Skip to content

Commit 1bb400a

Browse files
authored
covert tearDown in NoSetupWithParentCallOverrideRector as well (#652)
1 parent 7a914ca commit 1bb400a

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
namespace Rector\PHPUnit\Tests\CodeQuality\Rector\ClassMethod\NoSetupWithParentCallOverrideRector\Fixture;
4+
5+
use PHPUnit\Framework\TestCase;
6+
7+
final class CoverTearDown extends TestCase
8+
{
9+
#[\Override]
10+
protected function tearDown(): void
11+
{
12+
parent::tearDown();
13+
14+
$some = 'value';
15+
}
16+
}
17+
18+
?>
19+
-----
20+
<?php
21+
22+
namespace Rector\PHPUnit\Tests\CodeQuality\Rector\ClassMethod\NoSetupWithParentCallOverrideRector\Fixture;
23+
24+
use PHPUnit\Framework\TestCase;
25+
26+
final class CoverTearDown extends TestCase
27+
{
28+
protected function tearDown(): void
29+
{
30+
parent::tearDown();
31+
$some = 'value';
32+
}
33+
}
34+
35+
?>

rules/CodeQuality/Rector/ClassMethod/NoSetupWithParentCallOverrideRector.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function __construct(
2828
public function getRuleDefinition(): RuleDefinition
2929
{
3030
return new RuleDefinition(
31-
'Remove override, if setUp() references parent::setUp() call to improve readability',
31+
'Remove override attribute, if setUp()/tearDown() references parent call to improve readability',
3232
[
3333
new CodeSample(
3434
<<<'CODE_SAMPLE'
@@ -82,7 +82,7 @@ public function refactor(Node $node): ?Node
8282
return null;
8383
}
8484

85-
if (! $this->isName($node, 'setUp')) {
85+
if (! $this->isNames($node, ['setUp', 'tearDown'])) {
8686
return null;
8787
}
8888

0 commit comments

Comments
 (0)