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
+28-1Lines changed: 28 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,6 +24,7 @@ include:
24
24
```
25
25
26
26
## Rules
27
+
---
27
28
### `UnusedClassRule`
28
29
This rule scans for class declarations and use statements. If a class is declared but not used within the scanned source files, an error is generated.
29
30
@@ -48,6 +49,32 @@ parameters:
48
49
- 'src/MyUnusedClass.php'
49
50
```
50
51
52
+
### Excluding Services
53
+
By default, some known service and framework classes are excluded. There are a number of base classes from Symfony, Doctrine and PHPUnit that checked and, if matched, the class being analysed is ignored.
54
+
55
+
To disable this, set the *excludeFrameworks* property to false:
56
+
```yaml
57
+
# phpstan.neon
58
+
parameters:
59
+
unused_classes:
60
+
excludeFrameworks: false
61
+
```
62
+
63
+
This list will change as new frameworks and classes are added. Please look at the source code in src/Frameworks for a list of base classes that are excluded.
64
+
65
+
If you want add a custom list of base classes to ignore, use the *baseClassExcludes* property:
66
+
```yaml
67
+
# phpstan.neon
68
+
parameters:
69
+
unused_classes:
70
+
baseClassExcludes:
71
+
- 'App\Service\MyAbstractService'
72
+
- 'App\DI\MyDIClass'
73
+
```
74
+
75
+
Entries in *baseClassExcludes* are excluded regardless of the *excludeFrameworks* property value.
76
+
77
+
---
51
78
### `UnusedTraitRule`
52
79
This rule scans for trait declarations and use statements. If a trait is declared but not used within the scanned source files, an error is generated.
53
80
@@ -61,4 +88,4 @@ parameters:
61
88
```
62
89
63
90
#### Excluding files
64
-
You can exclude directories and individual files from being scanned by this rule using the excludePaths parameter as shown above/
91
+
You can exclude directories and individual files from being scanned by this rule using the excludePaths parameter as shown above.
0 commit comments