Skip to content

Commit 1d193cc

Browse files
authored
Merge pull request #92 from mglaman/phpstan-0.12
Bump to PHPStan 0.12
2 parents 3458665 + 49277a3 commit 1d193cc

30 files changed

+417
-337
lines changed

README.md

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -83,18 +83,20 @@ includes:
8383

8484
By default, the PHPStan Drupal extension will try to determine your Drupal project's root directory based on the working
8585
directory that PHPStan is checking. If this is not working properly, you can explicitly define the Drupal project's root
86-
directory using the `drupal_root` parameter.
86+
directory using the `drupal.drupal_root` parameter.
8787

8888
```
89-
drupal:
90-
drupal_root: /path/to/drupal
89+
parameters:
90+
drupal:
91+
drupal_root: /path/to/drupal
9192
```
9293

9394
You can also use container parameters. For instance you can always set it to the current working directory.
9495

9596
```
96-
drupal:
97-
drupal_root: %currentWorkingDirectory%
97+
parameters:
98+
drupal:
99+
drupal_root: %currentWorkingDirectory%
98100
```
99101

100102
### Entity storage mappings.
@@ -104,19 +106,21 @@ passed entity type ID and tries to return a known storage class, besides the def
104106
default mapping can be found in `extension.neon`. For example:
105107

106108
```
107-
drupal:
108-
entityTypeStorageMapping:
109-
node: Drupal\node\NodeStorage
110-
taxonomy_term: Drupal\taxonomy\TermStorage
111-
user: Drupal\user\UserStorage
109+
parameters:
110+
drupal:
111+
entityTypeStorageMapping:
112+
node: Drupal\node\NodeStorage
113+
taxonomy_term: Drupal\taxonomy\TermStorage
114+
user: Drupal\user\UserStorage
112115
```
113116

114117
To add support for custom entities, you may add the same definition in your project's `phpstan.neon`. See the following
115118
example for adding a mapping for Search API:
116119

117120
```
118-
drupal:
119-
entityTypeStorageMapping:
120-
search_api_index: Drupal\search_api\Entity\SearchApiConfigEntityStorage
121-
search_api_server: Drupal\search_api\Entity\SearchApiConfigEntityStorage
121+
parameters:
122+
drupal:
123+
entityTypeStorageMapping:
124+
search_api_index: Drupal\search_api\Entity\SearchApiConfigEntityStorage
125+
search_api_server: Drupal\search_api\Entity\SearchApiConfigEntityStorage
122126
```

composer.json

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,20 @@
1111
],
1212
"require": {
1313
"php": "^7.1",
14-
"phpstan/phpstan": "~0.11.0",
14+
"nette/finder": "^2.5",
15+
"phpstan/phpstan": "^0.12.0",
1516
"symfony/yaml": "~3.4.5|^4.2",
16-
"webflo/drupal-finder": "^1.2",
17-
"nette/di": "^3.0"
17+
"webflo/drupal-finder": "^1.2"
1818
},
1919
"require-dev": {
20-
"phpstan/phpstan-strict-rules": "~0.11.0",
20+
"phpstan/phpstan-strict-rules": "^0.12.0",
2121
"squizlabs/php_codesniffer": "^3.3",
2222
"phpunit/phpunit": "^7.5",
23-
"phpstan/phpstan-deprecation-rules": "~0.11.0",
23+
"phpstan/phpstan-deprecation-rules": "~0.12.0",
2424
"composer/installers": "^1.6",
2525
"drupal/core-recommended": "^8.8@alpha",
2626
"drush/drush": "^9.6"
2727
},
28-
"conflict": {
29-
"phpstan/phpstan": ">=0.12",
30-
"phpstan/phpstan-deprecation-rules": ">=0.12"
31-
},
3228
"minimum-stability": "dev",
3329
"prefer-stable": true,
3430
"suggest": {

drupal-autoloader.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php declare(strict_types=1);
2+
3+
use PHPStan\DependencyInjection\Container;
4+
use PHPStan\Drupal\DrupalAutoloader;
5+
6+
assert($container instanceof Container);
7+
if ($container === NULL && !($container instanceof Container)) {
8+
throw new \PHPStan\ShouldNotHappenException('The autoloader did not receive the container.');
9+
}
10+
11+
if (!defined('DRUPAL_TEST_IN_CHILD_SITE')) {
12+
define('DRUPAL_TEST_IN_CHILD_SITE', false);
13+
}
14+
15+
$drupalAutoloader = new DrupalAutoloader();
16+
$drupalAutoloader->register($container);

extension.neon

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
parameters:
2+
autoload_files:
3+
- drupal-autoloader.php
24
excludes_analyse:
35
- *.api.php
46
- */tests/fixtures/*.php
@@ -9,25 +11,27 @@ parameters:
911
- install
1012
- profile
1113
- engine
12-
extensions:
13-
drupal: PHPStan\DependencyInjection\DrupalExtension
14-
drupal:
15-
entityTypeStorageMapping:
16-
node: Drupal\node\NodeStorage
17-
taxonomy_term: Drupal\taxonomy\TermStorage
18-
user: Drupal\user\UserStorage
14+
drupal:
15+
drupal_root: null
16+
entityTypeStorageMapping:
17+
node: Drupal\node\NodeStorage
18+
taxonomy_term: Drupal\taxonomy\TermStorage
19+
user: Drupal\user\UserStorage
20+
parametersSchema:
21+
drupal: structure([
22+
drupal_root: schema(string(), nullable())
23+
entityTypeStorageMapping: arrayOf(string())
24+
])
1925
rules:
2026
- PHPStan\Rules\Classes\PluginManagerInspectionRule
2127
- PHPStan\Rules\Drupal\Coder\DiscouragedFunctionsRule
2228
- PHPStan\Rules\Drupal\GlobalDrupalDependencyInjectionRule
2329
- PHPStan\Rules\Drupal\PluginManager\PluginManagerSetsCacheBackendRule
2430
- PHPStan\Rules\Deprecations\AccessDeprecatedConstant
2531
services:
26-
drupal.serviceMapFactory:
27-
class: PHPStan\Drupal\ServiceMapFactory
28-
factory: PHPStan\Drupal\ServiceMapFactory(%drupalServiceMap%)
2932
-
30-
factory: @drupal.serviceMapFactory::create()
33+
class: PHPStan\Drupal\ServiceMap
34+
3135
-
3236
class: PHPStan\Type\EntityTypeManagerGetStorageDynamicReturnTypeExtension
3337
arguments:

phpstan-bootstrap.php

Lines changed: 0 additions & 3 deletions
This file was deleted.

phpstan.neon

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@ includes:
22
- vendor/phpstan/phpstan-strict-rules/rules.neon
33
- vendor/phpstan/phpstan-deprecation-rules/rules.neon
44
parameters:
5-
level: 7
5+
level: 8
6+
checkGenericClassInNonGenericObjectType: false
7+
checkMissingIterableValueType: false

src/DependencyInjection/DrupalExtension.php

Lines changed: 0 additions & 191 deletions
This file was deleted.

0 commit comments

Comments
 (0)