Skip to content

Commit 2e49df7

Browse files
committed
Add documentation
1 parent 7737011 commit 2e49df7

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
```

0 commit comments

Comments
 (0)