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
- In order to prevent false positives, we support even calls over unknown types (e.g. `$unknown->method()`) by marking all methods named `method` as used
@@ -176,13 +169,36 @@ Found 2 methods called over unknown type:
176
169
- It has almost no built-it library extensions
177
170
- It ignores trait methods
178
171
- Is lacks many minor features like class-string calls, dynamic method calls, array callbacks, nullsafe call chains etc
172
+
- It cannot detect dead cycles nor transitively dead methods
173
+
- It has no built-in dead code removal
179
174
180
175
## Limitations:
176
+
- Methods of anonymous classes are never reported as dead ([PHPStan limitation](https://github.com/phpstan/phpstan/issues/8410))
177
+
- Abstract trait methods are never reported as dead
178
+
- Most magic methods (e.g. `__get`, `__set` etc) are never reported as dead
179
+
- Only supported are: `__construct`, `__clone`
180
+
181
+
### Other problematic cases:
182
+
183
+
#### Constructors:
184
+
- For symfony apps & PHPStan extensions, we simplify the detection by assuming all DIC classes have used constructor.
185
+
- For other apps, you may get false-positives if services are created magically.
186
+
- To avoid those, you can easily disable consructor analysis with single ignore:
187
+
188
+
```neon
189
+
parameters:
190
+
ignoreErrors:
191
+
- '#^Unused .*?::__construct$#'
192
+
```
193
+
194
+
#### Private constructors:
195
+
- Those are never reported as dead as those are often used to deny class instantiation
181
196
182
-
- Only dead method calls are detected so far
183
-
- Including **constructors**, static methods, trait methods, interface methods, first class callables, clone, etc.
184
-
- Methods of anonymous classes are never reported as dead ([PHPStan limitation](https://github.com/phpstan/phpstan/issues/8410))
185
-
- Most magic methods (e.g. `__get`, `__set` etc) are never reported as dead
0 commit comments