77788[TASK] Use `list` as return type annotation for `GU::*Explode` methods
Commit message
Review
-
Code review CR +2 Done
- Christian Kuhn +2
- Oliver Klee +1
-
Verified V +2 Done
- Christian Kuhn +2
- Oliver Klee +1
- core-ci +1 CI
Issues 1
Files 1
Review log 2123
-
Elias Häußler uploaded patch set 1 02/08/23, 14:05
-
Oliver Klee commented on patch set 1 CR -1 02/08/23, 14:16
I had started something similar in https://review.typo3.org/c/Packages/TYPO3.CMS/+/75083 and would rebase my change once this change gets merged.GeneralUtility.php:837For return types, we should be as specific as possible. In this case, it should be array<int, int>, and for revExplode and trimExplode, it should be array<int, string>. -
core-ci voted on patch set 1 V +1 02/08/23, 14:21 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/37373
-
Oliver Klee commented on patch set 1 02/08/23, 14:22
Also, I'd be interested to learn how `list` would allow better static code analysis than `array`. (This is not a rhetorical question - I really would like to know.) -
Oliver Klee commented on patch set 1 CR +1 02/08/23, 17:59
Reply
I've found some documentation: https://phpstan.org/writing-php-code/phpdoc-types#lists > Lists are arrays with sequential integer keys starting at 0.GeneralUtility.php:837ReplyNow that I know what `list` actually means, this indeed is better than `array`. -
Oliver Hader voted on patch set 1 V +1 CR +1 02/08/23, 19:11
-
Nikita Hovratov commented on patch set 1 CR -1 02/09/23, 09:43
GeneralUtility.php:844As empty values are unset here, it sometimes does not return a pure sequential list. -
Nikita Hovratov commented on patch set 1 02/09/23, 09:47
GeneralUtility.php:856And here even it does add a string, that's why phpstan is complaining. -
Oliver Klee commented on patch set 1 02/09/23, 10:09
GeneralUtility.php:844ReplyAh, indeed. Then the return value needs to be array<int, int>.GeneralUtility.php:856ReplyI know. :-( I talked to Stefan Bürk about this. The part with the limit is not fully documented and contradicts the rest of the documented functionality of this method. This is why I'd like to deprecate the limit parameter before the 12LTS release. I'd suggest to keep the additional PHPStan warning in the meantime. -
Nikita Hovratov commented on patch set 1 02/09/23, 10:20
GeneralUtility.php:856Replyyes, do it! I've never used it so far and it does actually make no sense in this method. -
Nikita Hovratov commented on patch set 1 02/09/23, 10:21
GeneralUtility.php:844Replywe could also add a `array_values` at the end, but I don't know if there are any implications by doing so. -
Oliver Klee commented on patch set 1 02/09/23, 13:14
GeneralUtility.php:844ReplyDone (as a pre-patch): https://review.typo3.org/c/Packages/TYPO3.CMS/+/77802 As this is a change of behavior, I've marked the pre-patch as main-only, which then would make this change here main-only, tool. -
Oliver Klee commented on patch set 1 02/09/23, 14:49
GeneralUtility.php:856Reply -
Stefan Bürk commented on patch set 1 02/09/23, 20:41
GeneralUtility.php:856ReplyAs discussed with Oliver back than, personally I'm against it. I used the limit a lot, and expected it. Sure, I could replace that with plain php methods to achieve the same result in agency code (or at least the person taking over my code there). Given the name, despite the docblock, I always expected a "intExplode()" to behave like the "php explode()" method, as long as `$limit` is an option. So deprecating it would be the only way, as it cannot be dropped directly without change in behaviour and thus breaking. So I rather would not vote - neither on the deprecation nor on that patch. But this makes only sense, if the limit arguement has been removed. Which will not happen until v13. -
Oliver Klee commented on patch set 1 CR 0 02/09/23, 21:51
Then I propose we change this change to only affect trimExplode and revExplode so we can at least get those changes in. What do you think? -
Oliver Klee commented on patch set 1 02/11/23, 19:00
Elias, would you be okay with limiting this change to revExplode and trimExplode? If so, would you like to do the change, or should I do it? -
Elias Häußler commented on patch set 1 02/13/23, 06:56
Reply
Thanks for all your feedback and sorry for the late reply. Will take care of it now. -
Elias Häußler uploaded patch set 2
CR +1V +102/13/23, 07:57 -
core-ci voted on patch set 2 V +1 02/13/23, 08:34 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/37631
-
Oliver Klee voted on patch set 2 V +1 CR +1 02/13/23, 09:02
-
Christian Kuhn voted on patch set 2 V +2 CR +2 02/13/23, 09:12
-
Christian Kuhn merged patch set 3 02/13/23, 09:12