Skip to content

Conversation

@TomasVotruba
Copy link
Member

@TomasVotruba TomasVotruba commented Jan 26, 2026

In case of explicit parent::setUp() call, there is no need to add override attribute to the method. It was added by Rector core set, before it the rule got better at detecting useful cases.

This rule removes the override to make tests case more readable again 👍

@TomasVotruba TomasVotruba force-pushed the tv-no-override-setup branch 2 times, most recently from 2f0591d to 9bf2000 Compare January 26, 2026 20:59
@TomasVotruba TomasVotruba enabled auto-merge (squash) January 26, 2026 21:01
@TomasVotruba TomasVotruba merged commit 9a2221b into main Jan 26, 2026
7 checks passed
@TomasVotruba TomasVotruba deleted the tv-no-override-setup branch January 26, 2026 21:01
@samsonasik
Copy link
Member

If parent class is class in between, eg: extends AbstractFunctionalTestCase which has common setup for DB set, I think #[Override] still needed.

So only change when direct parent is a extends TestCase.

I will create PR for it.

@samsonasik
Copy link
Member

samsonasik commented Jan 26, 2026

Just check, it seems the TestsNodeAnalyzer::isInTestClass() check exactly extends equal name, so it seems not change the indirect parent class is class in between, so seems ok.

public function isInTestClass(Node $node): bool
{
$classReflection = $this->reflectionResolver->resolveClassReflection($node);
if (! $classReflection instanceof ClassReflection) {
return false;
}
foreach (PHPUnitClassName::TEST_CLASSES as $testCaseObjectClass) {
if ($classReflection->is($testCaseObjectClass)) {
return true;
}
}
return false;
}

@samsonasik
Copy link
Member

Ok, I can reproduce indirect parent Test case, which still removed, which should be skipped:

Screenshot 2026-01-27 at 07 01 15

I will create new PR for it.

@samsonasik
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants