Skip to content

Commit 42e429c

Browse files
committed
[Tests] replace bespoke RepeatedThreeTimes rules with real-rule RepeatedTwice chain
Drop the three hand-written Source rules that duplicated rule logic in tests; use real AddParamTypeFromPropertyTypeRector + ReturnTypeFromStrictParamRector instead.
1 parent 58f813b commit 42e429c

10 files changed

Lines changed: 55 additions & 309 deletions

‎tests/Issues/RepeatedThreeTimes/Fixture/fixture.php.inc‎

Lines changed: 0 additions & 35 deletions
This file was deleted.

‎tests/Issues/RepeatedThreeTimes/Source/NarrowArrayCollectionDocblockRector.php‎

Lines changed: 0 additions & 78 deletions
This file was deleted.

‎tests/Issues/RepeatedThreeTimes/Source/NarrowParamUnionDocblockRector.php‎

Lines changed: 0 additions & 85 deletions
This file was deleted.

‎tests/Issues/RepeatedThreeTimes/Source/ParamTypeFromDocblockRector.php‎

Lines changed: 0 additions & 69 deletions
This file was deleted.

‎tests/Issues/RepeatedThreeTimes/Source/SomeArrayCollection.php‎

Lines changed: 0 additions & 9 deletions
This file was deleted.

‎tests/Issues/RepeatedThreeTimes/Source/SomeCollection.php‎

Lines changed: 0 additions & 9 deletions
This file was deleted.

‎tests/Issues/RepeatedThreeTimes/config/configured_rule.php‎

Lines changed: 0 additions & 20 deletions
This file was deleted.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
namespace Rector\Tests\Issues\RepeatedTwice\Fixture;
4+
5+
final class Fixture
6+
{
7+
private string $name;
8+
9+
public function change($name)
10+
{
11+
$this->name = $name;
12+
13+
return $name;
14+
}
15+
}
16+
17+
?>
18+
-----
19+
<?php
20+
21+
namespace Rector\Tests\Issues\RepeatedTwice\Fixture;
22+
23+
final class Fixture
24+
{
25+
private string $name;
26+
27+
public function change(string $name): string
28+
{
29+
$this->name = $name;
30+
31+
return $name;
32+
}
33+
}
34+
35+
?>

tests/Issues/RepeatedThreeTimes/RepeatedThreeTimesTest.php renamed to tests/Issues/RepeatedTwice/RepeatedTwiceTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@
22

33
declare(strict_types=1);
44

5-
namespace Rector\Tests\Issues\RepeatedThreeTimes;
5+
namespace Rector\Tests\Issues\RepeatedTwice;
66

77
use Iterator;
88
use PHPUnit\Framework\Attributes\DataProvider;
99
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
1010

1111
/**
12-
* Each rule depends on the output of the rule registered after it,
13-
* so the file only reaches its final state on the 3rd pass
12+
* The return-type rule depends on the output of the param-type rule registered after it,
13+
* so the file only reaches its final state on the 2nd pass
1414
*
1515
* @see https://github.com/rectorphp/rector-src/pull/8826
1616
*/
17-
final class RepeatedThreeTimesTest extends AbstractRectorTestCase
17+
final class RepeatedTwiceTest extends AbstractRectorTestCase
1818
{
1919
#[DataProvider('provideData')]
2020
public function test(string $filePath): void
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Rector\Config\RectorConfig;
6+
use Rector\TypeDeclaration\Rector\ClassMethod\AddParamTypeFromPropertyTypeRector;
7+
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictParamRector;
8+
9+
return RectorConfig::configure()
10+
// registered in reverse order of dependency:
11+
// 2nd pass: native return type from the now-typed param
12+
// 1st pass: native param type from the typed property
13+
->withRules([
14+
ReturnTypeFromStrictParamRector::class,
15+
AddParamTypeFromPropertyTypeRector::class,
16+
]);

0 commit comments

Comments
 (0)