chore: refactor to declare more types#771
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #771 +/- ##
=========================================
Coverage 98.66% 98.66%
Complexity 1757 1757
=========================================
Files 71 71
Lines 5163 5164 +1
=========================================
+ Hits 5094 5095 +1
Misses 69 69 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| */ | ||
| #[\ReturnTypeWillChange] | ||
| public function offsetExists($offset): bool | ||
| public function offsetExists(mixed $offset): bool |
There was a problem hiding this comment.
These don't look so good. The PHPdoc used to say that $offset is an int
But the parent ArrayAccess::offsetExists(mixed $offset): boolallows anything as parameter 1. So we can't writepublic function offsetExists(int $offset): bool`
So we seem to lose something here, the PHPdoc type hint goes, but we can't preserve it in the actual parameter type declaration.
| $param->addValue(1); | ||
| $param->addValue('1'); |
There was a problem hiding this comment.
IMO addValue was supposed to always expect to be passed a string.
In this PR I enforced that. But this test was passing int literals to addValue
Trying some changes to type declarations now that PHP 8.2 is the minimum.
I thought that it might be easy to remove lots of
ReturnTypeWillChange.But it turns out to not always be simple. See a few comments below.