From 5e4b1596edf75d9acb7cd6d031005f8c38851b6e Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Mon, 28 Jun 2021 16:07:49 +0200 Subject: [PATCH] cleanup NodeRepository (#323) --- build/config/config-downgrade.php | 8 -------- config/set/downgrade-php80.php | 6 +++++- packages/NodeCollector/NodeCollector/NodeRepository.php | 3 +++ .../IssetOnPropertyObjectToPropertyExistsRector.php | 1 - src/Reflection/ReflectionResolver.php | 5 +++-- 5 files changed, 11 insertions(+), 12 deletions(-) diff --git a/build/config/config-downgrade.php b/build/config/config-downgrade.php index f0d9f39902d..9783ff0bddc 100644 --- a/build/config/config-downgrade.php +++ b/build/config/config-downgrade.php @@ -25,14 +25,6 @@ $containerConfigurator->import(DowngradeSetList::PHP_74); $containerConfigurator->import(DowngradeSetList::PHP_73); $containerConfigurator->import(DowngradeSetList::PHP_72); - - $services = $containerConfigurator->services(); - $services->set(DowngradeAttributeToAnnotationRector::class) - ->call('configure', [[ - DowngradeAttributeToAnnotationRector::ATTRIBUTE_TO_ANNOTATION => ValueObjectInliner::inline([ - new DowngradeAttributeToAnnotation('Symfony\Contracts\Service\Attribute\Required', 'required'), - ]), - ]]); }; /** diff --git a/config/set/downgrade-php80.php b/config/set/downgrade-php80.php index b84442da6a0..ed5c2b55a7f 100644 --- a/config/set/downgrade-php80.php +++ b/config/set/downgrade-php80.php @@ -41,7 +41,11 @@ $services->set(DowngradeAttributeToAnnotationRector::class) ->call('configure', [[ DowngradeAttributeToAnnotationRector::ATTRIBUTE_TO_ANNOTATION => ValueObjectInliner::inline([ - new DowngradeAttributeToAnnotation('Attribute'), + new DowngradeAttributeToAnnotation('Attribute', 'annotation'), + // Symfony + new DowngradeAttributeToAnnotation('Symfony\Contracts\Service\Attribute\Required', 'required'), + // Nette + new DowngradeAttributeToAnnotation('Nette\DI\Attributes\Inject', 'inject'), ]), ]]); diff --git a/packages/NodeCollector/NodeCollector/NodeRepository.php b/packages/NodeCollector/NodeCollector/NodeRepository.php index e7b59653ba6..387d02d040c 100644 --- a/packages/NodeCollector/NodeCollector/NodeRepository.php +++ b/packages/NodeCollector/NodeCollector/NodeRepository.php @@ -100,6 +100,9 @@ public function findClass(string $name): ?Class_ return $this->parsedNodeCollector->findClass($name); } + /** + * @param class-string $name + */ public function findTrait(string $name): ?Trait_ { return $this->parsedNodeCollector->findTrait($name); diff --git a/rules/CodeQuality/Rector/Isset_/IssetOnPropertyObjectToPropertyExistsRector.php b/rules/CodeQuality/Rector/Isset_/IssetOnPropertyObjectToPropertyExistsRector.php index d63e4eca571..59706db8332 100644 --- a/rules/CodeQuality/Rector/Isset_/IssetOnPropertyObjectToPropertyExistsRector.php +++ b/rules/CodeQuality/Rector/Isset_/IssetOnPropertyObjectToPropertyExistsRector.php @@ -12,7 +12,6 @@ use PhpParser\Node\Expr\Isset_; use PhpParser\Node\Expr\PropertyFetch; use PhpParser\Node\Scalar\String_; -use PhpParser\Node\Stmt\Property; use PHPStan\Reflection\Php\PhpPropertyReflection; use PHPStan\Reflection\ReflectionProvider; use PHPStan\Type\MixedType; diff --git a/src/Reflection/ReflectionResolver.php b/src/Reflection/ReflectionResolver.php index 9191259f33b..ce7ac1152aa 100644 --- a/src/Reflection/ReflectionResolver.php +++ b/src/Reflection/ReflectionResolver.php @@ -152,8 +152,9 @@ public function resolveMethodReflectionFromNew(New_ $new): ?MethodReflection return $this->resolveMethodReflection($newClassType->getClassName(), MethodName::CONSTRUCT, $scope); } - public function resolvePropertyReflectionFromPropertyFetch(PropertyFetch | StaticPropertyFetch $propertyFetch): ?PhpPropertyReflection - { + public function resolvePropertyReflectionFromPropertyFetch( + PropertyFetch | StaticPropertyFetch $propertyFetch + ): ?PhpPropertyReflection { $fetcheeType = $propertyFetch instanceof PropertyFetch ? $this->nodeTypeResolver->resolve($propertyFetch->var) : $this->nodeTypeResolver->resolve($propertyFetch->class);