mirror of
https://github.com/rectorphp/rector.git
synced 2025-04-20 23:41:57 +02:00
Fix PHPStan @return class-string<T>.
This commit is contained in:
parent
9ae98079ff
commit
44278b4957
@ -10,6 +10,7 @@ use PhpParser\Node\Stmt\ClassLike;
|
||||
use PhpParser\Node\Stmt\ClassMethod;
|
||||
use PhpParser\Node\Stmt\Function_;
|
||||
use PHPStan\Type\ArrayType;
|
||||
use PHPStan\Type\Generic\GenericObjectType;
|
||||
use PHPStan\Type\IntersectionType;
|
||||
use PHPStan\Type\IterableType;
|
||||
use PHPStan\Type\MixedType;
|
||||
@ -208,6 +209,11 @@ PHP
|
||||
return true;
|
||||
}
|
||||
|
||||
// is class-string<T> type? → skip
|
||||
if ($returnType instanceof GenericObjectType && $returnType->getClassName() === 'class-string') {
|
||||
return true;
|
||||
}
|
||||
|
||||
// prevent overriding self with itself
|
||||
if ($this->print($node->returnType) === 'self') {
|
||||
$className = $node->getAttribute(AttributeKey::CLASS_NAME);
|
||||
|
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Rector\TypeDeclaration\Tests\Rector\ClassMethod\ReturnTypeDeclarationRector\Fixture;
|
||||
|
||||
/**
|
||||
* @template T
|
||||
*/
|
||||
abstract class TestClassStringType
|
||||
{
|
||||
/**
|
||||
* @return class-string<T>
|
||||
*/
|
||||
abstract protected function getClassStringForT(): string;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user