mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-03 01:40:49 +00:00
[DowngradePhp80] Skip remove self on DowngradeStaticTypeDeclarationRector (#721)
Co-authored-by: Brandon Olivares <programmer2188@gmail.com>
This commit is contained in:
parent
998029d4fc
commit
3c8f8a03d6
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rector\Tests\DowngradePhp80\Rector\ClassMethod\DowngradeStaticTypeDeclarationRector\Fixture;
|
||||
|
||||
final class SkipSelf
|
||||
{
|
||||
public function run(): self
|
||||
{
|
||||
return $this;
|
||||
}
|
||||
}
|
|
@ -5,6 +5,7 @@ declare(strict_types=1);
|
|||
namespace Rector\DowngradePhp80\Rector\ClassMethod;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Name;
|
||||
use PhpParser\Node\Stmt\ClassMethod;
|
||||
use PHPStan\Reflection\ClassReflection;
|
||||
use PHPStan\Reflection\ReflectionProvider;
|
||||
|
@ -72,6 +73,13 @@ CODE_SAMPLE
|
|||
*/
|
||||
public function refactor(Node $node): ?Node
|
||||
{
|
||||
if ($node->returnType instanceof Name && $this->nodeNameResolver->isName(
|
||||
$node->returnType,
|
||||
'self'
|
||||
)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$scope = $node->getAttribute(AttributeKey::SCOPE);
|
||||
if ($scope === null) {
|
||||
$className = $node->getAttribute(AttributeKey::CLASS_NAME);
|
||||
|
|
Loading…
Reference in New Issue
Block a user