diff --git a/src/Drupal/ExtensionMap.php b/src/Drupal/ExtensionMap.php index 819c23b0..ff788b06 100644 --- a/src/Drupal/ExtensionMap.php +++ b/src/Drupal/ExtensionMap.php @@ -4,7 +4,6 @@ use function array_combine; use function array_map; -use function is_array; final class ExtensionMap { @@ -74,14 +73,8 @@ public function setExtensions(array $modules, array $themes, array $profiles): v */ private static function keyByExtensionName(array $extensions): array { - // PHP 7.4 returns array|false, PHP 8.0 only returns an array. - // Make PHPStan happy. When PHP 7.4 is dropped, reduce to a single - // return. - $combined = array_combine(array_map(static function (Extension $extension) { + return array_combine(array_map(static function (Extension $extension) { return $extension->getName(); }, $extensions), $extensions); - // @phpstan-ignore-next-line - assert(is_array($combined)); - return $combined; } } diff --git a/src/Rules/Deprecations/SymfonyCmfRouteObjectInterfaceConstantsRule.php b/src/Rules/Deprecations/SymfonyCmfRouteObjectInterfaceConstantsRule.php index 20a28bb4..9acfe0c5 100644 --- a/src/Rules/Deprecations/SymfonyCmfRouteObjectInterfaceConstantsRule.php +++ b/src/Rules/Deprecations/SymfonyCmfRouteObjectInterfaceConstantsRule.php @@ -49,6 +49,9 @@ public function processNode(Node $node, Scope $scope): array return []; } + // The next line is intentionally not using [at]phpstan-ignore [identifier]. + // The identifier would be 'class.notFound', which would not be true in + // case of a D9 scan and thus would fail the 'phpstan analyze' phase. // @phpstan-ignore-next-line $cmfRouteObjectInterfaceType = new ObjectType(SymfonyRouteObjectInterface::class); if (!$classType->isSuperTypeOf($cmfRouteObjectInterfaceType)->yes()) { diff --git a/src/Rules/Deprecations/SymfonyCmfRoutingInClassMethodSignatureRule.php b/src/Rules/Deprecations/SymfonyCmfRoutingInClassMethodSignatureRule.php index 16981c53..da750ba4 100644 --- a/src/Rules/Deprecations/SymfonyCmfRoutingInClassMethodSignatureRule.php +++ b/src/Rules/Deprecations/SymfonyCmfRoutingInClassMethodSignatureRule.php @@ -39,6 +39,9 @@ public function processNode(Node $node, Scope $scope): array } $method = $node->getMethodReflection(); + // The next lines are intentionally not using [at]phpstan-ignore [identifier]. + // The identifier would be 'class.notFound', which would not be true in + // case of a D9 scan and thus would fail the 'phpstan analyze' phase. // @phpstan-ignore-next-line $cmfRouteObjectInterfaceType = new ObjectType(RouteObjectInterface::class); // @phpstan-ignore-next-line diff --git a/src/Rules/Drupal/Tests/BrowserTestBaseDefaultThemeRule.php b/src/Rules/Drupal/Tests/BrowserTestBaseDefaultThemeRule.php index 08c8dd50..ca64cede 100644 --- a/src/Rules/Drupal/Tests/BrowserTestBaseDefaultThemeRule.php +++ b/src/Rules/Drupal/Tests/BrowserTestBaseDefaultThemeRule.php @@ -12,7 +12,6 @@ use function count; use function in_array; use function interface_exists; -use function method_exists; use function substr_compare; /** @@ -46,8 +45,7 @@ public function processNode(Node $node, Scope $scope): array // Do some cheap preflight tests to make sure the class is in a // namespace that makes sense to inspect. - // @phpstan-ignore-next-line - $parts = method_exists($node->namespacedName, 'getParts') ? $node->namespacedName->getParts() : $node->namespacedName->parts; + $parts = $node->namespacedName->getParts(); // The namespace is too short to be a test so skip inspection. if (count($parts) < 3) { return []; diff --git a/src/Type/EntityQuery/EntityQueryType.php b/src/Type/EntityQuery/EntityQueryType.php index f8952bd4..f8ab5b45 100644 --- a/src/Type/EntityQuery/EntityQueryType.php +++ b/src/Type/EntityQuery/EntityQueryType.php @@ -27,7 +27,7 @@ public function withAccessCheck(): self { // The constructor of ObjectType is under backward compatibility promise. // @see https://phpstan.org/developing-extensions/backward-compatibility-promise - // @phpstan-ignore-next-line + // @phpstan-ignore new.static $type = new static( $this->getClassName(), $this->getSubtractedType(), @@ -40,7 +40,7 @@ public function withAccessCheck(): self public function asCount(): self { - // @phpstan-ignore-next-line + // @phpstan-ignore new.static $type = new static( $this->getClassName(), $this->getSubtractedType(), diff --git a/tests/src/DrushIntegrationTest.php b/tests/src/DrushIntegrationTest.php index 2c4c288d..c49f6970 100644 --- a/tests/src/DrushIntegrationTest.php +++ b/tests/src/DrushIntegrationTest.php @@ -9,7 +9,7 @@ final class DrushIntegrationTest extends DrupalRuleTestCase protected function getRule(): \PHPStan\Rules\Rule { - // @phpstan-ignore-next-line + // @phpstan-ignore phpstanApi.constructor return new CallToNonExistentFunctionRule( $this->createReflectionProvider(), true diff --git a/tests/src/Reflection/EntityFieldMethodsViaMagicReflectionExtensionTest.php b/tests/src/Reflection/EntityFieldMethodsViaMagicReflectionExtensionTest.php index 431c8c74..d4d88251 100644 --- a/tests/src/Reflection/EntityFieldMethodsViaMagicReflectionExtensionTest.php +++ b/tests/src/Reflection/EntityFieldMethodsViaMagicReflectionExtensionTest.php @@ -47,7 +47,7 @@ public static function dataHasMethod(): \Generator // A content entity for sure does not have this method. yield 'Content entity: referencedEntities' => [ - // @phpstan-ignore-next-line + // @phpstan-ignore class.notFound EntityTest::class, 'referencedEntities', false, diff --git a/tests/src/Reflection/EntityFieldsViaMagicReflectionExtensionTest.php b/tests/src/Reflection/EntityFieldsViaMagicReflectionExtensionTest.php index df5093a8..ed8790d5 100644 --- a/tests/src/Reflection/EntityFieldsViaMagicReflectionExtensionTest.php +++ b/tests/src/Reflection/EntityFieldsViaMagicReflectionExtensionTest.php @@ -43,19 +43,19 @@ public function testHasProperty(string $class, string $property, bool $result): public static function dataHasProperty(): \Generator { yield 'content entity supported' => [ - // @phpstan-ignore-next-line + // @phpstan-ignore class.notFound EntityTest::class, 'foobar', true ]; yield 'config entity not supported' => [ - // @phpstan-ignore-next-line + // @phpstan-ignore class.notFound TestConfigType::class, 'foobar', false ]; yield 'annotated properties are skipped on content entities' => [ - // @phpstan-ignore-next-line + // @phpstan-ignore class.notFound ReflectionEntityTest::class, 'user_id', false @@ -92,7 +92,7 @@ public static function dataHasProperty(): \Generator public function testGetPropertyEntity(): void { - // @phpstan-ignore-next-line + // @phpstan-ignore class.notFound $classReflection = $this->createReflectionProvider()->getClass(EntityTest::class); $propertyReflection = $this->extension->getProperty($classReflection, 'field_myfield'); $readableType = $propertyReflection->getReadableType(); diff --git a/tests/src/Rules/AccessCheckImpossibleTypeCallRuleTest.php b/tests/src/Rules/AccessCheckImpossibleTypeCallRuleTest.php index fe86290e..66040c5f 100644 --- a/tests/src/Rules/AccessCheckImpossibleTypeCallRuleTest.php +++ b/tests/src/Rules/AccessCheckImpossibleTypeCallRuleTest.php @@ -14,20 +14,18 @@ final class AccessCheckImpossibleTypeCallRuleTest extends DrupalRuleTestCase protected function getRule(): Rule { - // @phpstan-ignore-next-line + // @phpstan-ignore phpstanApi.constructor return new ImpossibleCheckTypeMethodCallRule( - // @phpstan-ignore-next-line + // @phpstan-ignore phpstanApi.constructor new ImpossibleCheckTypeHelper( $this->createReflectionProvider(), $this->getTypeSpecifier(), [], false, - true, ), true, false, false, - false, ); }