-
Notifications
You must be signed in to change notification settings - Fork 2
refactor: Fix most PHPStan errors #71
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
Conversation
|
By the way, does this project really still support PHP 7.4? If we’d drop PHP 7.4 support, maybe even #59 could be merged some day (which is basically stalled on too old PHP versions pinned in |
|
Thanks A LOT ! |
- Add missing return types. In closures touched anyway, also add parameter types. - Avoid capturing unused variables. They are used in the commented-out part; to make the commented-out part work out of the box if uncommented, use arrow functions (available since PHP 7.4) instead of traditional anonymous functions: arrow functions capture variables automatically, so the `use` block can simply be skipped. Use arrow functions for other touched closures as well. - Add return types to `JsonSerializable::jsonSerialize()` overrides. The lack of return types cause deprecation warnings on PHP 8. The recommended return type of `mixed` cannot be used on PHP 7.4 (which we still support according to `composer.json`), but fortunately all classes consistently return arrays, so `array` could be added as a return type instead (which is available in PHP 7.4 as well, and which is stricter than the type stated by the interface – covariant return types are allowed since PHP 7.4). - Fix a wrongly documented type: the nicknames are objects, not strings. Refactor the code a bit to make it easier to tell this PHPStan. I skipped one error that looks real and that I don’t know how to fix: the documentation states that `App\Model\Overpass\Element::$tags` is nullable but it’s used as if it wasn’t; I don’t know Overpass, so I have no idea which one is right.
|
Just need to rebase your PR 👌 |
|
Thanks for rebasing and merging! Sorry, I’ve been a bit busy IRL in the past week. |
|
Also, could you please take care of the remaining two errors? It’s important that there are no permanent errors, as it makes new ones much easier to spot. |
|
See #73 |
|
Thanks, but I asked you to take care of them because I think the errors should be addressed rather than suppressed. I could also have added the
(On the other hand, passing CI is still better than failing CI, so thanks anyway.) |
useblock can simply be skipped. Use arrow functions for other touched closures as well.JsonSerializable::jsonSerialize()overrides. The lack of return types cause deprecation warnings on PHP 8. The recommended return type ofmixedcannot be used on PHP 7.4 (which we still support according tocomposer.json), but fortunately all classes consistently return arrays, soarraycould be added as a return type instead (which is available in PHP 7.4 as well, and which is stricter than the type stated by the interface – covariant return types are allowed since PHP 7.4).I skipped a few errors that look real and that I don’t know how to fix.