Skip to content

Commit

Permalink
cleanup NodeRepository (#323)
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasVotruba committed Jun 28, 2021
1 parent 0979d51 commit 5e4b159
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 12 deletions.
8 changes: 0 additions & 8 deletions build/config/config-downgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
]),
]]);
};

/**
Expand Down
6 changes: 5 additions & 1 deletion config/set/downgrade-php80.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
]),
]]);

Expand Down
3 changes: 3 additions & 0 deletions packages/NodeCollector/NodeCollector/NodeRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions src/Reflection/ReflectionResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 5e4b159

Please sign in to comment.