├── .phpstorm.meta.php ├── LICENSE ├── README.md └── composer.json /.phpstorm.meta.php: -------------------------------------------------------------------------------- 1 | \TYPO3\CMS\Core\Context\DateTimeAspect::class, 28 | 'visibility' => \TYPO3\CMS\Core\Context\VisibilityAspect::class, 29 | 'backend.user' => \TYPO3\CMS\Core\Context\UserAspect::class, 30 | 'frontend.user' => \TYPO3\CMS\Core\Context\UserAspect::class, 31 | 'workspace' => \TYPO3\CMS\Core\Context\WorkspaceAspect::class, 32 | 'language' => \TYPO3\CMS\Core\Context\LanguageAspect::class, 33 | 'typoscript' => \TYPO3\CMS\Core\Context\TypoScriptAspect::class, 34 | ])); 35 | 36 | expectedArguments( 37 | \TYPO3\CMS\Core\Context\DateTimeAspect::get(), 38 | 0, 39 | 'timestamp', 40 | 'iso', 41 | 'timezone', 42 | 'full', 43 | 'accessTime' 44 | ); 45 | 46 | expectedArguments( 47 | \TYPO3\CMS\Core\Context\VisibilityAspect::get(), 48 | 0, 49 | 'includeHiddenPages', 50 | 'includeHiddenContent', 51 | 'includeDeletedRecords' 52 | ); 53 | 54 | expectedArguments( 55 | \TYPO3\CMS\Core\Context\UserAspect::get(), 56 | 0, 57 | 'id', 58 | 'username', 59 | 'isLoggedIn', 60 | 'isAdmin', 61 | 'groupIds', 62 | 'groupNames' 63 | ); 64 | 65 | expectedArguments( 66 | \TYPO3\CMS\Core\Context\WorkspaceAspect::get(), 67 | 0, 68 | 'id', 69 | 'isLive', 70 | 'isOffline' 71 | ); 72 | 73 | expectedArguments( 74 | \TYPO3\CMS\Core\Context\LanguageAspect::get(), 75 | 0, 76 | 'id', 77 | 'contentId', 78 | 'fallbackChain', 79 | 'overlayType', 80 | 'legacyLanguageMode', 81 | 'legacyOverlayType' 82 | ); 83 | 84 | expectedArguments( 85 | \TYPO3\CMS\Core\Context\TypoScriptAspect::get(), 86 | 0, 87 | 'forcedTemplateParsing' 88 | ); 89 | } 90 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Alexander Schnitzler 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # .phpstorm.meta.php for TYPO3 2 | 3 | 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. 4 | 5 | ## Example 6 | 7 | ```php 8 | $class = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\Foo::class); 9 | ``` 10 | 11 | In TYPO3, this method is usually used as a replacement for `new` but obviously, said method cannot state a return type. 12 | To let phpstorm know what return type to expect, a simple override rule has to be define in `.phpstorm.meta.php`. 13 | 14 | ```php 15 | // .phpstorm.meta.php 16 | namespace PHPSTORM_META { 17 | override(\TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(0), type(0)); 18 | } 19 | ``` 20 | 21 | Now, phpstorm knows the type of variable `$class`. 22 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "alexanderschnitzler/phpstorm.meta.php-typo3", 3 | "description": "This package contains a .phpstorm.meta.php file which can be used to ease the work with TYPO3 projects in phpstorm.", 4 | "type": "library", 5 | "license": "MIT", 6 | "require": {} 7 | } 8 | --------------------------------------------------------------------------------