diff --git a/phpunit.xml b/phpunit.xml
index 9f15cef2ecf..deaec9b43a2 100644
--- a/phpunit.xml
+++ b/phpunit.xml
@@ -14,6 +14,7 @@
tests
rules-tests
utils-tests
+ rules-tests/Php83/Rector/ClassMethod/AddOverrideAttributeToOverriddenMethodsRector/Source/SomeAbstractTest.php
diff --git a/rector.php b/rector.php
index d9c6b398a62..20e9a368c50 100644
--- a/rector.php
+++ b/rector.php
@@ -6,7 +6,6 @@
use Rector\Config\RectorConfig;
use Rector\DeadCode\Rector\ConstFetch\RemovePhpVersionIdCheckRector;
use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector;
-use Rector\Php83\Rector\ClassConst\AddTypeToConstRector;
use Rector\PHPUnit\CodeQuality\Rector\Class_\AddSeeTestAnnotationRector;
use Rector\Utils\Rector\RemoveRefactorDuplicatedNodeInstanceCheckRector;
@@ -26,7 +25,7 @@
)
->withAttributesSets()
->withComposerBased(phpunit: true)
- ->withPhpSets(php82: true)
+ ->withPhpSets()
->withPaths([
__DIR__ . '/bin',
__DIR__ . '/config',
@@ -40,10 +39,7 @@
])
->withRootFiles()
->withImportNames(removeUnusedImports: true)
- ->withRules([
- RemoveRefactorDuplicatedNodeInstanceCheckRector::class, AddSeeTestAnnotationRector::class,
- AddTypeToConstRector::class,
- ])
+ ->withRules([RemoveRefactorDuplicatedNodeInstanceCheckRector::class, AddSeeTestAnnotationRector::class])
->withSkip([
StringClassNameToClassConstantRector::class,
// tests
diff --git a/rules-tests/Php83/Rector/ClassMethod/AddOverrideAttributeToOverriddenMethodsRector/Fixture/skip_setup_phpunit_as_clutter.php.inc b/rules-tests/Php83/Rector/ClassMethod/AddOverrideAttributeToOverriddenMethodsRector/Fixture/skip_setup_phpunit_as_clutter.php.inc
new file mode 100644
index 00000000000..d1649c14884
--- /dev/null
+++ b/rules-tests/Php83/Rector/ClassMethod/AddOverrideAttributeToOverriddenMethodsRector/Fixture/skip_setup_phpunit_as_clutter.php.inc
@@ -0,0 +1,15 @@
+isAbstract()) {
+ return false;
+ }
+
+ if ($classMethod->isPrivate()) {
+ return false;
+ }
+
+ $classMethodName = $classMethod->name->name;
+
+ foreach ((array) $classMethod->stmts as $stmt) {
+ if (! $stmt instanceof Expression) {
+ continue;
+ }
+
+ $expr = $stmt->expr;
+ if (! $expr instanceof StaticCall) {
+ continue;
+ }
+
+ if (! $this->nodeNameResolver->isName($expr->class, 'parent')) {
+ continue;
+ }
+
+ if ($this->nodeNameResolver->isName($expr->name, $classMethodName)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+}
diff --git a/rules/Php81/Rector/Array_/FirstClassCallableRector.php b/rules/Php81/Rector/Array_/FirstClassCallableRector.php
index acd663ad5e5..146d510fd32 100644
--- a/rules/Php81/Rector/Array_/FirstClassCallableRector.php
+++ b/rules/Php81/Rector/Array_/FirstClassCallableRector.php
@@ -4,6 +4,7 @@
namespace Rector\Php81\Rector\Array_;
+use Override;
use PhpParser\Node;
use PhpParser\Node\Expr\MethodCall;
use PhpParser\Node\Expr\StaticCall;
@@ -15,6 +16,7 @@
*/
final class FirstClassCallableRector extends ArrayToFirstClassCallableRector implements DeprecatedInterface
{
+ #[Override]
public function refactor(Node $node): StaticCall|MethodCall|null
{
throw new ShouldNotHappenException(sprintf(
diff --git a/rules/Php83/Rector/ClassMethod/AddOverrideAttributeToOverriddenMethodsRector.php b/rules/Php83/Rector/ClassMethod/AddOverrideAttributeToOverriddenMethodsRector.php
index 74775a64a75..5abcb0252af 100644
--- a/rules/Php83/Rector/ClassMethod/AddOverrideAttributeToOverriddenMethodsRector.php
+++ b/rules/Php83/Rector/ClassMethod/AddOverrideAttributeToOverriddenMethodsRector.php
@@ -19,6 +19,7 @@
use PHPStan\Reflection\ClassReflection;
use PHPStan\Reflection\ReflectionProvider;
use Rector\Contract\Rector\ConfigurableRectorInterface;
+use Rector\DeadCode\NodeAnalyzer\ParentClassAnalyzer;
use Rector\NodeAnalyzer\ClassAnalyzer;
use Rector\Php80\NodeAnalyzer\PhpAttributeAnalyzer;
use Rector\PhpParser\AstResolver;
@@ -54,6 +55,7 @@ public function __construct(
private readonly PhpAttributeAnalyzer $phpAttributeAnalyzer,
private readonly AstResolver $astResolver,
private readonly ValueResolver $valueResolver,
+ private readonly ParentClassAnalyzer $parentClassAnalyzer,
) {
}
@@ -135,6 +137,11 @@ public function refactor(Node $node): ?Node
return null;
}
+ // skip if no parents, nor traits, nor strinables are involved
+ if ($node->extends === null && $node->getTraitUses() === [] && ! $this->implementsStringable($node)) {
+ return null;
+ }
+
$className = (string) $this->getName($node);
if (! $this->reflectionProvider->hasClass($className)) {
return null;
@@ -227,12 +234,18 @@ private function shouldSkipClassMethod(ClassMethod $classMethod): bool
return true;
}
+ // nothing to override
if ($classMethod->isPrivate()) {
return true;
}
// ignore if it already uses the attribute
- return $this->phpAttributeAnalyzer->hasPhpAttribute($classMethod, self::OVERRIDE_CLASS);
+ if ($this->phpAttributeAnalyzer->hasPhpAttribute($classMethod, self::OVERRIDE_CLASS)) {
+ return true;
+ }
+
+ // skip test setup method override, as rather clutters the code than helps
+ return $this->isName($classMethod, 'setUp') && $this->parentClassAnalyzer->hasParentCall($classMethod);
}
private function shouldSkipParentClassMethod(ClassReflection $parentClassReflection, ClassMethod $classMethod): bool
@@ -284,4 +297,15 @@ private function shouldSkipParentClassMethod(ClassReflection $parentClassReflect
return false;
}
+
+ private function implementsStringable(Class_ $class): bool
+ {
+ foreach ($class->implements as $implement) {
+ if ($this->isName($implement, 'Stringable')) {
+ return true;
+ }
+ }
+
+ return false;
+ }
}
diff --git a/src/BetterPhpDocParser/PhpDoc/SpacelessPhpDocTagNode.php b/src/BetterPhpDocParser/PhpDoc/SpacelessPhpDocTagNode.php
index 70647241499..d7928efd494 100644
--- a/src/BetterPhpDocParser/PhpDoc/SpacelessPhpDocTagNode.php
+++ b/src/BetterPhpDocParser/PhpDoc/SpacelessPhpDocTagNode.php
@@ -4,6 +4,7 @@
namespace Rector\BetterPhpDocParser\PhpDoc;
+use Override;
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode;
use Stringable;
@@ -13,6 +14,7 @@
*/
final class SpacelessPhpDocTagNode extends PhpDocTagNode implements Stringable
{
+ #[Override]
public function __toString(): string
{
return $this->name . $this->value;
diff --git a/src/BetterPhpDocParser/PhpDocParser/BetterPhpDocParser.php b/src/BetterPhpDocParser/PhpDocParser/BetterPhpDocParser.php
index 45026f3fd41..da65d242540 100644
--- a/src/BetterPhpDocParser/PhpDocParser/BetterPhpDocParser.php
+++ b/src/BetterPhpDocParser/PhpDocParser/BetterPhpDocParser.php
@@ -5,6 +5,7 @@
namespace Rector\BetterPhpDocParser\PhpDocParser;
use Nette\Utils\Strings;
+use Override;
use PhpParser\Node;
use PHPStan\PhpDocParser\Ast\PhpDoc\GenericTagValueNode;
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocChildNode;
@@ -90,6 +91,7 @@ public function parseWithNode(BetterTokenIterator $betterTokenIterator, Node $no
return $phpDocNode;
}
+ #[Override]
public function parseTag(TokenIterator $tokenIterator): PhpDocTagNode
{
// replace generic nodes with DoctrineAnnotations
@@ -106,6 +108,7 @@ public function parseTag(TokenIterator $tokenIterator): PhpDocTagNode
/**
* @param BetterTokenIterator $tokenIterator
*/
+ #[Override]
public function parseTagValue(TokenIterator $tokenIterator, string $tag): PhpDocTagValueNode
{
$isPrecededByHorizontalWhitespace = $tokenIterator->isPrecededByHorizontalWhitespace();
diff --git a/src/BetterPhpDocParser/ValueObject/PhpDoc/SpacingAwareTemplateTagValueNode.php b/src/BetterPhpDocParser/ValueObject/PhpDoc/SpacingAwareTemplateTagValueNode.php
index 92dd63ae7ac..d0fa17733b9 100644
--- a/src/BetterPhpDocParser/ValueObject/PhpDoc/SpacingAwareTemplateTagValueNode.php
+++ b/src/BetterPhpDocParser/ValueObject/PhpDoc/SpacingAwareTemplateTagValueNode.php
@@ -4,6 +4,7 @@
namespace Rector\BetterPhpDocParser\ValueObject\PhpDoc;
+use Override;
use PHPStan\PhpDocParser\Ast\PhpDoc\TemplateTagValueNode;
use PHPStan\PhpDocParser\Ast\Type\TypeNode;
use Stringable;
@@ -19,6 +20,7 @@ public function __construct(
parent::__construct($name, $typeNode, $description);
}
+ #[Override]
public function __toString(): string
{
// @see https://github.com/rectorphp/rector/issues/3438
diff --git a/src/BetterPhpDocParser/ValueObject/Type/BracketsAwareIntersectionTypeNode.php b/src/BetterPhpDocParser/ValueObject/Type/BracketsAwareIntersectionTypeNode.php
index d1a0afae706..f0544b25f94 100644
--- a/src/BetterPhpDocParser/ValueObject/Type/BracketsAwareIntersectionTypeNode.php
+++ b/src/BetterPhpDocParser/ValueObject/Type/BracketsAwareIntersectionTypeNode.php
@@ -4,11 +4,13 @@
namespace Rector\BetterPhpDocParser\ValueObject\Type;
+use Override;
use PHPStan\PhpDocParser\Ast\Type\IntersectionTypeNode;
use Stringable;
final class BracketsAwareIntersectionTypeNode extends IntersectionTypeNode implements Stringable
{
+ #[Override]
public function __toString(): string
{
return implode('&', $this->types);
diff --git a/src/BetterPhpDocParser/ValueObject/Type/BracketsAwareUnionTypeNode.php b/src/BetterPhpDocParser/ValueObject/Type/BracketsAwareUnionTypeNode.php
index 6d8d8e617ae..e4bff800d1a 100644
--- a/src/BetterPhpDocParser/ValueObject/Type/BracketsAwareUnionTypeNode.php
+++ b/src/BetterPhpDocParser/ValueObject/Type/BracketsAwareUnionTypeNode.php
@@ -4,6 +4,7 @@
namespace Rector\BetterPhpDocParser\ValueObject\Type;
+use Override;
use PHPStan\PhpDocParser\Ast\Type\TypeNode;
use PHPStan\PhpDocParser\Ast\Type\UnionTypeNode;
use Stringable;
@@ -23,6 +24,7 @@ public function __construct(
/**
* Preserve common format
*/
+ #[Override]
public function __toString(): string
{
$types = [];
diff --git a/src/BetterPhpDocParser/ValueObject/Type/FullyQualifiedIdentifierTypeNode.php b/src/BetterPhpDocParser/ValueObject/Type/FullyQualifiedIdentifierTypeNode.php
index 59c050c2099..ba15a85d3df 100644
--- a/src/BetterPhpDocParser/ValueObject/Type/FullyQualifiedIdentifierTypeNode.php
+++ b/src/BetterPhpDocParser/ValueObject/Type/FullyQualifiedIdentifierTypeNode.php
@@ -4,11 +4,13 @@
namespace Rector\BetterPhpDocParser\ValueObject\Type;
+use Override;
use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode;
use Stringable;
final class FullyQualifiedIdentifierTypeNode extends IdentifierTypeNode implements Stringable
{
+ #[Override]
public function __toString(): string
{
return '\\' . ltrim($this->name, '\\');
diff --git a/src/BetterPhpDocParser/ValueObject/Type/SpacingAwareArrayTypeNode.php b/src/BetterPhpDocParser/ValueObject/Type/SpacingAwareArrayTypeNode.php
index 4e33184ab26..1a7da5c9ef2 100644
--- a/src/BetterPhpDocParser/ValueObject/Type/SpacingAwareArrayTypeNode.php
+++ b/src/BetterPhpDocParser/ValueObject/Type/SpacingAwareArrayTypeNode.php
@@ -4,6 +4,7 @@
namespace Rector\BetterPhpDocParser\ValueObject\Type;
+use Override;
use PHPStan\PhpDocParser\Ast\Type\ArrayTypeNode;
use PHPStan\PhpDocParser\Ast\Type\CallableTypeNode;
use PHPStan\PhpDocParser\Ast\Type\GenericTypeNode;
@@ -14,6 +15,7 @@
final class SpacingAwareArrayTypeNode extends ArrayTypeNode implements Stringable
{
+ #[Override]
public function __toString(): string
{
if ($this->type instanceof CallableTypeNode) {
diff --git a/src/BetterPhpDocParser/ValueObject/Type/SpacingAwareCallableTypeNode.php b/src/BetterPhpDocParser/ValueObject/Type/SpacingAwareCallableTypeNode.php
index 3b7957d6413..7eb7ddf16ec 100644
--- a/src/BetterPhpDocParser/ValueObject/Type/SpacingAwareCallableTypeNode.php
+++ b/src/BetterPhpDocParser/ValueObject/Type/SpacingAwareCallableTypeNode.php
@@ -4,11 +4,13 @@
namespace Rector\BetterPhpDocParser\ValueObject\Type;
+use Override;
use PHPStan\PhpDocParser\Ast\Type\CallableTypeNode;
use Stringable;
final class SpacingAwareCallableTypeNode extends CallableTypeNode implements Stringable
{
+ #[Override]
public function __toString(): string
{
// keep original (Psalm?) format, see https://github.com/rectorphp/rector/issues/2841
diff --git a/src/Config/RectorConfig.php b/src/Config/RectorConfig.php
index f74e0dd0dbe..39ea996da58 100644
--- a/src/Config/RectorConfig.php
+++ b/src/Config/RectorConfig.php
@@ -5,6 +5,7 @@
namespace Rector\Config;
use Illuminate\Container\Container;
+use Override;
use Rector\Caching\Contract\ValueObject\Storage\CacheStorageInterface;
use Rector\Configuration\Option;
use Rector\Configuration\Parameter\SimpleParameterProvider;
@@ -406,6 +407,7 @@ public function autotagInterface(string $interface): void
/**
* @param string $abstract
*/
+ #[Override]
public function singleton($abstract, mixed $concrete = null): void
{
parent::singleton($abstract, $concrete);
diff --git a/src/Console/ConsoleApplication.php b/src/Console/ConsoleApplication.php
index 74f023a5d34..954c0645c12 100644
--- a/src/Console/ConsoleApplication.php
+++ b/src/Console/ConsoleApplication.php
@@ -5,6 +5,7 @@
namespace Rector\Console;
use Composer\XdebugHandler\XdebugHandler;
+use Override;
use Rector\Application\VersionResolver;
use Rector\ChangesReporting\Output\ConsoleOutputFormatter;
use Rector\Configuration\Option;
@@ -37,6 +38,7 @@ public function __construct(array $commands)
$this->setDefaultCommand('process');
}
+ #[Override]
public function doRun(InputInterface $input, OutputInterface $output): int
{
$this->enableXdebug($input);
@@ -76,6 +78,7 @@ public function doRun(InputInterface $input, OutputInterface $output): int
return parent::doRun($input, $output);
}
+ #[Override]
protected function getDefaultInputDefinition(): InputDefinition
{
$defaultInputDefinition = parent::getDefaultInputDefinition();
diff --git a/src/Console/Style/RectorStyle.php b/src/Console/Style/RectorStyle.php
index 0b8b5d7c4dc..e3a4db616b8 100644
--- a/src/Console/Style/RectorStyle.php
+++ b/src/Console/Style/RectorStyle.php
@@ -5,6 +5,7 @@
namespace Rector\Console\Style;
use OndraM\CiDetector\CiDetector;
+use Override;
use Symfony\Component\Console\Exception\RuntimeException;
use Symfony\Component\Console\Helper\ProgressBar;
use Symfony\Component\Console\Input\InputInterface;
@@ -30,6 +31,7 @@ public function __construct(InputInterface $input, OutputInterface $output)
/**
* @see https://github.com/phpstan/phpstan-src/commit/0993d180e5a15a17631d525909356081be59ffeb
*/
+ #[Override]
public function createProgressBar(int $max = 0): ProgressBar
{
$progressBar = parent::createProgressBar($max);
@@ -56,6 +58,7 @@ public function createProgressBar(int $max = 0): ProgressBar
return $progressBar;
}
+ #[Override]
public function progressAdvance(int $step = 1): void
{
// hide progress bar in tests
diff --git a/src/PhpParser/Node/CustomNode/FileWithoutNamespace.php b/src/PhpParser/Node/CustomNode/FileWithoutNamespace.php
index 5bb6093891d..da4c17f529f 100644
--- a/src/PhpParser/Node/CustomNode/FileWithoutNamespace.php
+++ b/src/PhpParser/Node/CustomNode/FileWithoutNamespace.php
@@ -4,6 +4,7 @@
namespace Rector\PhpParser\Node\CustomNode;
+use Override;
use Rector\Contract\PhpParser\Node\StmtsAwareInterface;
use Rector\PhpParser\Node\FileNode;
@@ -15,6 +16,7 @@
*/
final class FileWithoutNamespace extends FileNode implements StmtsAwareInterface
{
+ #[Override]
public function getType(): string
{
return 'FileWithoutNamespace';
@@ -23,6 +25,7 @@ public function getType(): string
/**
* @return string[]
*/
+ #[Override]
public function getSubNodeNames(): array
{
return ['stmts'];
diff --git a/src/PhpParser/Printer/BetterStandardPrinter.php b/src/PhpParser/Printer/BetterStandardPrinter.php
index 04849e5b3ed..293a4d4fe1b 100644
--- a/src/PhpParser/Printer/BetterStandardPrinter.php
+++ b/src/PhpParser/Printer/BetterStandardPrinter.php
@@ -5,6 +5,7 @@
namespace Rector\PhpParser\Printer;
use Nette\Utils\Strings;
+use Override;
use PhpParser\Comment;
use PhpParser\Internal\TokenStream;
use PhpParser\Node;
@@ -63,6 +64,7 @@ public function __construct(
* @param Node[] $origStmts
* @param mixed[] $origTokens
*/
+ #[Override]
public function printFormatPreserving(array $stmts, array $origStmts, array $origTokens): string
{
$newStmts = $this->unwrapFileNode($stmts);
@@ -100,6 +102,7 @@ public function print(Node | array | null $node): string
/**
* @param Node[] $stmts
*/
+ #[Override]
public function prettyPrintFile(array $stmts): string
{
// to keep indexes from 0
@@ -117,6 +120,7 @@ protected function pInterpolatedStringPart(InterpolatedStringPart $interpolatedS
return $interpolatedStringPart->value;
}
+ #[Override]
protected function p(
Node $node,
int $precedence = self::MAX_PRECEDENCE,
@@ -161,6 +165,7 @@ protected function pStmt_FileNode(FileNode $fileNode): string
return $this->pStmts($fileNode->stmts);
}
+ #[Override]
protected function pExpr_ArrowFunction(ArrowFunction $arrowFunction, int $precedence, int $lhsPrecedence): string
{
if (! $arrowFunction->hasAttribute(AttributeKey::COMMENTS)) {
@@ -196,6 +201,7 @@ protected function pExpr_ArrowFunction(ArrowFunction $arrowFunction, int $preced
/**
* This allows to use both spaces and tabs vs. original space-only
*/
+ #[Override]
protected function setIndentLevel(int $level): void
{
$level = max($level, 0);
@@ -206,6 +212,7 @@ protected function setIndentLevel(int $level): void
/**
* This allows to use both spaces and tabs vs. original space-only
*/
+ #[Override]
protected function indent(): void
{
$indentSize = SimpleParameterProvider::provideIntParameter(Option::INDENT_SIZE);
@@ -217,6 +224,7 @@ protected function indent(): void
/**
* This allows to use both spaces and tabs vs. original space-only
*/
+ #[Override]
protected function outdent(): void
{
if ($this->getIndentCharacter() === ' ') {
@@ -236,6 +244,7 @@ protected function outdent(): void
* @param mixed[] $nodes
* @param mixed[] $origNodes
*/
+ #[Override]
protected function pArray(
array $nodes,
array $origNodes,
@@ -264,6 +273,7 @@ protected function pArray(
* Do not add "()" on Expressions
* @see https://github.com/rectorphp/rector/pull/401#discussion_r181487199
*/
+ #[Override]
protected function pExpr_Yield(Yield_ $yield, int $precedence, int $lhsPrecedence): string
{
if (! $yield->value instanceof Expr) {
@@ -285,6 +295,7 @@ protected function pExpr_Yield(Yield_ $yield, int $precedence, int $lhsPrecedenc
/**
* Print new lined array items when newlined_array_print is set to true
*/
+ #[Override]
protected function pExpr_Array(Array_ $array): string
{
if ($array->getAttribute(AttributeKey::NEWLINED_ARRAY_PRINT) === true) {
@@ -297,6 +308,7 @@ protected function pExpr_Array(Array_ $array): string
return parent::pExpr_Array($array);
}
+ #[Override]
protected function pExpr_BinaryOp_Pipe(Pipe $node, int $precedence, int $lhsPrecedence): string
{
return $this->pInfixOp(
@@ -312,6 +324,7 @@ protected function pExpr_BinaryOp_Pipe(Pipe $node, int $precedence, int $lhsPrec
/**
* Fixes escaping of regular patterns
*/
+ #[Override]
protected function pScalar_String(String_ $string): string
{
if ($string->getAttribute(AttributeKey::DOC_INDENTATION) === '__REMOVED__') {
@@ -339,6 +352,7 @@ protected function pScalar_String(String_ $string): string
/**
* It remove all spaces extra to parent
*/
+ #[Override]
protected function pStmt_Declare(Declare_ $declare): string
{
$declareString = parent::pStmt_Declare($declare);
@@ -346,6 +360,7 @@ protected function pStmt_Declare(Declare_ $declare): string
return Strings::replace($declareString, '#\s+#');
}
+ #[Override]
protected function pExpr_Ternary(Ternary $ternary, int $precedence, int $lhsPrecedence): string
{
$kind = $ternary->getAttribute(AttributeKey::KIND);
@@ -360,6 +375,7 @@ protected function pExpr_Ternary(Ternary $ternary, int $precedence, int $lhsPrec
/**
* Used in rector-downgrade-php
*/
+ #[Override]
protected function pScalar_InterpolatedString(InterpolatedString $interpolatedString): string
{
$content = parent::pScalar_InterpolatedString($interpolatedString);
@@ -371,6 +387,7 @@ protected function pScalar_InterpolatedString(InterpolatedString $interpolatedSt
return $content;
}
+ #[Override]
protected function pExpr_MethodCall(MethodCall $methodCall): string
{
if (! $methodCall->var instanceof CallLike) {
@@ -395,6 +412,7 @@ protected function pExpr_MethodCall(MethodCall $methodCall): string
. '(' . $this->pMaybeMultiline($methodCall->args) . ')';
}
+ #[Override]
protected function pInfixOp(
string $class,
Node $leftNode,
@@ -407,6 +425,7 @@ protected function pInfixOp(
return parent::pInfixOp($class, $leftNode, $operatorString, $rightNode, $precedence, $lhsPrecedence);
}
+ #[Override]
protected function pExpr_Instanceof(Instanceof_ $instanceof, int $precedence, int $lhsPrecedence): string
{
$this->wrapAssign($instanceof->expr, $instanceof->class);
diff --git a/src/PostRector/Rector/ClassRenamingPostRector.php b/src/PostRector/Rector/ClassRenamingPostRector.php
index 32e8251e528..51622e7e14d 100644
--- a/src/PostRector/Rector/ClassRenamingPostRector.php
+++ b/src/PostRector/Rector/ClassRenamingPostRector.php
@@ -4,6 +4,7 @@
namespace Rector\PostRector\Rector;
+use Override;
use PhpParser\Node;
use PhpParser\Node\Stmt\Namespace_;
use PhpParser\NodeVisitor;
@@ -62,6 +63,7 @@ public function enterNode(Node $node): Namespace_|FileNode|int|null
return NodeVisitor::STOP_TRAVERSAL;
}
+ #[Override]
public function shouldTraverse(array $stmts): bool
{
$this->oldToNewClasses = $this->renamedClassesDataCollector->getOldToNewClasses();
diff --git a/src/PostRector/Rector/DocblockNameImportingPostRector.php b/src/PostRector/Rector/DocblockNameImportingPostRector.php
index 407f8de47db..2089d5f0d89 100644
--- a/src/PostRector/Rector/DocblockNameImportingPostRector.php
+++ b/src/PostRector/Rector/DocblockNameImportingPostRector.php
@@ -4,6 +4,7 @@
namespace Rector\PostRector\Rector;
+use Override;
use PhpParser\Node;
use PhpParser\Node\Param;
use PhpParser\Node\Stmt;
@@ -47,6 +48,7 @@ public function enterNode(Node $node): Node|null
/**
* @param Stmt[] $stmts
*/
+ #[Override]
public function shouldTraverse(array $stmts): bool
{
return $this->addUseStatementGuard->shouldTraverse($stmts, $this->getFile()->getFilePath());
diff --git a/src/PostRector/Rector/NameImportingPostRector.php b/src/PostRector/Rector/NameImportingPostRector.php
index 7c63e54b217..7052b406ba3 100644
--- a/src/PostRector/Rector/NameImportingPostRector.php
+++ b/src/PostRector/Rector/NameImportingPostRector.php
@@ -4,6 +4,7 @@
namespace Rector\PostRector\Rector;
+use Override;
use PhpParser\Node;
use PhpParser\Node\Name;
use PhpParser\Node\Name\FullyQualified;
@@ -56,6 +57,7 @@ public function enterNode(Node $node): Name|null
/**
* @param Stmt[] $stmts
*/
+ #[Override]
public function shouldTraverse(array $stmts): bool
{
return $this->addUseStatementGuard->shouldTraverse($stmts, $this->getFile()->getFilePath());
diff --git a/src/StaticTypeMapper/ValueObject/Type/AliasedObjectType.php b/src/StaticTypeMapper/ValueObject/Type/AliasedObjectType.php
index ca1bc7028d5..c9a14f997fe 100644
--- a/src/StaticTypeMapper/ValueObject/Type/AliasedObjectType.php
+++ b/src/StaticTypeMapper/ValueObject/Type/AliasedObjectType.php
@@ -4,6 +4,7 @@
namespace Rector\StaticTypeMapper\ValueObject\Type;
+use Override;
use PhpParser\Node\Name;
use PhpParser\Node\Stmt\Use_;
use PhpParser\Node\UseItem;
@@ -53,6 +54,7 @@ public function areShortNamesEqual(self | FullyQualifiedObjectType $comparedObje
return $this->getShortName() === $comparedObjectType->getShortName();
}
+ #[Override]
public function equals(Type $type): bool
{
$className = ClassNameFromObjectTypeResolver::resolve($type);
diff --git a/src/StaticTypeMapper/ValueObject/Type/ShortenedGenericObjectType.php b/src/StaticTypeMapper/ValueObject/Type/ShortenedGenericObjectType.php
index 916ba0da943..b4ebf1d0183 100644
--- a/src/StaticTypeMapper/ValueObject/Type/ShortenedGenericObjectType.php
+++ b/src/StaticTypeMapper/ValueObject/Type/ShortenedGenericObjectType.php
@@ -4,6 +4,7 @@
namespace Rector\StaticTypeMapper\ValueObject\Type;
+use Override;
use PHPStan\Type\Generic\GenericObjectType;
use PHPStan\Type\IsSuperTypeOfResult;
use PHPStan\Type\Type;
@@ -24,6 +25,7 @@ public function __construct(
parent::__construct($shortName, $types);
}
+ #[Override]
public function isSuperTypeOf(Type $type): IsSuperTypeOfResult
{
$genericObjectType = new GenericObjectType($this->fullyQualifiedName, $this->getTypes());
diff --git a/src/StaticTypeMapper/ValueObject/Type/ShortenedObjectType.php b/src/StaticTypeMapper/ValueObject/Type/ShortenedObjectType.php
index 208bd9ce896..f5e7108eb80 100644
--- a/src/StaticTypeMapper/ValueObject/Type/ShortenedObjectType.php
+++ b/src/StaticTypeMapper/ValueObject/Type/ShortenedObjectType.php
@@ -4,6 +4,7 @@
namespace Rector\StaticTypeMapper\ValueObject\Type;
+use Override;
use PHPStan\Type\IsSuperTypeOfResult;
use PHPStan\Type\ObjectType;
use PHPStan\Type\Type;
@@ -23,6 +24,7 @@ public function __construct(
parent::__construct($shortName);
}
+ #[Override]
public function isSuperTypeOf(Type $type): IsSuperTypeOfResult
{
$fullyQualifiedObjectType = new ObjectType($this->fullyQualifiedName);
diff --git a/src/StaticTypeMapper/ValueObject/Type/SimpleStaticType.php b/src/StaticTypeMapper/ValueObject/Type/SimpleStaticType.php
index d975c714b86..d97ba4c2d84 100644
--- a/src/StaticTypeMapper/ValueObject/Type/SimpleStaticType.php
+++ b/src/StaticTypeMapper/ValueObject/Type/SimpleStaticType.php
@@ -4,6 +4,7 @@
namespace Rector\StaticTypeMapper\ValueObject\Type;
+use Override;
use PHPStan\Type\StaticType;
final class SimpleStaticType extends StaticType
@@ -13,6 +14,7 @@ public function __construct(
) {
}
+ #[Override]
public function getClassName(): string
{
return $this->className;