mirror of
https://github.com/rectorphp/rector.git
synced 2025-04-13 12:02:09 +02:00
Updated Rector to commit dfe6f2d43c20b7883ad5354d59c859f3ad85cae4
dfe6f2d43c
[DeadCode] Allow remove useless @var on typed class constant as well on RemoveUselessVarTagRector (#6633)
This commit is contained in:
parent
24e1aacac4
commit
8bafaa06b5
@ -4,6 +4,7 @@ declare (strict_types=1);
|
||||
namespace Rector\DeadCode\PhpDoc;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Stmt\ClassConst;
|
||||
use PhpParser\Node\Stmt\Property;
|
||||
use PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode;
|
||||
use PHPStan\Type\IntersectionType;
|
||||
@ -33,7 +34,10 @@ final class DeadVarTagValueNodeAnalyzer
|
||||
$this->staticTypeMapper = $staticTypeMapper;
|
||||
$this->templateTypeRemovalGuard = $templateTypeRemovalGuard;
|
||||
}
|
||||
public function isDead(VarTagValueNode $varTagValueNode, Property $property) : bool
|
||||
/**
|
||||
* @param \PhpParser\Node\Stmt\Property|\PhpParser\Node\Stmt\ClassConst $property
|
||||
*/
|
||||
public function isDead(VarTagValueNode $varTagValueNode, $property) : bool
|
||||
{
|
||||
if (!$property->type instanceof Node) {
|
||||
return \false;
|
||||
|
@ -5,6 +5,7 @@ namespace Rector\DeadCode\PhpDoc\TagRemover;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Param;
|
||||
use PhpParser\Node\Stmt\ClassConst;
|
||||
use PhpParser\Node\Stmt\Expression;
|
||||
use PhpParser\Node\Stmt\Property;
|
||||
use PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode;
|
||||
@ -52,7 +53,10 @@ final class VarTagRemover
|
||||
$this->docBlockUpdater = $docBlockUpdater;
|
||||
$this->typeComparator = $typeComparator;
|
||||
}
|
||||
public function removeVarTagIfUseless(PhpDocInfo $phpDocInfo, Property $property) : bool
|
||||
/**
|
||||
* @param \PhpParser\Node\Stmt\Property|\PhpParser\Node\Stmt\ClassConst $property
|
||||
*/
|
||||
public function removeVarTagIfUseless(PhpDocInfo $phpDocInfo, $property) : bool
|
||||
{
|
||||
$varTagValueNode = $phpDocInfo->getVarTagValueNode();
|
||||
if (!$varTagValueNode instanceof VarTagValueNode) {
|
||||
|
@ -4,6 +4,7 @@ declare (strict_types=1);
|
||||
namespace Rector\DeadCode\Rector\Property;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Stmt\ClassConst;
|
||||
use PhpParser\Node\Stmt\Property;
|
||||
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory;
|
||||
use Rector\DeadCode\PhpDoc\TagRemover\VarTagRemover;
|
||||
@ -30,7 +31,7 @@ final class RemoveUselessVarTagRector extends AbstractRector
|
||||
}
|
||||
public function getRuleDefinition() : RuleDefinition
|
||||
{
|
||||
return new RuleDefinition('Remove unused @var annotation for properties', [new CodeSample(<<<'CODE_SAMPLE'
|
||||
return new RuleDefinition('Remove unused @var annotation for properties and class constants', [new CodeSample(<<<'CODE_SAMPLE'
|
||||
final class SomeClass
|
||||
{
|
||||
/**
|
||||
@ -52,10 +53,10 @@ CODE_SAMPLE
|
||||
*/
|
||||
public function getNodeTypes() : array
|
||||
{
|
||||
return [Property::class];
|
||||
return [Property::class, ClassConst::class];
|
||||
}
|
||||
/**
|
||||
* @param Property $node
|
||||
* @param Property|ClassConst $node
|
||||
*/
|
||||
public function refactor(Node $node) : ?Node
|
||||
{
|
||||
|
@ -19,12 +19,12 @@ final class VersionResolver
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = '7bbe9ba2af41fbb64a2817cd44d19665aa79f186';
|
||||
public const PACKAGE_VERSION = 'dfe6f2d43c20b7883ad5354d59c859f3ad85cae4';
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2024-12-27 16:37:19';
|
||||
public const RELEASE_DATE = '2024-12-28 21:19:31';
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user