80859[TASK] Add phpstan check for unneeded pseudo uncertain instanceof usage
Commit message
Review
-
Code review CR +2 Done
- Benjamin Franzke +2
- Nikita Hovratov +1
- Andreas Kienast +1
- Oliver Hader +1
-
Verified V +2 Done
- Benjamin Franzke +2
- Andreas Kienast +1
- Oliver Hader +1
- core-ci +1 CI
Issues 1
Files 42
- Build/phpstan/src/Rules/Classes/UnneededInstanceOfRule.phpnew+84 −0
- Build/phpstan/phpstan.neon+11 −0
- typo3/sysext/adminpanel/Classes/Modules/Debug/QueryInformation.php+1 −1
- typo3/sysext/backend/Classes/Controller/PageTsConfig/PageTsConfigActiveController.php+1 −2
- typo3/sysext/backend/Classes/Controller/PageTsConfig/PageTsConfigIncludesController.php+6 −14
- typo3/sysext/backend/Classes/Controller/AjaxLoginController.php+4 −1
- typo3/sysext/backend/Classes/Http/RouteDispatcher.php+1 −1
- typo3/sysext/backend/Classes/Security/ContentSecurityPolicy/CspAjaxController.php+1 −1
- typo3/sysext/backend/Classes/Template/Components/Buttons/DropDown/AbstractDropDownItem.php+1 −3
- typo3/sysext/backend/Classes/Template/Components/Buttons/DropDownButton.php+1 −3
- typo3/sysext/backend/Classes/Template/Components/Buttons/GenericButton.php+1 −3
- typo3/sysext/backend/Classes/View/BackendLayoutView.php+1 −4
- typo3/sysext/core/Classes/Domain/Repository/PageRepository.php+3 −5
- typo3/sysext/core/Classes/Error/AbstractExceptionHandler.php+1 −1
- typo3/sysext/core/Classes/Error/ProductionExceptionHandler.php+3 −4
- typo3/sysext/core/Classes/Imaging/IconFactory.php+8 −10
- typo3/sysext/core/Classes/Messaging/FlashMessageQueue.php+2 −4
- typo3/sysext/core/Classes/Routing/PageRouter.php+1 −1
- typo3/sysext/core/Classes/TypoScript/PageTsConfigFactory.php+1 −1
- typo3/sysext/dashboard/Classes/Controller/DashboardController.php+1 −1
Show 22 more files
- typo3/sysext/dashboard/Classes/DashboardInitializationService.php+4 −3
- typo3/sysext/extbase/Classes/Persistence/Generic/Mapper/DataMapper.php+3 −3
- typo3/sysext/extensionmanager/Classes/Utility/DependencyUtility.php+1 −1
- typo3/sysext/extensionmanager/Classes/Utility/InstallUtility.php+1 −4
- typo3/sysext/extensionmanager/Classes/Utility/ListUtility.php+13 −10
- typo3/sysext/felogin/Tests/Unit/Configuration/RecoveryConfigurationTest.php+1 −3
- typo3/sysext/form/Classes/Mvc/Persistence/FormPersistenceManager.php+1 −4
- typo3/sysext/frontend/Classes/ContentObject/FilesContentObject.php+2 −3
- typo3/sysext/frontend/Classes/Controller/ErrorController.php+4 −4
- typo3/sysext/frontend/Classes/Middleware/BackendUserAuthenticator.php+1 −1
- typo3/sysext/frontend/Classes/Middleware/SiteBaseRedirectResolver.php+1 −1
- typo3/sysext/frontend/Classes/Typolink/PageLinkBuilder.php+4 −14
- typo3/sysext/impexp/Classes/Controller/ExportController.php+2 −2
- typo3/sysext/impexp/Classes/Controller/ImportController.php+2 −3
- typo3/sysext/impexp/Classes/Export.php+1 −1
- typo3/sysext/install/Classes/Middleware/Maintenance.php+1 −1
- typo3/sysext/redirects/Classes/Hooks/DataHandlerSlugUpdateHook.php+4 −4
- typo3/sysext/redirects/Classes/Http/Middleware/RedirectHandler.php+25 −25
- typo3/sysext/scheduler/Classes/Scheduler.php+1 −1
- typo3/sysext/tstemplate/Classes/Controller/TemplateAnalyzerController.php+1 −8
- typo3/sysext/workspaces/Classes/Middleware/WorkspacePreview.php+3 −3
- composer.json+2 −1
Review log 1316
-
Benjamin Franzke uploaded patch set 1 09/05/23, 07:13
-
core-ci voted on patch set 1 V -1 09/05/23, 07:20 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/46214
-
Benjamin Franzke uploaded patch set 2
V -109/05/23, 07:48 -
core-ci voted on patch set 2 V -1 09/05/23, 08:00 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/46216
-
Oliver Klee commented on patch set 2 CR -1 09/05/23, 08:12
Please let's not do this. In many cases, the `instanceof` check reduces cognitive load for the reader, and I want our code to be easy to read and understand. -
Oliver Klee commented on patch set 2 09/05/23, 08:20
Explanation for the cognitive load thing: When the reader reads `if (x instanceof)`, they know that it's an instance of the given class after that. For an `!== null` check, they'll need to look in another place first (the method declaration, the return type declaration of a called method etc.) to first know which type it is. -
Oliver Klee commented on patch set 2 09/05/23, 08:40
Reply
Or am I misunderstanding the purpose of this change, and this is not about `$x instanceof Foo` on variables that are `Foo|null`? -
Benjamin Franzke uploaded patch set 3
CR -1V -110/18/23, 07:08 -
core-ci voted on patch set 3 V +1 10/18/23, 07:16 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/47890
-
Benjamin Franzke commented on patch set 3 10/18/23, 07:18
This change is ready for review.Reply
This is opinionated and not a suited argument for a decision. What matters is reduction of possible future bugs. Please see commit message where I described this in detail.Reply
It is. I added detailed explanations to the commit message. -
Andreas Kienast voted on patch set 3 V +1 CR +1 10/18/23, 07:18
-
Oliver Hader voted on patch set 3 CR +1 10/18/23, 07:58
-
Nikita Hovratov voted on patch set 3 CR +1 10/18/23, 08:08
-
Oliver Hader voted on patch set 3 V +1 10/18/23, 08:27
-
Benjamin Franzke voted on patch set 3 V +2 CR +2 10/18/23, 08:28
-
Benjamin Franzke merged patch set 4 10/18/23, 08:28