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
- enums in `#[Column(enumType: UserStatus::class)]`
61
62
62
63
#### PHPUnit:
63
64
-**data provider methods**
@@ -90,13 +91,16 @@ parameters:
90
91
## Generic usage providers:
91
92
92
93
#### Reflection:
93
-
- Any constant or method accessed via `ReflectionClass` is detected as used
94
-
- e.g. `$reflection->getConstructor()`, `$reflection->getConstant('NAME')`, `$reflection->getMethods()`, ...
94
+
- Any enum, constant or method accessed via `ReflectionClass` is detected as used
95
+
- e.g. `$reflection->getConstructor()`, `$reflection->getConstant('NAME')`, `$reflection->getMethods()`, `$reflection->getCases()`...
95
96
96
97
#### Vendor:
97
98
- Any overridden method that originates in `vendor` is not reported as dead
98
99
- e.g. implementing `Psr\Log\LoggerInterface::log` is automatically considered used
99
100
101
+
#### Enum:
102
+
- Detects usages caused by `BackedEnum::from`, `BackedEnum::tryFrom` and `UnitEnum::cases`
103
+
100
104
Those providers are enabled by default, but you can disable them if needed.
101
105
102
106
## Excluding usages in tests:
@@ -340,6 +344,21 @@ $methods = $reflection->getMethods(); // all Foo methods are used here
340
344
341
345
- All that applies even to constant fetches (e.g. `Foo::{$unknown}`)
342
346
347
+
## Detected class members:
348
+
Default configuration is:
349
+
350
+
```neon
351
+
parameters:
352
+
shipmonkDeadCode:
353
+
detect:
354
+
deadMethods: true
355
+
deadConstants: true
356
+
deadEnumCases: false
357
+
```
358
+
359
+
Enum cases are disabled by default as those are often used in API input objects (using custom deserialization, which typically require custom usage provider).
360
+
361
+
343
362
## Comparison with tomasvotruba/unused-public
344
363
- You can see [detailed comparison PR](https://github.com/shipmonk-rnd/dead-code-detector/pull/53)
345
364
- Basically, their analysis is less precise and less flexible. Mainly:
0 commit comments