Skip to content

feat: add conditional return type to getEnv#37

Merged
loks0n merged 1 commit intomainfrom
feat/condition-return-types
Mar 15, 2026
Merged

feat: add conditional return type to getEnv#37
loks0n merged 1 commit intomainfrom
feat/condition-return-types

Conversation

@loks0n
Copy link
Contributor

@loks0n loks0n commented Mar 15, 2026

Summary

  • Adds PHPStan conditional return type annotation to getEnv
  • When $default is null (or omitted), return type is string|null
  • When a non-null string is passed, return type narrows to string
  • Eliminates the need for ?? fallback at call sites where a non-null default is provided

Test plan

  • PHPStan passes at --level=max

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Documentation
    • Improved type annotations for enhanced code reliability and developer experience.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@coderabbitai
Copy link

coderabbitai bot commented Mar 15, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 962e2a8c-cb27-4d4f-b069-0733814ad17f

📥 Commits

Reviewing files that changed from the base of the PR and between 6441a9c and 484b930.

📒 Files selected for processing (1)
  • src/System/System.php

Walkthrough

Updated the docblock for the getEnv method in src/System/System.php to introduce a generic template parameter TDefault and conditional return type annotation. The @param TDefault $default documentation was added, and the return type declaration was modified to reflect the conditional behavior based on whether a default value is provided. The actual function implementation and signature remain unchanged.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title clearly and specifically describes the main change: adding a conditional return type to the getEnv function.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/condition-return-types
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@loks0n loks0n merged commit 7c16695 into main Mar 15, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant