Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions build/more-enum-adapter-errors.neon
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,13 @@ parameters:
rawMessage: 'Asserted type PHPStan\BetterReflection\Reflection\Adapter\ReflectionEnum for $this->getNativeReflection() with type PHPStan\BetterReflection\Reflection\Adapter\ReflectionClass can never happen.'
count: 1
path: ../src/Reflection/ClassReflection.php

-
rawMessage: 'Parameter #2 $reflection of method PHPStan\Reflection\ClassReflectionFactory::create() expects ReflectionClass, PHPStan\BetterReflection\Reflection\Adapter\ReflectionClass|PHPStan\BetterReflection\Reflection\Adapter\ReflectionEnum given.'
count: 1
path: ../src/Reflection/BetterReflection/BetterReflectionProvider.php

-
rawMessage: 'Parameter #2 $reflection of method PHPStan\Reflection\ClassReflectionFactory::create() expects ReflectionClass, PHPStan\BetterReflection\Reflection\Adapter\ReflectionClass|PHPStan\BetterReflection\Reflection\Adapter\ReflectionEnum given.'
count: 1
path: ../src/Analyser/NodeScopeResolver.php
4 changes: 4 additions & 0 deletions build/phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ parameters:
- '#^Dynamic call to static method PHPUnit\\Framework\\\S+\(\)\.$#'
- '#should be contravariant with parameter \$node \(PhpParser\\Node\) of method PHPStan\\Rules\\Rule<PhpParser\\Node>::processNode\(\)$#'
- '#Variable property access on PhpParser\\Node#'
-
identifier: shipmonk.deadMethod
message: '#^Unused .*?::__construct#' # likely used in DIC
reportUnmatched: false
-
identifier: shipmonk.deadMethod
message: '#^Unused .*?Factory::create#' # likely used in DIC
Expand Down
7 changes: 3 additions & 4 deletions src/Analyser/NodeScopeResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@
use function array_merge;
use function array_slice;
use function array_values;
use function base64_decode;
use function count;
use function in_array;
use function is_array;
Expand Down Expand Up @@ -2621,11 +2620,11 @@ private function createAstClassReflection(Node\Stmt\ClassLike $stmt, string $cla
throw new ShouldNotHappenException();
}

$enumAdapter = base64_decode('UEhQU3RhblxCZXR0ZXJSZWZsZWN0aW9uXFJlZmxlY3Rpb25cQWRhcHRlclxSZWZsZWN0aW9uRW51bQ==', true);

return $this->classReflectionFactory->create(
$betterReflectionClass->getName(),
$betterReflectionClass instanceof ReflectionEnum && PHP_VERSION_ID >= 80000 ? new $enumAdapter($betterReflectionClass) : new ReflectionClass($betterReflectionClass),
$betterReflectionClass instanceof ReflectionEnum && PHP_VERSION_ID >= 80000
? new \PHPStan\BetterReflection\Reflection\Adapter\ReflectionEnum($betterReflectionClass)
: new ReflectionClass($betterReflectionClass),
null,
null,
null,
Expand Down
4 changes: 1 addition & 3 deletions src/Reflection/BetterReflection/BetterReflectionProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
use function array_key_exists;
use function array_key_first;
use function array_map;
use function base64_decode;
use function in_array;
use function sprintf;
use function strtolower;
Expand Down Expand Up @@ -145,8 +144,7 @@ public function getClass(string $className): ClassReflection
}

if ($reflectionClass instanceof ReflectionEnum && PHP_VERSION_ID >= 80000) {
$enumAdapter = base64_decode('UEhQU3RhblxCZXR0ZXJSZWZsZWN0aW9uXFJlZmxlY3Rpb25cQWRhcHRlclxSZWZsZWN0aW9uRW51bQ==', true);
$adaptedClass = new $enumAdapter($reflectionClass);
$adaptedClass = new \PHPStan\BetterReflection\Reflection\Adapter\ReflectionEnum($reflectionClass);
} else {
$adaptedClass = new ReflectionClass($reflectionClass);
}
Expand Down
Loading