Skip to content

Commit fd21dc9

Browse files
authored
Merge pull request #125 from mglaman/gh-112
plugin managers are not required to specify cache tags
2 parents 19d24b4 + eb18a39 commit fd21dc9

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

src/Rules/Drupal/PluginManager/PluginManagerSetsCacheBackendRule.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ public function processNode(Node $node, Scope $scope): array
4949
}
5050

5151
$hasCacheBackendSet = false;
52-
$hasCacheTags = false;
5352
$misnamedCacheTagWarnings = [];
5453

5554
foreach ($node->stmts ?? [] as $statement) {
@@ -72,7 +71,6 @@ public function processNode(Node $node, Scope $scope): array
7271
/** @var \PhpParser\Node\Expr\Array_ $cacheTags */
7372
$cacheTags = $setCacheBackendArgs[2]->value;
7473
if (count($cacheTags->items) > 0) {
75-
$hasCacheTags = true;
7674
/** @var \PhpParser\Node\Expr\ArrayItem $item */
7775
foreach ($cacheTags->items as $item) {
7876
if (($item->value instanceof Node\Scalar\String_) &&
@@ -91,9 +89,6 @@ public function processNode(Node $node, Scope $scope): array
9189
if (!$hasCacheBackendSet) {
9290
$errors[] = 'Missing cache backend declaration for performance.';
9391
}
94-
if (!$hasCacheTags) {
95-
$errors[] = 'Plugin manager has cache backend specified but does not declare cache tags.';
96-
}
9792
foreach ($misnamedCacheTagWarnings as $cacheTagWarning) {
9893
$errors[] = sprintf('%s cache tag might be unclear and does not contain the cache key in it.', $cacheTagWarning);
9994
}

tests/src/DrupalIntegrationTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,13 @@ public function testServiceMapping() {
6565
$errorMessages = [
6666
'\Drupal calls should be avoided in classes, use dependency injection instead',
6767
'Call to an undefined method Drupal\Core\Entity\EntityManager::thisMethodDoesNotExist().',
68+
'Call to deprecated method getDefinitions() of class Drupal\\Core\\Entity\\EntityManager:
69+
in drupal:8.0.0 and is removed from drupal:9.0.0.
70+
Use \\Drupal\\Core\\Entity\\EntityTypeManagerInterface::getDefinitions()
71+
instead.'
6872
];
6973
$errors = $this->runAnalyze(__DIR__ . '/../fixtures/drupal/modules/phpstan_fixtures/src/TestServicesMappingExtension.php');
70-
$this->assertCount(2, $errors->getErrors());
74+
$this->assertCount(3, $errors->getErrors(), var_export($errors->getErrors(), true));
7175
$this->assertCount(0, $errors->getInternalErrors());
7276
foreach ($errors->getErrors() as $key => $error) {
7377
$this->assertEquals($errorMessages[$key], $error->getMessage());

0 commit comments

Comments
 (0)