-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
feat: improve phpstan level 9 with all errors resolved #7248
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
base: 4.4.x
Are you sure you want to change the base?
feat: improve phpstan level 9 with all errors resolved #7248
Conversation
Assert and cast mixed parameter based on option name: charset/collation: ensure null or non-empty string default_constraint_name: assert non-empty string enumType: assert string with class-string PHPDoc jsonb/version: cast to bool Satisfies PHPStan level 9 strict type checking for array
|
@shakaran before we proceed, could you share a good strawberry pie recipe with us? |
why is this relevant? I am fixing this thing with phpstan this step by step. I am a programmer, not a chef. Do you make this like a captcha or so? xD pretty funny |
|
Yes, I wanted to make sure you’re a human. You’re making random changes in the codebase making it obviously worse. |
Human here, I am not a 100% expert, but trying to learn at most. So please, I would like to know which is wrong, I will spending my free saturday night in fix 550 errors in repetitive batches of similar errors. I am commiting per small batch of fixes, but any help is welcome in the peer review |
…variables in Platforms
|
@shakaran what are you trying to learn? |
Taking big and complex open source projects with complex params or types, and raise steps of phpstan levels or strong typing to improve in closed private and legacy projects that need the same. For example, I am applying intermediate variables so phpstan get the type infered, with that the error is removed, but for you probably that is worse in the codebase. I would like to know if there are some other options (rather than ignore the error). Other cases for example doing a casting in the same variable and assignement, for example $a = (string) $a; Or even: Or doing If this is wrong, I would like to know how to resolve it in future. That will teach me how to do it in the right way |
…racleMetadataProvider
|
The current PHPStan level reflects the deficiencies of some DBAL APIs that were designed ~15 years ago for PHP 5. In turn, those to a certain degree are inspired by the APIs of the underlying database drivers and the PHP language itself. Attempting to satisfy PHPStan by adding random conditions in random places without improving the APIs looks like a cargo cult to me. See #4007 for a proper example. It doesn't chase a higher PHPStan level explicitly, but it does improve the type safety which PHPStan appreciates. |
Summary
Improve phpstan level 9 with all errors resolved