Skip to content

Commit 23947f1

Browse files
Remove base64_decode workaround (#5869)
1 parent 6afc6d4 commit 23947f1

4 files changed

Lines changed: 18 additions & 7 deletions

File tree

‎build/more-enum-adapter-errors.neon‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,13 @@ parameters:
2626
rawMessage: 'Asserted type PHPStan\BetterReflection\Reflection\Adapter\ReflectionEnum for $this->getNativeReflection() with type PHPStan\BetterReflection\Reflection\Adapter\ReflectionClass can never happen.'
2727
count: 1
2828
path: ../src/Reflection/ClassReflection.php
29+
30+
-
31+
rawMessage: 'Parameter #2 $reflection of method PHPStan\Reflection\ClassReflectionFactory::create() expects ReflectionClass, PHPStan\BetterReflection\Reflection\Adapter\ReflectionClass|PHPStan\BetterReflection\Reflection\Adapter\ReflectionEnum given.'
32+
count: 1
33+
path: ../src/Reflection/BetterReflection/BetterReflectionProvider.php
34+
35+
-
36+
rawMessage: 'Parameter #2 $reflection of method PHPStan\Reflection\ClassReflectionFactory::create() expects ReflectionClass, PHPStan\BetterReflection\Reflection\Adapter\ReflectionClass|PHPStan\BetterReflection\Reflection\Adapter\ReflectionEnum given.'
37+
count: 1
38+
path: ../src/Analyser/NodeScopeResolver.php

‎build/phpstan.neon‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ parameters:
7777
- '#^Dynamic call to static method PHPUnit\\Framework\\\S+\(\)\.$#'
7878
- '#should be contravariant with parameter \$node \(PhpParser\\Node\) of method PHPStan\\Rules\\Rule<PhpParser\\Node>::processNode\(\)$#'
7979
- '#Variable property access on PhpParser\\Node#'
80+
-
81+
identifier: shipmonk.deadMethod
82+
message: '#^Unused .*?::__construct#' # likely used in DIC
83+
reportUnmatched: false
8084
-
8185
identifier: shipmonk.deadMethod
8286
message: '#^Unused .*?Factory::create#' # likely used in DIC

‎src/Analyser/NodeScopeResolver.php‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,6 @@
174174
use function array_merge;
175175
use function array_slice;
176176
use function array_values;
177-
use function base64_decode;
178177
use function count;
179178
use function in_array;
180179
use function is_array;
@@ -2621,11 +2620,11 @@ private function createAstClassReflection(Node\Stmt\ClassLike $stmt, string $cla
26212620
throw new ShouldNotHappenException();
26222621
}
26232622

2624-
$enumAdapter = base64_decode('UEhQU3RhblxCZXR0ZXJSZWZsZWN0aW9uXFJlZmxlY3Rpb25cQWRhcHRlclxSZWZsZWN0aW9uRW51bQ==', true);
2625-
26262623
return $this->classReflectionFactory->create(
26272624
$betterReflectionClass->getName(),
2628-
$betterReflectionClass instanceof ReflectionEnum && PHP_VERSION_ID >= 80000 ? new $enumAdapter($betterReflectionClass) : new ReflectionClass($betterReflectionClass),
2625+
$betterReflectionClass instanceof ReflectionEnum && PHP_VERSION_ID >= 80000
2626+
? new \PHPStan\BetterReflection\Reflection\Adapter\ReflectionEnum($betterReflectionClass)
2627+
: new ReflectionClass($betterReflectionClass),
26292628
null,
26302629
null,
26312630
null,

‎src/Reflection/BetterReflection/BetterReflectionProvider.php‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@
5959
use function array_key_exists;
6060
use function array_key_first;
6161
use function array_map;
62-
use function base64_decode;
6362
use function in_array;
6463
use function sprintf;
6564
use function strtolower;
@@ -145,8 +144,7 @@ public function getClass(string $className): ClassReflection
145144
}
146145

147146
if ($reflectionClass instanceof ReflectionEnum && PHP_VERSION_ID >= 80000) {
148-
$enumAdapter = base64_decode('UEhQU3RhblxCZXR0ZXJSZWZsZWN0aW9uXFJlZmxlY3Rpb25cQWRhcHRlclxSZWZsZWN0aW9uRW51bQ==', true);
149-
$adaptedClass = new $enumAdapter($reflectionClass);
147+
$adaptedClass = new \PHPStan\BetterReflection\Reflection\Adapter\ReflectionEnum($reflectionClass);
150148
} else {
151149
$adaptedClass = new ReflectionClass($reflectionClass);
152150
}

0 commit comments

Comments
 (0)