Skip to content

Commit 23a17d4

Browse files
authored
Move mix DowngradeSetAccessibleReflectionPropertyRector+DowngradeMatchToSwitchRector tests from rector-src to here (#340)
1 parent 388ab1f commit 23a17d4

File tree

3 files changed

+84
-0
lines changed

3 files changed

+84
-0
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
3+
namespace Rector\Tests\Issues\ScopeNotAvailable\FixtureMatchToSwitchReflection;
4+
5+
final class ServiceValueResolver
6+
{
7+
public function resolve(Request $request, ArgumentMetadata $argument): array
8+
{
9+
try {
10+
11+
} catch (\RuntimeException $e) {
12+
13+
$r = new \ReflectionProperty($e, 'message');
14+
$r->setValue($e, $message);
15+
16+
throw $e;
17+
}
18+
}
19+
}
20+
21+
?>
22+
-----
23+
<?php
24+
25+
namespace Rector\Tests\Issues\ScopeNotAvailable\FixtureMatchToSwitchReflection;
26+
27+
final class ServiceValueResolver
28+
{
29+
public function resolve(Request $request, ArgumentMetadata $argument): array
30+
{
31+
try {
32+
33+
} catch (\RuntimeException $e) {
34+
35+
$r = new \ReflectionProperty($e, 'message');
36+
if (PHP_VERSION_ID < 80100) {
37+
$r->setAccessible(true);
38+
}
39+
$r->setValue($e, $message);
40+
41+
throw $e;
42+
}
43+
}
44+
}
45+
46+
?>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Rector\Tests\Issues\ScopeNotAvailable;
6+
7+
use Iterator;
8+
use PHPUnit\Framework\Attributes\DataProvider;
9+
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
10+
11+
final class MatchToSwitchReflectionTest extends AbstractRectorTestCase
12+
{
13+
#[DataProvider('provideData')]
14+
public function test(string $filePath): void
15+
{
16+
$this->doTestFile($filePath);
17+
}
18+
19+
public static function provideData(): Iterator
20+
{
21+
return self::yieldFilesFromDirectory(__DIR__ . '/FixtureMatchToSwitchReflection');
22+
}
23+
24+
public function provideConfigFilePath(): string
25+
{
26+
return __DIR__ . '/config/match_to_switch_reflection.php';
27+
}
28+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Rector\Config\RectorConfig;
6+
use Rector\DowngradePhp80\Rector\Expression\DowngradeMatchToSwitchRector;
7+
use Rector\DowngradePhp81\Rector\StmtsAwareInterface\DowngradeSetAccessibleReflectionPropertyRector;
8+
9+
return RectorConfig::configure()
10+
->withRules([DowngradeSetAccessibleReflectionPropertyRector::class, DowngradeMatchToSwitchRector::class]);

0 commit comments

Comments
 (0)