From a830ec28777ff26cd88f54056ffdf544296bddba Mon Sep 17 00:00:00 2001 From: TomasVotruba Date: Thu, 1 Apr 2021 10:16:31 +0200 Subject: [PATCH] fixup! remove annotation stubs --- .../PhpDoc/DoctrineAnnotationTagValueNode.php | 4 +- .../DoctrineAnnotation/SilentKeyMap.php | 2 +- .../ValueObject/NodeTypes.php | 2 +- rules/CodingStyle/Node/NameImporter.php | 38 ------------------- ...ertyInjectToConstructorInjectionRector.php | 2 +- 5 files changed, 5 insertions(+), 43 deletions(-) diff --git a/packages/BetterPhpDocParser/PhpDoc/DoctrineAnnotationTagValueNode.php b/packages/BetterPhpDocParser/PhpDoc/DoctrineAnnotationTagValueNode.php index 0f4d679c3588..5f7f1fe50ca7 100644 --- a/packages/BetterPhpDocParser/PhpDoc/DoctrineAnnotationTagValueNode.php +++ b/packages/BetterPhpDocParser/PhpDoc/DoctrineAnnotationTagValueNode.php @@ -129,7 +129,7 @@ public function getValuesWithExplicitSilentAndWithoutQuotes(): array foreach ($this->values as $key => $value) { $valueWithoutQuotes = $this->getValueWithoutQuotes($key); - if (is_int($key)) { + if (is_int($key) && $this->silentKey !== null) { $explicitKeysValues[$this->silentKey] = $valueWithoutQuotes; } else { $explicitKeysValues[$key] = $valueWithoutQuotes; @@ -158,7 +158,7 @@ public function getSilentValue() public function changeSilentValue($value): void { // is quoted? - $isQuoted = (bool) Strings::match($this->items[0], self::CONSTNAT_REGEX); + $isQuoted = (bool) Strings::match($this->items[0], self::UNQUOTED_VALUE_REGEX); if ($isQuoted) { $value = '"' . $value . '"'; } diff --git a/packages/BetterPhpDocParser/ValueObject/DoctrineAnnotation/SilentKeyMap.php b/packages/BetterPhpDocParser/ValueObject/DoctrineAnnotation/SilentKeyMap.php index c6b9730e93c2..7709e8366260 100644 --- a/packages/BetterPhpDocParser/ValueObject/DoctrineAnnotation/SilentKeyMap.php +++ b/packages/BetterPhpDocParser/ValueObject/DoctrineAnnotation/SilentKeyMap.php @@ -7,7 +7,7 @@ final class SilentKeyMap { /** - * @var array + * @var array */ public const CLASS_NAMES_TO_SILENT_KEYS = [ 'Symfony\Component\Routing\Annotation\Route' => 'path', diff --git a/packages/BetterPhpDocParser/ValueObject/NodeTypes.php b/packages/BetterPhpDocParser/ValueObject/NodeTypes.php index 92bde382dd64..4951c81da06b 100644 --- a/packages/BetterPhpDocParser/ValueObject/NodeTypes.php +++ b/packages/BetterPhpDocParser/ValueObject/NodeTypes.php @@ -25,7 +25,7 @@ final class NodeTypes ]; /** - * @var array + * @var string[] */ public const TYPE_AWARE_DOCTRINE_ANNOTATION_CLASSES = [ 'JMS\Serializer\Annotation\Type', diff --git a/rules/CodingStyle/Node/NameImporter.php b/rules/CodingStyle/Node/NameImporter.php index 02b8841d7066..f5d73d1bf327 100644 --- a/rules/CodingStyle/Node/NameImporter.php +++ b/rules/CodingStyle/Node/NameImporter.php @@ -9,7 +9,6 @@ use PhpParser\Node\Expr\ConstFetch; use PhpParser\Node\Expr\FuncCall; use PhpParser\Node\Name; -use PhpParser\Node\Name\FullyQualified; use PhpParser\Node\Stmt\Namespace_; use PhpParser\Node\Stmt\UseUse; use PHPStan\Reflection\ReflectionProvider; @@ -125,10 +124,6 @@ private function shouldSkipName(Name $name): bool return true; } -// if ($this->isNonExistingClassLikeAndFunctionFullyQualifiedName($name)) { -// return true; -// } - // Importing root namespace classes (like \DateTime) is optional $importShortClasses = $this->parameterProvider->provideParameter(Option::IMPORT_SHORT_CLASSES); if (! $importShortClasses) { @@ -213,39 +208,6 @@ private function isFunctionOrConstantImportWithSingleName(Name $name): bool return false; } -// private function isNonExistingClassLikeAndFunctionFullyQualifiedName(Name $name): bool -// { -// if (! $name instanceof FullyQualified) { -// return false; -// } -// -// // can be also in to be renamed classes -// $classOrFunctionName = $name->toString(); -// -// $oldToNewClasses = $this->renamedClassesCollector->getOldToNewClasses(); -// if (in_array($classOrFunctionName, $oldToNewClasses, true)) { -// return false; -// } -// -// $parent = $name->getAttribute(AttributeKey::PARENT_NODE); -// if ($parent instanceof FuncCall) { -// return false; -// } -// -// return false; -// // skip-non existing class-likes and functions -// dump($classOrFunctionName); -// dump($this->reflectionProvider->hasClass($classOrFunctionName)); -// die; -// -// if ($this->reflectionProvider->hasClass($classOrFunctionName)) { -// return false; -// } -// -// $parent = $name->getAttribute(AttributeKey::PARENT_NODE); -// return ! $parent instanceof FuncCall; -// } - private function addUseImport(Name $name, FullyQualifiedObjectType $fullyQualifiedObjectType): void { if ($this->useNodesToAddCollector->hasImport($name, $fullyQualifiedObjectType)) { diff --git a/rules/DependencyInjection/Rector/Property/AnnotatedPropertyInjectToConstructorInjectionRector.php b/rules/DependencyInjection/Rector/Property/AnnotatedPropertyInjectToConstructorInjectionRector.php index 8b75238d6c36..1c313fc94995 100644 --- a/rules/DependencyInjection/Rector/Property/AnnotatedPropertyInjectToConstructorInjectionRector.php +++ b/rules/DependencyInjection/Rector/Property/AnnotatedPropertyInjectToConstructorInjectionRector.php @@ -38,7 +38,7 @@ final class AnnotatedPropertyInjectToConstructorInjectionRector extends AbstractRector { /** - * @var array + * @var string[] */ private const INJECT_ANNOTATION_CLASSES = ['JMS\DiExtraBundle\Annotation\Inject', 'DI\Annotation\Inject'];