Skip to content

Commit

Permalink
bump deps (#301)
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasVotruba committed Jun 26, 2021
1 parent 04981ba commit 6a3f274
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 29 deletions.
16 changes: 8 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@
"idiosyncratic/editorconfig": "^0.1.3",
"nette/utils": "^3.2",
"nikic/php-parser": "4.10.5",
"phpstan/phpdoc-parser": "^0.5.4",
"phpstan/phpdoc-parser": "^0.5.5",
"phpstan/phpstan": ">=0.12.86 <=0.12.90",
"phpstan/phpstan-phpunit": "^0.12.19",
"phpstan/phpstan-phpunit": "^0.12.20",
"rector/extension-installer": "^0.10.2",
"rector/rector-cakephp": "^0.11.2",
"rector/rector-doctrine": "^0.11.5",
"rector/rector-laravel": "^0.11.1",
"rector/rector-nette": "^0.11.5",
"rector/rector-phpunit": "^0.11.1",
"rector/rector-symfony": "^0.11.6",
"rector/rector-cakephp": "^0.11.3",
"rector/rector-doctrine": "^0.11.6",
"rector/rector-laravel": "^0.11.2",
"rector/rector-nette": "^0.11.9",
"rector/rector-phpunit": "^0.11.3",
"rector/rector-symfony": "^0.11.7",
"sebastian/diff": "^4.0.4",
"ssch/typo3-rector": "^0.11.14",
"symfony/console": "^5.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace Rector\Tests\DowngradePhp80\Rector\MethodCall\DowngradeNamedArgumentRe

use Rector\Tests\DowngradePhp80\Rector\MethodCall\DowngradeNamedArgumentRector\Source\Foo;

class StaticCall extends Foo
final class SomeStaticCall extends Foo
{
public function __construct(string $name = null, array $attributes = [])
{
Expand All @@ -20,7 +20,7 @@ namespace Rector\Tests\DowngradePhp80\Rector\MethodCall\DowngradeNamedArgumentRe

use Rector\Tests\DowngradePhp80\Rector\MethodCall\DowngradeNamedArgumentRector\Source\Foo;

class StaticCall extends Foo
final class SomeStaticCall extends Foo
{
public function __construct(string $name = null, array $attributes = [])
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ final class CurrentAndParentClassMethodComparator
{
public function __construct(
private NodeNameResolver $nodeNameResolver,
private MethodParameterTypeResolver $methodReflectionProvider,
private MethodParameterTypeResolver $methodParameterTypeResolver,
private ParameterDefaultsComparator $parameterDefaultsComparator,
private ParameterTypeComparator $parameterTypeComparator,
private NodeComparator $nodeComparator
Expand Down Expand Up @@ -161,7 +161,7 @@ private function areParameterDefaultsDifferent(
ClassMethod $classMethod,
MethodReflection $methodReflection
): bool {
$parameterReflections = $this->methodReflectionProvider->getParameterReflectionsFromMethodReflection(
$parameterReflections = $this->methodParameterTypeResolver->getParameterReflectionsFromMethodReflection(
$methodReflection
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@
final class ParameterTypeComparator
{
public function __construct(
private MethodParameterTypeResolver $methodReflectionProvider
private MethodParameterTypeResolver $methodParameterTypeResolver
) {
}

public function compareCurrentClassMethodAndParentStaticCall(
ClassMethod $classMethod,
StaticCall $staticCall
): bool {
$currentParameterTypes = $this->methodReflectionProvider->provideParameterTypesByClassMethod($classMethod);
$parentParameterTypes = $this->methodReflectionProvider->provideParameterTypesByStaticCall($staticCall);
$currentParameterTypes = $this->methodParameterTypeResolver->provideParameterTypesByClassMethod($classMethod);
$parentParameterTypes = $this->methodParameterTypeResolver->provideParameterTypesByStaticCall($staticCall);

foreach ($currentParameterTypes as $key => $currentParameterType) {
if (! isset($parentParameterTypes[$key])) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
use Rector\Core\Rector\AbstractRector;
use Rector\Core\Reflection\ReflectionResolver;
use Rector\NodeCollector\StaticAnalyzer;
use Rector\NodeTypeResolver\MethodParameterTypeResolver;
use Rector\NodeTypeResolver\Node\AttributeKey;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
Expand All @@ -26,7 +25,6 @@ final class ThisCallOnStaticMethodToStaticCallRector extends AbstractRector
{
public function __construct(
private StaticAnalyzer $staticAnalyzer,
private MethodParameterTypeResolver $methodReflectionProvider,
private ReflectionResolver $reflectionResolver
) {
}
Expand Down
3 changes: 2 additions & 1 deletion rules/PhpSpecToPHPUnit/PHPUnitTypeDeclarationDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Rector\Core\Reflection\ReflectionResolver;
use Rector\Core\ValueObject\MethodName;
use Rector\Testing\PHPUnit\StaticPHPUnitEnvironment;
use ReflectionMethod;
use ReflectionNamedType;

/**
Expand All @@ -33,7 +34,7 @@ public function decorate(ClassMethod $classMethod): void
MethodName::SET_UP
);

if ($reflectionMethod === null) {
if (! $reflectionMethod instanceof ReflectionMethod) {
return;
}

Expand Down
25 changes: 14 additions & 11 deletions src/PhpParser/AstResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use PhpParser\Node;
use PhpParser\Node\Expr\MethodCall;
use PhpParser\Node\Expr\StaticCall;
use PhpParser\Node\Stmt\Class_;
use PhpParser\Node\Stmt\ClassMethod;
use PhpParser\Node\Stmt\Function_;
Expand Down Expand Up @@ -131,25 +132,27 @@ public function resolveClassMethod(string $className, string $methodName): ?Clas

public function resolveClassMethodFromMethodCall(MethodCall $methodCall): ?ClassMethod
{
$callerStaticType = $this->nodeTypeResolver->getStaticType($methodCall->var);
if (! $callerStaticType instanceof TypeWithClassName) {
return null;
return $this->resolveClassMethodFromCall($methodCall);
}

public function resolveClassMethodFromCall(MethodCall | StaticCall $call): ?ClassMethod
{
if ($call instanceof MethodCall) {
$callerStaticType = $this->nodeTypeResolver->resolve($call->var);
} else {
$callerStaticType = $this->nodeTypeResolver->resolve($call->class);
}

$methodName = $this->nodeNameResolver->getName($methodCall->name);
if ($methodName === null) {
if (! $callerStaticType instanceof TypeWithClassName) {
return null;
}

$methodReflection = $this->reflectionResolver->resolveMethodReflection(
$callerStaticType->getClassName(),
$methodName
);
if ($methodReflection === null) {
$methodName = $this->nodeNameResolver->getName($call->name);
if ($methodName === null) {
return null;
}

return $this->resolveClassMethodFromMethodReflection($methodReflection);
return $this->resolveClassMethod($callerStaticType->getClassName(), $methodName);
}

private function resolveClassFromClassReflection(ClassReflection $classReflection, string $className): ?Class_
Expand Down

0 comments on commit 6a3f274

Please sign in to comment.