Skip to content

method.nonObject does not recognize object creation since 2.1.13 #12940

@maddy42

Description

@maddy42

Bug report

good morning everyone, we found a possible problem with latest update 2.1.13, where object creation followed by object usage leads to method.nonObject report.

I give the full message here:
` ------ --------------------------------------------------------------
Line frontend/Classes/Controller/TypoScriptFrontendController.php


268 Cannot call method setTemplateFile() on null.
🪪 method.nonObject
277 Cannot call method setLanguage() on null.
🪪 method.nonObject


`

The mentioned code is
$this->pageRenderer = GeneralUtility::makeInstance(PageRenderer::class); $this->pageRenderer->setTemplateFile('EXT:frontend/Resources/Private/Templates/MainPage.html'); ..... $this->pageRenderer->setLanguage($locale);
https://git.typo3.org/typo3/CI/cms/-/blob/main/typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php?ref_type=heads#L267

object creation is done via
public static function makeInstance(string $className, mixed ...$constructorArguments): object {}
see https://git.typo3.org/typo3/CI/cms/-/blob/main/typo3/sysext/core/Classes/Utility/GeneralUtility.php?ref_type=heads#L2806

the object in question can't be null, there would have been an exception before, if anything goes wrong. The function signature clearly states to expect an object.

Could you please take a look at this? Thank you very much.

Code snippet that reproduces the problem

No response

Expected output

no mention of this place having the possibility to be null.

Did PHPStan help you today? Did it make you happy in any way?

well, not exactly happy today, but it is very helpful to keep issues at bay. Thank you for each and every update, even when we have to fiddle to keep up.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions