Review main Merged

68191[TASK] Enable phpstan parameter checkFunctionArgumentTypes

Daniel Goerz CR +2 V +2 Hard +407 −94 updated 03/12/21, 08:25

Commit message

From now on, phpstan will validate arguments passed to methods
for type integrity. This patch also resolves all remaining
issues in the core up to PHP 7.4.

Running phpstan on PHP 8 is therefore disabled temporarily and
will be enabled again with another patch that resolves all
remaining PHP 8 issues regarding argument types.

Review

  • Code review CR +2 Done
    • Benni Mack +2
    • Richard Haeser +1
  • Verified V +2 Done
    • Benni Mack +2
    • Richard Haeser +1
    • TYPO3com +1 CI
    • core-ci +1 CI

Issues 1

Files 62

Show 42 more files

Review log 1838

Show 513 earlier messages
  1. Daniel Goerz uploaded patch set 1 03/05/21, 10:53

  2. Daniel Goerz wrote 03/05/21, 10:53

    Topic set to phpstan
  3. TYPO3com voted on patch set 1 V -1 03/05/21, 11:00 Completed build in 07m 00s on Fri, 5 Mar, 11:00 AM Test Summary: 32742 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-9860

  4. core-ci voted on patch set 1 V -1 03/05/21, 11:06 Core CI is not happy: https://core.b13.com/typo3-core/typo3.cms/-/pipelines/1193

  5. Daniel Goerz uploaded patch set 2 03/06/21, 08:37

  6. TYPO3com voted on patch set 2 V -1 03/06/21, 08:43 Completed build in 05m 56s on Sat, 6 Mar, 08:43 AM Test Summary: 32742 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-9874

  7. core-ci voted on patch set 2 V -1 03/06/21, 08:48 Core CI is not happy: https://core.b13.com/typo3-core/typo3.cms/-/pipelines/1210

  8. Daniel Goerz uploaded patch set 3 03/06/21, 09:02

  9. TYPO3com voted on patch set 3 V -1 03/06/21, 09:09 Completed build in 06m 44s on Sat, 6 Mar, 09:09 AM Test Summary: 32742 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-9875

  10. core-ci voted on patch set 3 V -1 03/06/21, 09:16 Core CI is not happy: https://core.b13.com/typo3-core/typo3.cms/-/pipelines/1211

  11. Daniel Goerz rebased onto patch set 4 03/08/21, 15:19

  12. TYPO3com voted on patch set 4 V -1 03/08/21, 15:25 Completed build in 05m 38s on Mon, 8 Mar, 03:25 PM Test Summary: 32638 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-9932

  13. core-ci voted on patch set 4 V -1 03/08/21, 15:29 Core CI is not happy: https://core.b13.com/typo3-core/typo3.cms/-/pipelines/1276

  1. Daniel Goerz uploaded patch set 5 03/08/21, 16:17

  2. TYPO3com voted on patch set 5 V -1 03/08/21, 16:23 Completed build in 05m 40s on Mon, 8 Mar, 04:23 PM Test Summary: 32638 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-9933

  3. core-ci voted on patch set 5 V -1 03/08/21, 16:27 Core CI is not happy: https://core.b13.com/typo3-core/typo3.cms/-/pipelines/1277

  4. Daniel Goerz uploaded patch set 6 03/09/21, 08:26

  5. TYPO3com voted on patch set 6 V -1 03/09/21, 08:31 Completed build in 05m 24s on Tue, 9 Mar, 08:31 AM Test Summary: 32638 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-9956

  6. core-ci voted on patch set 6 V -1 03/09/21, 08:38 Core CI is not happy: https://core.b13.com/typo3-core/typo3.cms/-/pipelines/1304

  7. Daniel Goerz rebased onto patch set 7 03/09/21, 15:08

  8. TYPO3com voted on patch set 7 V -1 03/09/21, 15:18 Completed build in 10m 00s on Tue, 9 Mar, 03:18 PM Test Summary: 32680 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-9975

  9. core-ci voted on patch set 7 V -1 03/09/21, 15:22 Core CI is not happy: https://core.b13.com/typo3-core/typo3.cms/-/pipelines/1330

  10. Daniel Goerz uploaded patch set 8 03/09/21, 16:22

  11. core-ci voted on patch set 8 V -1 03/09/21, 16:32 Core CI is not happy: https://core.b13.com/typo3-core/typo3.cms/-/pipelines/1335

  12. TYPO3com voted on patch set 8 V -1 03/09/21, 16:45 Completed build in 21m 29s on Tue, 9 Mar, 04:45 PM Test Summary: 32680 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-9980

  13. Daniel Goerz uploaded patch set 9 03/11/21, 10:10

  14. Daniel Goerz updated the commit message in patch set 10 03/11/21, 10:15

  15. Daniel Goerz commented on patch set 10 03/11/21, 10:16

    This change is ready for review.
  16. TYPO3com voted on patch set 9 V +1 03/11/21, 10:18 Completed build in 07m 06s on Thu, 11 Mar, 10:18 AM Test Summary: 32680 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-10046

  17. TYPO3com voted on patch set 10 V +1 03/11/21, 10:23 Completed build in 07m 35s on Thu, 11 Mar, 10:23 AM Test Summary: 32680 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-10047

  18. core-ci voted on patch set 9 V +1 03/11/21, 10:23 Core CI is happy: https://core.b13.com/typo3-core/typo3.cms/-/pipelines/1410

  19. core-ci voted on patch set 10 V +1 03/11/21, 10:25 Core CI is happy: https://core.b13.com/typo3-core/typo3.cms/-/pipelines/1411

  20. Richard Haeser voted on patch set 10 V +1 CR +1 03/11/21, 13:00

  21. Benni Mack voted on patch set 10 V +2 CR +2 03/11/21, 20:02

  22. Benni Mack merged patch set 11 03/11/21, 20:02

  23. Benni Mack commented on patch set 11 03/11/21, 20:03

    great work.
  24. Sascha Egerer commented on patch set 11 03/12/21, 07:37

    ImageProcessController.php:57 Unresolved

    `GeneralUtility::locationHeaderUrl()` can now get an empty string and so it will return an empty string. RedirectResponse will then create a `Location` header without a value as the value is an empty string. That means the header will not work at all. I think this will hide an deeper issue and it does maybe more sense to fail here if getPublicUrl is empty. What do you think?

    InlineRecordContainer.php:392 Unresolved

    Creating an image tag with a src "/" does not make that much sense. If there is no public url the image tag should not be created at all

    FileInfoElement.php:92 Unresolved

    Same here. If there is no public url it does not make sense to create the link. The a tag should just be skipped while the text can still be rendered.

    ShortcutButton.php:329 Unresolved

    `?:` should not be used as it is an unsafe comparison. PHPStan will also complain about that in a stricter mode. But I'm not sure if there is a TYPO3 core related decision about that. So I'm fine if with it if most people say we should go this way.

    BackendUtility.php:1064 Unresolved

    No public url = no image tag

    BackendLogController.php:230 Unresolved

    `$timestampDay` can be false. Passing false as array key does not make sense. as this will be casted to `0` which could end up in unexpected results (maybe not in this case but in general). So i would just add a `$timestampDay !== false` in the if condition below

    AbstractUserAuthentication.php:826 Unresolved

    Calling getRawUserByUid with 0 does not make sense. So we should first check if it's a valid value

    Pbkdf2PasswordHash.php:208

    I think the 4 should maybe still be kept as 4th parameter but this can be done in another patch (which is not really required IMO).

    Resolver.php:67 Unresolved

    This annotation should be moved up to line 50

    IconRegistry.php:476 Unresolved

    We can do an early return here which is cleaner. $iconContent = file_get_contents($absoluteIconDeclarationPath); if (empty($iconContent)) { return; }

    ImageProcessingService.php:64 Unresolved

    This is the wrong place to fix that issue. `$this->processedFileRepository->findByUid()` must be fixed to return the correct type. The annotation in line 57 should then also be removed. We should prevent those annotations as much as possible as they are "hardcore overwrites". If the called method is changed this place can never be detected by a static code linter as broken as we say "ignore whatever the method says it does return. It's always of this type". So... is like shooting in our own foot :)

    ListController.php:211 Unresolved

    Same here. `findAll` must be fixed to return the correct type.

    FileList.php:809 Unresolved

    no source = no image tag

    WorkspaceNewPlaceholderRemovalMigration.php:72 Unresolved

    I would do the cast once in the first line of foreach so the array does also use a string key.

    FileStorageExtractionTask.php:54 Unresolved

    IMO we should throw more specific exceptions but thats not a must.

    FileStorageIndexingTask.php:46 Unresolved

    IMO we should throw more specific exceptions but thats not a must.
  25. Daniel Goerz commented on patch set 11 03/12/21, 08:25

    Hi Sascha, thanks for your Feedback. The main goal was to finally activate the option to stop new code from introducing new errors. I agree that the code could be improved further. Especially the ->getPublicUrl() null cases. I’ll have a look into that once phpstan runs with the activated argument type checking on PHP 8 again. In the meantime feel free to push patches improving code quality, always welcome.