Project

General

Profile

Actions

Task #98097

closed

Add type hints to all GeneralUtility::makeInstance calls

Added by JAKOTA Design Group GmbH almost 2 years ago. Updated over 1 year ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Code Cleanup
Start date:
2022-08-06
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
11
PHP Version:
8.0
Tags:
Complexity:
easy
Sprint Focus:

Description

Hi,

This is a change request to make it easier for PHPStan to check the code and IDEs to give helpful hints.

As an example

public/typo3/sysext/backend/Classes/Controller/EditDocumentController.php

Line 541

$tce = GeneralUtility::makeInstance(DataHandler::class);

this should be changed to

/** @var DataHandler $tce */
$tce = GeneralUtility::makeInstance(DataHandler::class);

And I would like to suggest a change for coding styles like this.

Same file line 1079

$file = GeneralUtility::makeInstance(ResourceFactory::class)->getFileObject($fileUid);

This should be change in general to something like

/** @var ResourceFactory $resourceFactory */
$resourceFactory = GeneralUtility::makeInstance(ResourceFactory::class);
$file = $resourceFactory->getFileObject($fileUid);

Only this way PHPStan and your IDE knows what to expect and navigating from one file to the next is just a click away.

Thanks

Actions

Also available in: Atom PDF