fix: phpstan error in v1.8.8#6637
fix: phpstan error in v1.8.8#6637MGatner merged 3 commits intocodeigniter4:developfrom ddevsr:patch-1
Conversation
datamweb
left a comment
There was a problem hiding this comment.
A poorly timed release!
|
@MGatner Now PHPUnit & PHPStan already passed |
|
The PHPUnit failure looks unrelated (Predis connection failure m). Merging! |
| $intCurrentIndex = (int) $currentIndex; | ||
|
|
||
| if ((empty($currentIndex) && (int) $currentIndex !== 0) || (! isset($array[$currentIndex]) && $currentIndex !== '*')) { | ||
| if (empty($currentIndex) && $intCurrentIndex !== 0 || (! isset($array[$currentIndex]) && $currentIndex !== '*')) { |
There was a problem hiding this comment.
If $currentIndex is null, empty($currentIndex) is true and $intCurrentIndex !== 0 is false.
If $currentIndex is not null, empty($currentIndex) is false and $intCurrentIndex !== 0 is true.
So the left side is still always false.
There was a problem hiding this comment.
Does this seem better?
// Grab the current index
$currentIndex = $indexes ? array_shift($indexes) : null;
if ($currentIndex === null || (! isset($array[$currentIndex]) && $currentIndex !== '*')) {
return null;
}There was a problem hiding this comment.
I'm sorry, I didn't realize it changed between my review and the merge. This was originally just removing the extraneous part of the conditional.
Yours is better but this still has a lot of cognitive complexity and anyone working on it in the future will need to spend some time figuring it out. Maybe we should break it up into separate return statements? Or extract the second half of the conditional as a variable with a helpful name?
Description
See https://github.com/codeigniter4/CodeIgniter4/actions/runs/3197626681/jobs/5221091878
Checklist: