You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: README.md
+64
Original file line number
Diff line number
Diff line change
@@ -24,6 +24,12 @@ It also contains these framework-specific rules (can be enabled separately):
24
24
* Do not extend Nette\Object, use Nette\SmartObject trait instead
25
25
* Rethrow exceptions that are always meant to be rethrown (like `AbortException`)
26
26
27
+
Links checking (can be enabled separately by - see configuration):
28
+
* Validate parameters passed to 'link()', 'lazyLink()', 'redirect()', 'redirectPermanent()', 'forward()', 'isLinkCurrent()' and 'canonicalize()' methods
29
+
* Works for presenters, components and 'LinkGenerator' service
30
+
* Checks if passed destination is valid and points to existing presenter, action or signal
31
+
* Checks if passed link parameters are valid and match relevant 'action*()', 'render*()' or 'handle*()' method signature
32
+
* Checks also links to sub-components of known types (createComponent*() method must exists)
27
33
28
34
## Installation
29
35
@@ -52,3 +58,61 @@ To perform framework-specific checks, include also this file:
52
58
```
53
59
54
60
</details>
61
+
62
+
## Configuration
63
+
64
+
### containerLoader
65
+
66
+
Container loader can be used to create instance of Nette application DI container.
67
+
68
+
Example:
69
+
```neon
70
+
parameters:
71
+
nette:
72
+
containerLoader: './containerLoader.php'
73
+
```
74
+
75
+
Example `containerLoader.php`:
76
+
77
+
```php
78
+
<?php
79
+
80
+
return App\Bootstrap::boot()->createContainer();
81
+
```
82
+
83
+
### applicationMapping
84
+
85
+
Application mapping is used to map presenter identfiers to classes in link checking.
86
+
87
+
Example:
88
+
```neon
89
+
parameters:
90
+
nette:
91
+
applicationMapping:
92
+
*: App\Presenters\*\*Presenter
93
+
```
94
+
95
+
### checkLinks
96
+
97
+
Link checking can be disabled/enabled by setting `checkLinks` parameter. It is enabled by default if `bleedingEndge` is enabled.
98
+
99
+
Either `applicationMapping` or `containerLoader` (for automatically loading mappings from `PresenterFactory` service in your app) must be set for link checking to work.
100
+
101
+
Example:
102
+
```neon
103
+
parameters:
104
+
nette:
105
+
checkLinks: true
106
+
```
107
+
108
+
If you use non-standard `PresenterFactory` this feature might not work because logic for mapping presenter name (e.g. `MyModule:Homepage`) to presenter class (e.g. `\App\Presenters\MyModule\HomepagePresenter`) and vice versa would work differently.
109
+
110
+
If you use `containerLoader` you might solve this by implementing method `unformatPresenterClass` in your custom `PresenterFactory` class. This method should return presenter name for given presenter class.
111
+
112
+
Or you can create custom implementation overriding `PHPStan\Nette\PresenterResolver` service and replace it in your PHPStan config:
0 commit comments