Merge conflict Gerrit cannot merge this change. It needs a rebase onto main.
92589[TASK] Replace unneeded instanceof on xxx|null. Use a null check instead
Commit message
Test this change
Run a command in your clone of the TYPO3 Core. Then try what the change does and vote on Verified in Gerrit. How to review a patch
- Check out patch set 3
-
git fetch https://review.typo3.org/Packages/TYPO3.CMS refs/changes/89/92589/3 && git checkout FETCH_HEAD - Cherry-pick onto main
-
git fetch https://review.typo3.org/Packages/TYPO3.CMS refs/changes/89/92589/3 && git cherry-pick FETCH_HEAD
Review
-
Code review CR -2 Blocked
- Benjamin Franzke -2
-
Verified V -1 Blocked
- core-ci -1 CI
Relation chain 2
-
92589 [TASK] Replace unneeded instanceof on xxx|null. Use a null check instead This change
-
main
92349[TASK] Replace deprecated usage for custom phpstan rule and add tests
The chain has patch set 9 of 11, the changes above it need a rebase.
Issues 2
Files 41
- Build/phpstan/phpstan-baseline.neon+0 −6
- typo3/sysext/backend/Classes/Controller/ContentElement/ElementInformationController.php+3 −3
- typo3/sysext/backend/Classes/Controller/SiteConfigurationController.php2+3 −3
- typo3/sysext/backend/Classes/RecordList/DatabaseRecordList.php+1 −1
- typo3/sysext/backend/Classes/Utility/BackendUtility.php+2 −2
- typo3/sysext/core/Classes/Context/UserAspect.php+1 −1
- typo3/sysext/core/Classes/Database/Schema/DefaultTcaSchema.php1+1 −1
- typo3/sysext/core/Classes/Http/UploadedFile.php+1 −1
- typo3/sysext/core/Classes/Imaging/Icon.php4+1 −1
- typo3/sysext/core/Classes/Imaging/ImageProcessingInstructions.php2+2 −2
- typo3/sysext/core/Classes/Imaging/ImageProcessingResult.php+1 −1
- typo3/sysext/core/Classes/Localization/Loader/XliffLoader.php+1 −1
- typo3/sysext/core/Classes/Localization/Parser/XliffParser.php+1 −1
- typo3/sysext/core/Classes/Mail/MemorySpool.php+1 −1
- typo3/sysext/core/Classes/Messaging/FlashMessageQueue.php+1 −1
- typo3/sysext/core/Classes/Resource/Collection/FolderBasedFileCollection.php+1 −1
- typo3/sysext/core/Classes/Resource/DefaultUploadFolderResolver.php+1 −1
- typo3/sysext/core/Classes/Schema/TcaSchema.php1+1 −1
- typo3/sysext/extbase/Classes/Persistence/Generic/Mapper/DataMapper.php+1 −1
- typo3/sysext/extbase/Classes/Persistence/Generic/Storage/Typo3DbQueryParser.php1+2 −2
Show 21 more files
- typo3/sysext/extbase/Classes/Validation/ValidatorResolver.php+2 −2
- typo3/sysext/extensionmanager/Classes/Utility/ListUtility.php+2 −2
- typo3/sysext/felogin/Classes/Controller/PasswordRecoveryController.php+2 −2
- typo3/sysext/filelist/Classes/ElementBrowser/FileBrowser.php+1 −1
- typo3/sysext/filelist/Classes/ElementBrowser/FolderBrowser.php+1 −1
- typo3/sysext/fluid/Classes/Core/ViewHelper/ViewHelperResolver.php+1 −1
- typo3/sysext/fluid/Classes/Core/ViewHelper/ViewHelperResolverFactory.php+1 −1
- typo3/sysext/fluid/Classes/ViewHelpers/Form/UploadDeleteCheckboxViewHelper.php1+1 −1
- typo3/sysext/fluid/Classes/ViewHelpers/Format/HtmlViewHelper.php1+1 −1
- typo3/sysext/form/Classes/Domain/Runtime/FormRuntime.php1+1 −2
- typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php+1 −1
- typo3/sysext/frontend/Classes/Html/HtmlWorker.php+2 −2
- typo3/sysext/frontend/Classes/Imaging/GifBuilder.php+4 −5
- typo3/sysext/frontend/Classes/Middleware/SiteResolver.php+1 −2
- typo3/sysext/install/Classes/ExtensionScanner/Php/Matcher/MethodAnnotationMatcher.php+1 −2
- typo3/sysext/install/Classes/ExtensionScanner/Php/Matcher/PropertyAnnotationMatcher.php+1 −2
- typo3/sysext/install/Classes/SystemEnvironment/ServerResponse/FileDeclaration.php1+1 −1
- typo3/sysext/install/Tests/Unit/SystemEnvironment/DatabaseCheck/Platform/MySqlTest.php+2 −4
- typo3/sysext/lowlevel/Classes/ConfigurationModuleProvider/BackendRoutesProvider.php+1 −1
- typo3/sysext/redirects/Classes/Repository/Demand.php+1 −1
- typo3/sysext/webhooks/Classes/Message/PageModificationMessage.php+1 −1
Review log 1518
-
Simon Schaufelberger uploaded patch set 1 01/30/26, 13:33
-
core-ci voted on patch set 1 V -1 01/30/26, 13:44 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/94668
-
Simon Schaufelberger uploaded patch set 2
V -101/30/26, 13:52 -
core-ci voted on patch set 2 V +1 01/30/26, 13:59 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/94671
-
Garvin Hicking commented on patch set 2 01/30/26, 21:43
I must say I kind of like having it in the code to implicitly see which type is expected there. Also it could be forward compatible in case something could be an interface but we want specific type checks? This feels too broad and dangerous to me. -
Simon Schaufelberger commented on patch set 2 01/30/26, 22:29
Reply
I don't want to start any discussion here. The original phpstan rule came from https://review.typo3.org/c/Packages/TYPO3.CMS/+/80859 and in https://review.typo3.org/c/Packages/TYPO3.CMS/+/92349?tab=comments Stefan already starte a new discussion. So instead of starting a third discussion here, please comment on the one from https://review.typo3.org/c/Packages/TYPO3.CMS/+/92349?tab=comments. -
Garvin Hicking commented on patch set 2 01/30/26, 22:40
Reply
Hmkay, but why spawn multiple patches already if there's discussion? Anyways, I just dislike this specific patch here, and have not checked out the others ones. Will try to see what's up. -
Simon Schaufelberger commented on patch set 2 01/30/26, 23:22
Reply
This is just the change that stefan requested in the phpstan rule and that would result in the change of these files here, that's why it's a pre-patch. -
Garvin Hicking commented on patch set 2 CR -1 01/31/26, 10:02
checkingReply Unresolved
Thanks, I see. Let me go through each instance, I have the feeling there are several that are really 100% perfectly fine, but spotted a few where I want to check the incoming data if it might be possible to come from consumer PSR-Events/Hooks or from files without strict types. -
Garvin Hicking commented on patch set 2 01/31/26, 10:16
SiteConfigurationController.php:553Unresolvedthis is a place I still find helpful/userful, since it's not strictly type safe and only deduced from a type hint, not a type declaration. $allSites comes from SiteConfigurationController->saveAction and there from siteConfiguration->resolveAllExistingSitesRaw(). Now this is hyperbole theoretical, but if at some point we introduce a PSR-event to manipulate the array or even some new Object that is not a Site but something else, we'll have to chew through all places where distinctions need to be made. IMO it would then help to have (at least a few) instances of "instanceof Site" checks that would directly hint me at this. So my thought is, at places where we have arrays or just PHPdoc typehints, we should not remove this instanceof.SiteConfigurationController.php:571Unresolvedsame here -
Garvin Hicking commented on patch set 2 01/31/26, 12:30
UploadDeleteCheckboxViewHelper.php:69UnresolvedNot safe hereHtmlViewHelper.php:84UnresolvedIf I read this correctly the enforced return type is only "object" and it's not safe we'll have a ServerRequestInterface? Needs thorough checking.FormRuntime.php:399UnresolvedOnly type hinted, not safeFileDeclaration.php:123UnresolvedThis is only type-hinted and not type declared, I'd leave it out -
Garvin Hicking commented on patch set 2 01/31/26, 13:55
Reply
done with my inspections, see comments.DefaultTcaSchema.php:839Unresolvedunsure due to array, needs investigationIcon.php:241Only type-hinted, maybe not safeImageProcessingInstructions.php:54UnresolvedI think in the past working here I've come across cases where this was a stdObject. Needs thorough investigation.ImageProcessingInstructions.php:134UnresolvedsameTcaSchema.php:261Unresolvedneeds safe investigation due to array, I would leave itTypo3DbQueryParser.php:133Unresolvedonly type-hinted, not type-safe -
Benjamin Franzke commented on patch set 2 CR -2 04/02/26, 11:31
Icon.php:241ReplyAck and Thanks! It is important we do not trust doctypes here. You mentioned this in a lot of cases, which brings me to the following question: Why are all these changes applied by that rector rule at all @simonschaufi+typo3@gmail.com? I've explicitly and on purpose disabled treating doctypes as certain when I introduced this phpstan rule in: > 80859: [TASK] Add phpstan check for unneeded pseudo uncertain instanceof usage | https://review.typo3.org/c/Packages/TYPO3.CMS/+/80859 See https://review.typo3.org/c/Packages/TYPO3.CMS/+/80859/4/Build/phpstan/phpstan.neon#14 We should *only* "prepare" to fix cases than are *actually* found by (whatever) improvement we apply to that rule. That means I'm against applying changes because of rector results. Please only include changes in here that will be marked as invalid with https://forge.typo3.org/issues/108652 Also: To be able to review this change, that referenced change needs to be ready. (relation chain seems swapped and not up to date) Applying -2 here, not because I want to block anything, but because this is really important to avoid introducing hard-to-trace regressions. Ping me in Slack if I miss to respond to changes, please. -
Benni Mack updated the commit message in patch set 3
CR -1V +104/22/26, 06:45Copied Votes: * Code-Review-2 (copy condition: "changekind:NO_CHANGE OR **is:MIN**") -
core-ci voted on patch set 3 V -1 04/22/26, 11:30 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/100783
-
Benni Mack commented on patch set 3 09/02/26, 19:44
Icon.php:241ReplyI don't know the current state here, but I suggest to either abandon this change or put this change into WIP for the time being -
Simon Schaufelberger commented on patch set 3 09/02/26, 20:59
Icon.php:241Reply UnresolvedAs mentioned in the commit message, this is a pre-patch and shows what must be changed for the phpstan rule change. I'll mark this as WIP as I still need to talk with Stefan Bürk about this change. -
Simon Schaufelberger marked it work in progress 09/02/26, 20:59