Download the PHP package saschaegerer/phpstan-typo3 without Composer
On this page you can find all versions of the php package saschaegerer/phpstan-typo3. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download saschaegerer/phpstan-typo3
More information about saschaegerer/phpstan-typo3
Files in saschaegerer/phpstan-typo3
Package phpstan-typo3
Short Description TYPO3 CMS class reflection extension for PHPStan
License MIT
Informations about the package phpstan-typo3
PHPStan TYPO3 extensions and rules
TYPO3 CMS class reflection extension for PHPStan & framework-specific rules.
This extension provides the following features (!!! not an exhaustive list !!!):
Dynamic Return Type Extensions
- Provides correct return type for
\TYPO3\CMS\Core\Context\Context->getAspect(). - Provides correct return type for
\TYPO3\CMS\Core\Context\DateTimeAspect->get(). - Provides correct return type for
\TYPO3\CMS\Core\Context\UserAspect->get(). - Provides correct return type for
\TYPO3\CMS\Extbase\Property\PropertyMapper->convert(). - Provides correct return type for
\TYPO3\CMS\Core\Utility\MathUtilitymethods likeisIntegerInRange. - Provides correct return type for
\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv(). - Provides correct return type for
\TYPO3\CMS\Extbase\Persistence\QueryInterface->execute(). - Provides correct return type for
\TYPO3\CMS\Extbase\Persistence\ObjectStoragemethods. - Provides correct return type for
\TYPO3\CMS\Core\Site\Entity\Site->getAttribute(). - Provides correct return type for
\Psr\Http\Message\ServerRequestInterface->getAttribute(). - Provides correct return type for
\TYPO3\CMS\Extbase\Validation\ValidatorResolver->createValidator(). - Uses under the hood bnf/phpstan-psr-container
All these dynamic return type extensions are necessary to teach PHPStan what type will be returned by the specific method call.
Show me a practical use case.
For example PHPStan cannot know innately what type will be returned if you call `\TYPO3\CMS\Core\Utility\MathUtility->forceIntegerInRange(1000, 1, 10)`. It will be an int<10>. With the help of this library PHPStan also knows what´s going up. Imagine the following situation in your code: PHPStan will tell you that the if condition is superfluous, because the variable $integer will never be higher than 10. Right?Framework specific rules
- Validates
\TYPO3\CMS\Core\Context\Context->getAspect()aspect names. - Validates
\Psr\Http\Message\ServerRequestInterface->getAttribute()attribute names. - Validates
\TYPO3\CMS\Core\Site\Entity\Site->getAttribute()attribute names. - Validates
\TYPO3\CMS\Extbase\Validation\ValidatorResolver->createValidator()required options. - Detects private service access via
\Psr\Container\ContainerInterface->get(). - Detects private service access via
\TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance().
Show me a practical use case.
For example PHPStan cannot know innately that calling `ValidatorResolver->createValidator(RegularExpressionValidator::class)` is invalid, because we miss to pass the required option `regularExpression`. With the help of this library PHPStan now complaints that we have missed to pass the required option. So go ahead and find bugs in your code without running it.Installation & Configuration
To use this extension, require it in Composer:
If you also install phpstan/extension-installer then you're all set!
Manual installation
If you don't want to use `phpstan/extension-installer`, put this into your phpstan.neon config:Custom Context API Aspects
If you use custom aspects for the TYPO3 Context API you can add a mapping so PHPStan knows what type of aspect class is returned by the context API
Custom Request Attribute
If you use custom PSR-7 request attribute you can add a mapping so PHPStan knows what type of class is returned by Request::getAttribute()
Custom Site Attribute
If you use custom attributes for the TYPO3 Site API you can add a mapping so PHPStan knows what type is returned by the site API
Check for private Services
You have to provide a path to App_KernelDevelopmentDebugContainer.xml or similar XML file describing your container. This is generated by ssch/typo3-debug-dump-pass in your /var/cache/{TYPO3_CONTEXT}/ folder.
Development
Running Tests and Quality Checks
The following composer scripts are available for development:
| Command | Description |
|---|---|
composer test |
Run all quality checks (lint, cs, phpstan, phpunit) |
composer test:php-lint |
Run PHP syntax linting using parallel-lint |
composer test:php-cs |
Run code style checks using PHP_CodeSniffer |
composer test:phpstan |
Run static analysis using PHPStan |
composer test:phpunit |
Run PHPUnit tests |
composer fix:php-cs |
Fix code style issues using PHP Code Beautifier |
All versions of phpstan-typo3 with dependencies
ext-simplexml Version *
phpstan/phpstan Version ^2.1.33
typo3/cms-core Version ^14.0
typo3/cms-extbase Version ^14.0
bnf/phpstan-psr-container Version ^1.0
composer/semver Version ^3.4
ssch/typo3-debug-dump-pass Version ^0.0.3