mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-08 20:22:24 +00:00
[Php70] Skip class has __callStatic() on StaticCallOnNonStaticToInstanceCallRector (#555)
This commit is contained in:
parent
057c5e6853
commit
1b113a0c93
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
|
||||
namespace Rector\Tests\Php70\Rector\StaticCall\StaticCallOnNonStaticToInstanceCallRector\Fixture;
|
||||
|
||||
use Rector\Tests\Php70\Rector\StaticCall\StaticCallOnNonStaticToInstanceCallRector\Source\Service;
|
||||
|
||||
class SkipCallStatic
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
return Service::getAlbum();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rector\Tests\Php70\Rector\StaticCall\StaticCallOnNonStaticToInstanceCallRector\Source;
|
||||
|
||||
use stdClass;
|
||||
|
||||
class Service
|
||||
{
|
||||
public static function __callStatic($name, $arguments)
|
||||
{
|
||||
return Other::$name($arguments);
|
||||
}
|
||||
}
|
||||
|
||||
class Other
|
||||
{
|
||||
public static function getAlbum()
|
||||
{
|
||||
return new stdClass;
|
||||
}
|
||||
}
|
|
@ -10,9 +10,11 @@ use PhpParser\Node\Expr\MethodCall;
|
|||
use PhpParser\Node\Expr\New_;
|
||||
use PhpParser\Node\Expr\PropertyFetch;
|
||||
use PhpParser\Node\Expr\StaticCall;
|
||||
use PHPStan\Reflection\MethodReflection;
|
||||
use PHPStan\Reflection\ReflectionProvider;
|
||||
use PHPStan\Type\ObjectType;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\Core\Reflection\ReflectionResolver;
|
||||
use Rector\NodeCollector\ScopeResolver\ParentClassScopeResolver;
|
||||
use Rector\NodeCollector\StaticAnalyzer;
|
||||
use ReflectionMethod;
|
||||
|
@ -29,6 +31,7 @@ final class StaticCallOnNonStaticToInstanceCallRector extends AbstractRector
|
|||
public function __construct(
|
||||
private StaticAnalyzer $staticAnalyzer,
|
||||
private ReflectionProvider $reflectionProvider,
|
||||
private ReflectionResolver $reflectionResolver,
|
||||
private ParentClassScopeResolver $parentClassScopeResolver
|
||||
) {
|
||||
}
|
||||
|
@ -149,6 +152,11 @@ CODE_SAMPLE
|
|||
return false;
|
||||
}
|
||||
|
||||
$methodReflection = $this->reflectionResolver->resolveMethodReflection($className, '__callStatic', null);
|
||||
if ($methodReflection instanceof MethodReflection) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$classReflection = $this->reflectionProvider->getClass($className);
|
||||
$reflectionClass = $classReflection->getNativeReflection();
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user