File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -59,3 +59,30 @@ parameters:
5959// PHPStan will now know that $myAttribute is of type FlowdGmbh\MyProject\Http\MyAttribute
6060$myAttribute = $request->getAttribute('myAttribute');
6161```
62+
63+ ### Custom Site Attribute
64+
65+ If you use custom attributes for the TYPO3 Site API you can add a mapping so PHPStan knows
66+ what type is returned by the site API
67+
68+ ```
69+ parameters:
70+ typo3:
71+ siteApiGetAttributeMapping:
72+ myArrayAttribute: array
73+ myIntAttribute: int
74+ myStringAttribute: string
75+ ```
76+
77+ ```
78+ $site = $this->request->getAttribute('site');
79+
80+ // PHPStan will now know that $myArrayAttribute is of type array<mixed, mixed>
81+ $myArrayAttribute = $site->getAttribute('myArrayAttribute');
82+
83+ // PHPStan will now know that $myIntAttribute is of type int
84+ $myIntAttribute = $site->getAttribute('myIntAttribute');
85+
86+ // PHPStan will now know that $myStringAttribute is of type string
87+ $myStringAttribute = $site->getAttribute('myStringAttribute');
88+ ```
You can’t perform that action at this time.
0 commit comments