Skip to content

Improve static analysis by adding type hints for $app in artisan and public/index.php #6531

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 5, 2025

Conversation

AJenbo
Copy link
Contributor

@AJenbo AJenbo commented Jan 31, 2025

This PR adds explicit type hints for the $app variable in artisan and public/index.php using PHPDoc comments.
Why?

  • Improves static analysis by tools like PHPStan and PHPStorm, allowing them to correctly infer the type.
  • Prevents unnecessary warnings or incorrect suggestions in IDEs.
  • Enhances code readability by making it clear that $app is an instance of Illuminate\Foundation\Application.

Impact

  • No runtime behavior changes.
  • Does not introduce breaking changes.
  • Strictly improves developer experience.

Testing

Since this change only affects static analysis, no functional tests are included. However, I can set up PHPStan within the test suite if desired.

AJenbo and others added 3 commits January 31, 2025 19:15
Added PHPDoc type hints for the $app variable to improve static analysis
support in PHPStan and PHPStorm. This prevents tools from incorrectly
flagging the variable and enhances developer experience.

No functional changes; only improves code readability and IDE support.
@taylorotwell taylorotwell merged commit cf5aed8 into laravel:11.x Feb 5, 2025
4 checks passed
@AJenbo AJenbo deleted the feat/add-app-type-hints branch February 5, 2025 11:41
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.

2 participants