Skip to content

Commit 6a2882c

Browse files
committed
Add suggestion of phpstan/phpstan-deprecation-rules to README
Fixes #11
1 parent b17b213 commit 6a2882c

File tree

1 file changed

+36
-3
lines changed

1 file changed

+36
-3
lines changed

README.md

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ includes:
1717

1818
## Enabling rules one-by-one
1919

20-
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
21-
the whole `rules.neon` from this package in your configuration, but look at its contents and copy only the rules you
20+
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
21+
the whole `rules.neon` from this package in your configuration, but look at its contents and copy only the rules you
2222
want to your configuration under the `services` key:
2323

2424
```
@@ -40,11 +40,44 @@ parameters:
4040
- *TestBase.php
4141
```
4242

43+
## Deprecation testing
44+
45+
Add the deprecation rules to your Drupal project's dependencies
46+
47+
```
48+
composer require phpstan/phpstan-deprecation-rules
49+
```
50+
51+
Edit your `phpstan.neon` to look like the following:
52+
53+
```
54+
includes:
55+
- vendor/mglaman/phpstan-drupal/extension.neon
56+
- vendor/phpstan/phpstan-deprecation-rules/rules.neon
57+
```
58+
59+
To only handle deprecation testing, use a `phpstan.neon` like this:
60+
61+
```
62+
parameters:
63+
customRulesetUsed: true
64+
reportUnmatchedIgnoredErrors: false
65+
# Ignore phpstan-drupal extension's rules.
66+
ignoreErrors:
67+
- '#\Drupal calls should be avoided in classes, use dependency injection instead#'
68+
- '#Plugin definitions cannot be altered.#'
69+
- '#Missing cache backend declaration for performance.#'
70+
- '#Plugin manager has cache backend specified but does not declare cache tags.#'
71+
includes:
72+
- vendor/mglaman/phpstan-drupal/extension.neon
73+
- vendor/phpstan/phpstan-deprecation-rules/rules.neon
74+
```
75+
4376
## Adapting to your project
4477

4578
### Entity storage mappings.
4679

47-
The `EntityTypeManagerGetStorageDynamicReturnTypeExtension` service helps map dynamic return types. This inspects the
80+
The `EntityTypeManagerGetStorageDynamicReturnTypeExtension` service helps map dynamic return types. This inspects the
4881
passed entity type ID and tries to return a known storage class, besides the default `EntityStorageInterface`. The
4982
default mapping can be found in `extension.neon`. For example:
5083

0 commit comments

Comments
 (0)