Skip to content

Commit 9ae027f

Browse files
authored
Remove conflicts against nette/di ^3.0 (#73)
PHPStan has an indirect dependency against nette/di^3.0 due to nette/schema, this fixes our code and requires nette/di:^3.0
1 parent 25fb6e8 commit 9ae027f

File tree

4 files changed

+16
-13
lines changed

4 files changed

+16
-13
lines changed

composer.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
"php": "^7.1",
1313
"phpstan/phpstan": "^0.11",
1414
"symfony/yaml": "~3.4.5|^4.2",
15-
"webflo/drupal-finder": "^1.1"
15+
"webflo/drupal-finder": "^1.1",
16+
"nette/di": "^3.0"
1617
},
1718
"require-dev": {
1819
"phpstan/phpstan-strict-rules": "^0.11",
@@ -23,9 +24,6 @@
2324
"drupal/core": "^8.6",
2425
"drush/drush": "^9.6"
2526
},
26-
"conflict": {
27-
"nette/di": ">=3.0"
28-
},
2927
"minimum-stability": "dev",
3028
"prefer-stable": true,
3129
"suggest": {

phpstan.neon

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
includes:
22
- vendor/phpstan/phpstan-strict-rules/rules.neon
3+
- vendor/phpstan/phpstan-deprecation-rules/rules.neon
34
parameters:
45
level: 7

src/DependencyInjection/DrupalExtension.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class DrupalExtension extends CompilerExtension
5959
public function loadConfiguration(): void
6060
{
6161
/** @var array */
62-
$config = Helpers::merge($this->config, $this->defaultConfig);
62+
$config = Nette\Schema\Helpers::merge($this->config, $this->defaultConfig);
6363

6464
$finder = new DrupalFinder();
6565

@@ -87,12 +87,12 @@ public function loadConfiguration(): void
8787

8888
$builder = $this->getContainerBuilder();
8989
foreach ($builder->getDefinitions() as $definition) {
90-
$factory = $definition->getFactory();
91-
if ($factory === null) {
92-
continue;
93-
}
94-
if ($factory->entity === RequireParentConstructCallRule::class) {
95-
$definition->setFactory(EnhancedRequireParentConstructCallRule::class);
90+
if ($definition instanceof Nette\DI\Definitions\FactoryDefinition) {
91+
$resultDefinition = $definition->getResultDefinition();
92+
$factory = $resultDefinition->getFactory();
93+
if ($factory->entity === RequireParentConstructCallRule::class) {
94+
$resultDefinition->setFactory(EnhancedRequireParentConstructCallRule::class);
95+
}
9696
}
9797
}
9898

tests/src/DeprecationRulesTest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,18 @@ public function dataDeprecatedSamples(): \Generator
2424
2,
2525
[
2626
'\Drupal calls should be avoided in classes, use dependency injection instead',
27-
'Call to deprecated method url() of class Drupal.'
27+
'Call to deprecated method url() of class Drupal:
28+
as of Drupal 8.0.x, will be removed before Drupal 9.0.0.
29+
Instead create a \Drupal\Core\Url object directly, for example using
30+
Url::fromRoute().'
2831
]
2932
];
3033
yield [
3134
__DIR__ . '/../fixtures/drupal/core/lib/Drupal/Core/Entity/EntityManager.php',
3235
1,
3336
[
34-
'Class Drupal\Core\Entity\EntityManager implements deprecated interface Drupal\Core\Entity\EntityManagerInterface.'
37+
'Class Drupal\Core\Entity\EntityManager implements deprecated interface Drupal\Core\Entity\EntityManagerInterface:
38+
in Drupal 8.0.0, will be removed before Drupal 9.0.0.'
3539
]
3640
];
3741
}

0 commit comments

Comments
 (0)