Skip to content

Commit 7c6d315

Browse files
committed
Call setAccessible only on old PHP
1 parent b1d629e commit 7c6d315

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

tests/Excluder/TestsUsageExcluderTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use PHPStan\Testing\PHPStanTestCase;
77
use ReflectionClass;
88
use function realpath;
9+
use const PHP_VERSION_ID;
910

1011
class TestsUsageExcluderTest extends PHPStanTestCase
1112
{
@@ -16,7 +17,9 @@ public function testAutodetectComposerDevPaths(): void
1617

1718
$excluderReflection = new ReflectionClass(TestsUsageExcluder::class);
1819
$devPathsPropertyReflection = $excluderReflection->getProperty('devPaths');
19-
$devPathsPropertyReflection->setAccessible(true);
20+
if (PHP_VERSION_ID < 8_01_00) {
21+
$devPathsPropertyReflection->setAccessible(true);
22+
}
2023

2124
self::assertSame([
2225
realpath(__DIR__ . '/../../tests'),

tests/Provider/SymfonyUsageProviderTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use function mkdir;
88
use function realpath;
99
use function rmdir;
10+
use const PHP_VERSION_ID;
1011

1112
class SymfonyUsageProviderTest extends PHPStanTestCase
1213
{
@@ -20,7 +21,9 @@ public function testAutodetectConfigDir(): void
2021

2122
$providerReflection = new ReflectionClass(SymfonyUsageProvider::class);
2223
$configDirPropertyReflection = $providerReflection->getProperty('configDir');
23-
$configDirPropertyReflection->setAccessible(true);
24+
if (PHP_VERSION_ID < 8_01_00) {
25+
$configDirPropertyReflection->setAccessible(true);
26+
}
2427

2528
$configDirFromProperty = $configDirPropertyReflection->getValue($provider);
2629

0 commit comments

Comments
 (0)