Skip to content

Commit 3e0746f

Browse files
authored
Support turning off @internal check (#754)
* Support turning off @internal check fixes #747 * Add README.md changes
1 parent cdafb32 commit 3e0746f

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,19 @@ See the `extension-installer` documentation for more information: https://github
9191

9292
## Adapting to your project
9393

94+
### Customizing rules
95+
96+
#### Disabling checks for extending `@internal` classes
97+
98+
You can disable the `ClassExtendsInternalClassRule` rule by adding the following to your `phpstan.neon`:
99+
100+
```neon
101+
parameters:
102+
drupal:
103+
rules:
104+
classExtendsInternalClassRule: false
105+
```
106+
94107
### Specifying your Drupal project's root
95108

96109
By default, the PHPStan Drupal extension will try to determine your Drupal project's root directory based on the working

extension.neon

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ parameters:
2323
testClassSuffixNameRule: false
2424
dependencySerializationTraitPropertyRule: false
2525
accessResultConditionRule: false
26+
classExtendsInternalClassRule: true
2627
entityMapping:
2728
aggregator_feed:
2829
class: Drupal\aggregator\Entity\Feed
@@ -246,6 +247,7 @@ parametersSchema:
246247
testClassSuffixNameRule: boolean()
247248
dependencySerializationTraitPropertyRule: boolean()
248249
accessResultConditionRule: boolean()
250+
classExtendsInternalClassRule: boolean()
249251
])
250252
entityMapping: arrayOf(anyOf(
251253
structure([

rules.neon

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ rules:
33
- mglaman\PHPStanDrupal\Rules\Drupal\GlobalDrupalDependencyInjectionRule
44
- mglaman\PHPStanDrupal\Rules\Drupal\PluginManager\PluginManagerSetsCacheBackendRule
55
- mglaman\PHPStanDrupal\Rules\Deprecations\AccessDeprecatedConstant
6-
- mglaman\PHPStanDrupal\Rules\Classes\ClassExtendsInternalClassRule
76
- mglaman\PHPStanDrupal\Rules\Classes\PluginManagerInspectionRule
87
- mglaman\PHPStanDrupal\Rules\Deprecations\ConditionManagerCreateInstanceContextConfigurationRule
98
- mglaman\PHPStanDrupal\Rules\Drupal\RenderCallbackRule
@@ -27,6 +26,8 @@ conditionalTags:
2726
phpstan.rules.rule: %drupal.rules.dependencySerializationTraitPropertyRule%
2827
mglaman\PHPStanDrupal\Rules\Drupal\AccessResultConditionRule:
2928
phpstan.rules.rule: %drupal.rules.accessResultConditionRule%
29+
mglaman\PHPStanDrupal\Rules\Classes\ClassExtendsInternalClassRule:
30+
phpstan.rules.rule: %drupal.rules.classExtendsInternalClassRule%
3031

3132
services:
3233
-
@@ -37,3 +38,5 @@ services:
3738
class: mglaman\PHPStanDrupal\Rules\Drupal\AccessResultConditionRule
3839
arguments:
3940
treatPhpDocTypesAsCertain: %treatPhpDocTypesAsCertain%
41+
-
42+
class: mglaman\PHPStanDrupal\Rules\Classes\ClassExtendsInternalClassRule

0 commit comments

Comments
 (0)