Skip to content

Commit 3e9eae8

Browse files
authored
Merge pull request #389 from mglaman/gh295
Move rules to `rules.neon`
2 parents 3d19fe8 + 9ce71f3 commit 3e9eae8

File tree

5 files changed

+29
-32
lines changed

5 files changed

+29
-32
lines changed

README.md

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,28 +14,23 @@ Extension for [PHPStan](https://phpstan.org/) to allow analysis of Drupal code.
1414

1515
When you are using [`phpstan/extension-installer`](https://github.com/phpstan/extension-installer), `phpstan.neon` will be automatically included.
1616

17-
Otherwise add `phpstan.neon` to your Drupal project.
17+
<details>
18+
<summary>Manual installation</summary>
1819

19-
Make sure it has
20+
If you don't want to use `phpstan/extension-installer`, include `extension.neon` in your project's PHPStan config:
2021

21-
```neon
22+
```
2223
includes:
23-
- vendor/mglaman/phpstan-drupal/extension.neon
24+
- vendor/mglaman/phpstan-drupal/extension.neon
2425
```
2526

26-
## Enabling rules one-by-one
27-
28-
If you don't want to start using all the available strict rules at once but only one or two, you can! Just don't include
29-
the whole `rules.neon` from this package in your configuration, but look at its contents and copy only the rules you
30-
want to your configuration under the `services` key:
27+
To include Drupal specific analysis rules, include this file:
3128

3229
```
33-
services:
34-
-
35-
class: PHPStan\Rules\Drupal\PluginManager\PluginManagerSetsCacheBackendRule
36-
tags:
37-
- phpstan.rules.rule
30+
includes:
31+
- vendor/mglaman/phpstan-drupal/rules.neon
3832
```
33+
</details>
3934

4035
## Excluding tests from analysis
4136

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@
6464
},
6565
"phpstan": {
6666
"includes": [
67-
"extension.neon"
67+
"extension.neon",
68+
"rules.neon"
6869
]
6970
}
7071
},

extension.neon

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -243,23 +243,6 @@ parametersSchema:
243243
])
244244
))
245245
])
246-
rules:
247-
- mglaman\PHPStanDrupal\Rules\Drupal\Coder\DiscouragedFunctionsRule
248-
- mglaman\PHPStanDrupal\Rules\Drupal\GlobalDrupalDependencyInjectionRule
249-
- mglaman\PHPStanDrupal\Rules\Drupal\PluginManager\PluginManagerSetsCacheBackendRule
250-
- mglaman\PHPStanDrupal\Rules\Deprecations\AccessDeprecatedConstant
251-
- mglaman\PHPStanDrupal\Rules\Classes\ClassExtendsInternalClassRule
252-
- mglaman\PHPStanDrupal\Rules\Classes\PluginManagerInspectionRule
253-
- mglaman\PHPStanDrupal\Rules\Deprecations\ConditionManagerCreateInstanceContextConfigurationRule
254-
- mglaman\PHPStanDrupal\Rules\Drupal\RenderCallbackRule
255-
- mglaman\PHPStanDrupal\Rules\Deprecations\StaticServiceDeprecatedServiceRule
256-
- mglaman\PHPStanDrupal\Rules\Deprecations\GetDeprecatedServiceRule
257-
- mglaman\PHPStanDrupal\Rules\Drupal\Tests\BrowserTestBaseDefaultThemeRule
258-
- mglaman\PHPStanDrupal\Rules\Deprecations\ConfigEntityConfigExportRule
259-
- mglaman\PHPStanDrupal\Rules\Deprecations\PluginAnnotationContextDefinitionsRule
260-
- mglaman\PHPStanDrupal\Rules\Drupal\ModuleLoadInclude
261-
- mglaman\PHPStanDrupal\Rules\Drupal\LoadIncludes
262-
- mglaman\PHPStanDrupal\Rules\Drupal\EntityQuery\EntityQueryHasAccessCheckRule
263246
services:
264247
-
265248
class: mglaman\PHPStanDrupal\Drupal\ServiceMap

rules.neon

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
rules:
2+
- mglaman\PHPStanDrupal\Rules\Drupal\Coder\DiscouragedFunctionsRule
3+
- mglaman\PHPStanDrupal\Rules\Drupal\GlobalDrupalDependencyInjectionRule
4+
- mglaman\PHPStanDrupal\Rules\Drupal\PluginManager\PluginManagerSetsCacheBackendRule
5+
- mglaman\PHPStanDrupal\Rules\Deprecations\AccessDeprecatedConstant
6+
- mglaman\PHPStanDrupal\Rules\Classes\ClassExtendsInternalClassRule
7+
- mglaman\PHPStanDrupal\Rules\Classes\PluginManagerInspectionRule
8+
- mglaman\PHPStanDrupal\Rules\Deprecations\ConditionManagerCreateInstanceContextConfigurationRule
9+
- mglaman\PHPStanDrupal\Rules\Drupal\RenderCallbackRule
10+
- mglaman\PHPStanDrupal\Rules\Deprecations\StaticServiceDeprecatedServiceRule
11+
- mglaman\PHPStanDrupal\Rules\Deprecations\GetDeprecatedServiceRule
12+
- mglaman\PHPStanDrupal\Rules\Drupal\Tests\BrowserTestBaseDefaultThemeRule
13+
- mglaman\PHPStanDrupal\Rules\Deprecations\ConfigEntityConfigExportRule
14+
- mglaman\PHPStanDrupal\Rules\Deprecations\PluginAnnotationContextDefinitionsRule
15+
- mglaman\PHPStanDrupal\Rules\Drupal\ModuleLoadInclude
16+
- mglaman\PHPStanDrupal\Rules\Drupal\LoadIncludes
17+
- mglaman\PHPStanDrupal\Rules\Drupal\EntityQuery\EntityQueryHasAccessCheckRule

tests/fixtures/config/phpunit-drupal-phpstan.neon

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@ parameters:
1515
class: Drupal\phpstan_fixtures\Entity\ContentEntityUsingDefaultStorage
1616
includes:
1717
- ../../../extension.neon
18+
- ../../../rules.neon
1819
- ../../../vendor/phpstan/phpstan-deprecation-rules/rules.neon

0 commit comments

Comments
 (0)