@@ -8,7 +8,7 @@ TYPO3 CMS class reflection extension for PHPStan & framework-specific rules
88
99To use this extension, require it in [ Composer] ( https://getcomposer.org/ ) :
1010
11- ```
11+ ``` Shell
1212composer require --dev saschaegerer/phpstan-typo3
1313```
1414
@@ -19,25 +19,26 @@ If you also install [phpstan/extension-installer](https://github.com/phpstan/ext
1919
2020If you don't want to use ` phpstan/extension-installer ` , put this into your phpstan.neon config:
2121
22- ```
22+ ``` NEON
2323includes:
2424 - vendor/saschaegerer/phpstan-typo3/extension.neon
2525```
26+
2627</details >
2728
2829### Custom Context API Aspects
2930
3031If you use custom aspects for the TYPO3 Context API you can add a mapping so PHPStan knows
3132what type of aspect class is returned by the context API
3233
33- ```
34+ ``` NEON
3435parameters:
3536 typo3:
3637 contextApiGetAspectMapping:
3738 myCustomAspect: FlowdGmbh\MyProject\Context\MyCustomAspect
3839```
3940
40- ```
41+ ``` PHP
4142// PHPStan will now know that $myCustomAspect is of type FlowdGmbh\MyProject\Context\MyCustomAspect
4243$myCustomAspect = GeneralUtility::makeInstance(Context::class)->getAspect('myCustomAspect');
4344```
@@ -47,15 +48,15 @@ $myCustomAspect = GeneralUtility::makeInstance(Context::class)->getAspect('myCus
4748If you use custom PSR-7 request attribute you can add a mapping so PHPStan knows
4849what type of class is returned by Request::getAttribute()
4950
50- ```
51+ ``` NEON
5152parameters:
5253 typo3:
5354 requestGetAttributeMapping:
5455 myAttribute: FlowdGmbh\MyProject\Http\MyAttribute
5556 myNullableAttribute: FlowdGmbh\MyProject\Http\MyAttribute|null
5657```
5758
58- ```
59+ ``` PHP
5960// PHPStan will now know that $myAttribute is of type FlowdGmbh\MyProject\Http\MyAttribute
6061$myAttribute = $request->getAttribute('myAttribute');
6162```
@@ -65,7 +66,7 @@ $myAttribute = $request->getAttribute('myAttribute');
6566If you use custom attributes for the TYPO3 Site API you can add a mapping so PHPStan knows
6667what type is returned by the site API
6768
68- ```
69+ ``` NEON
6970parameters:
7071 typo3:
7172 siteGetAttributeMapping:
@@ -74,7 +75,7 @@ parameters:
7475 myStringAttribute: string
7576```
7677
77- ```
78+ ``` PHP
7879$site = $this->request->getAttribute('site');
7980
8081// PHPStan will now know that $myArrayAttribute is of type array<mixed , mixed >
0 commit comments