Skip to content

Conversation

@sumaiazaman
Copy link
Contributor

Summary

This PR improves the PHPStan configuration to enhance type safety while maintaining compatibility with Laravel's dynamic features.

Changes Made

  • Increased PHPStan level from 1 to 3 for stricter static analysis
  • Removed unnecessary ignored errors that should be properly addressed:
    • Removed #\\(void\\) is used# - void usage should be explicit
    • Removed #but return statement is missing.# - return types should be consistent
    • Removed #has invalid type# - type declarations should be valid
  • Added explanatory comments for remaining ignored errors
  • Kept framework-specific patterns that are intentionally dynamic (like new static)

Benefits

  • Better type safety: Higher PHPStan level catches more potential issues
  • Improved code quality: Fewer suppressed errors means addressing real problems
  • Better developer experience: More accurate IDE support and error detection
  • Gradual improvement: Maintains compatibility while moving toward stricter typing

Testing

  • Static analysis passes with the new configuration
  • Existing functionality remains unchanged
  • Framework's dynamic features continue to work as expected

This change follows Laravel's commitment to improving type safety while preserving the framework's flexibility and ease of use.

- Increase PHPStan level from 1 to 3 for stricter analysis
- Remove unnecessary ignored errors that should be addressed
- Add comments explaining remaining ignored errors
- Keep framework-specific patterns that are intentionally dynamic

This change improves type safety while maintaining compatibility
with Laravel's dynamic features.
@sumaiazaman sumaiazaman changed the title Improve PHPStan configuration for better type safety [12.x] Improve PHPStan configuration for better type safety Nov 11, 2025
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