alexanderschnitzler/phpstorm.meta.php-typo3

This package contains a .phpstorm.meta.php file which can be used to ease the work with TYPO3 projects in phpstorm.

dev-main 2021-09-17 09:58 UTC

This package is auto-updated.

Last update: 2024-12-17 16:41:46 UTC


README

This repository contains a .phpstorm.meta.php file which can be used to ease the work with TYPO3 projects in phpstorm. TYPO3 comes with a couple of factory methods which cannot clearly define a return type. In the past, a dynamicReturnTypeMeta.json file has often been used to tackle said issue. This however depends on a certain plugin to be installed. A .phpstorm.meta.php file can be used out of the box with all current phpstorm version.

Example

$class = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\Foo::class);

In TYPO3, this method is usually used as a replacement for new but obviously, said method cannot state a return type. To let phpstorm know what return type to expect, a simple override rule has to be define in .phpstorm.meta.php.

// .phpstorm.meta.php
namespace PHPSTORM_META {
    override(\TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(0), type(0));
}

Now, phpstorm knows the type of variable $class.