Review main Merged

74637[TASK] Remove dead code paths identified by PHPStan

crell CR +2 V +2 Normal +15 −84 updated 05/28/22, 20:26

Commit message

According to PHPStan, these checks are all unnecessary.
Most of them appear to be type checks that have been
rendered unnecessary due later type additions. They
are therefore removed without replacement.

Used command:

> Build/Scripts/runTests.sh -s phpstanGenerateBaseline

Review

  • Code review CR +2 Done
    • Stefan Bürk +2
    • Oliver Klee +1
    • Nikita Hovratov +1
  • Verified V +2 Done
    • Stefan Bürk +2
    • Nikita Hovratov +1
    • core-ci +1 CI

Issues 1

Files 11

Review log 1925

  1. crell uploaded patch set 1 05/12/22, 21:37

  2. core-ci voted on patch set 1 V +1 05/12/22, 21:46 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/27154

  3. crell uploaded patch set 2 05/12/22, 21:54

  4. crell uploaded patch set 3 05/12/22, 21:56

  5. core-ci voted on patch set 2 V +1 05/12/22, 22:01 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/27156

  6. core-ci voted on patch set 3 V +1 05/12/22, 22:03 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/27157

  7. Stefan Bürk updated the commit message in patch set 4 05/13/22, 00:23

  8. Stefan Bürk commented on patch set 4 05/13/22, 00:29

    IpLocker.php:84

    This *must* be kept on backport.

    LazyObjectStorage.php:181

    Not sure about this. In the whole chain which can happen, most is only doctyped. In the shipped core way, this will end up with a guaranteed int for $numberOfElements. But if there are Backend/StorageBackend overrides used (xclass/custom) this may be not the case as the corresponding interfaces are not (strict) return typed. How should we proceed with this ?
  9. core-ci voted on patch set 4 V +1 05/13/22, 00:30 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/27161

  10. crell commented on patch set 4 05/13/22, 13:54

    IpLocker.php:84 Reply

    None of these changes affect a signature, so why would they be backported?

    LazyObjectStorage.php:181 Reply

    My inclination is to say "if you have a class that is not following the docblock types, it's already your bug, not core's, so you're on your own." The only way I can see that someone could get a non-countable object in there is to override either QueryInterface or DataMapper. Both seem like edge cases. Plus, if they were overriding either in a way that returns null, they'd be hitting an exception already. So I don't see a way that any existing *working* code could be broken here. The worst case is that, in the future, it would be possible to write buggy extension code that returns null and you wouldn't get a dedicated error message. But the extension code would still be just as buggy. Moving the types from docblocks to the signature should also be done, but I don't think that's necessarily a blocker here.
  11. Stefan Bürk commented on patch set 4 05/13/22, 14:07

    IpLocker.php:84 Reply

    Why should we not backport removal of dead code and clean phpstan baseline in 11 lts also ? At least if it is possible and doable. Howver this is the only part which must be kept, as explode() in 7.4 may return false instead of a exception. This comment is just a reminder that it get not forgotten on the backport.
  12. crell commented on patch set 4 05/13/22, 14:43

    IpLocker.php:84 Reply

    "Don't mess with LTS unless you have to" is the standard I'm used to. Georg mentioned in a previous issue that LTS has been broken by accident in the past, and these changes have no impact on cross-version compatibility the way type changes would, so I just don't see the point. If they do get backported then I concur the explode() change should not be included for reasons stated. I just doing see the point in backporting any of it.
  13. Stefan Bürk uploaded patch set 5 05/13/22, 17:56

  14. core-ci voted on patch set 5 V +1 05/13/22, 18:03 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/27187

  15. Stefan Bürk commented on patch set 5 05/13/22, 18:05

    IpLocker.php:84 Reply

    For me for backport to 11.5: * bugfixes fixing issues (errors, missbehaviours, not working correct etc) * security bugfixes * removing dead-code * docblock improvements for phpstan / baseline reducing (if doable) which not (or must be at least changed during backport): * breaking type/return type additions (exception may be made for internal marked classes - depends) * features are a no-go for backport * if backport needs a lot of adjustments which renders the backport nearly to a fully new patch - decide to leave it out (except it's a security or tougher bug which is fixed ...) for 10.4 backport it's even smaller: * only security bugfixes * only really annoying bugfixes for real issues * no phpstan/docblock/typehint/return only patches just as a dumb-rule thing. In the end, the merger who merges the patch may decide if he really takes the responibility for the backport or not.
  16. crell commented on patch set 5 05/16/22, 19:37

    IpLocker.php:84 Reply

    Done
  17. Stefan Bürk commented on patch set 5 V +1 CR +1 05/16/22, 23:27

    LazyObjectStorage.php:181 Reply

    Done
  18. Oliver Klee voted on patch set 5 CR +1 05/17/22, 08:02

  19. Oliver Klee wrote 05/18/22, 19:41

    Removed reviewer Oliver Klee with the following votes: * Code-Review+1 by Oliver Klee
  20. Nikita Hovratov rebased onto patch set 6 05/27/22, 14:10

  21. Nikita Hovratov voted on patch set 6 V +1 CR +1 05/27/22, 14:16

  22. core-ci voted on patch set 6 V +1 05/27/22, 14:18 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/27493

  23. Oliver Klee voted on patch set 6 CR +1 05/27/22, 14:43

  24. Stefan Bürk voted on patch set 6 V +2 CR +2 05/28/22, 20:26

  25. Stefan Bürk merged patch set 7 05/28/22, 20:26