-
-
Notifications
You must be signed in to change notification settings - Fork 946
Closed
Description
Bug report
Using anonymous class definition inside another class leads to Fatal error during symbol discovery
Internal error: Internal error: Class 'Granularity' not found in file /var/www/html/sts3/app/modules/Statistics/Granularity.php
Removing the anonymous class definition resolves the error.
Code snippet that reproduces the problem
Unable to reproduce in playground.
Class snippet
<?php
declare(strict_types=1);
class Granularity
{
protected static function provideInstances(): array
{
$myclass = new class() extends Granularity { };
return [];
}
}
PHPStan debug trace
PHP Fatal error: Uncaught Error: Class 'Granularity' not found in phar:///var/www/html/sts3/vendor/phpstan/phpstan/phpstan/src/Reflection/Runtime/RuntimeReflectionProvider.php(129) : eval()'d code:1
Stack trace:
#0 phar:///var/www/html/sts3/vendor/phpstan/phpstan/phpstan/src/Reflection/Runtime/RuntimeReflectionProvider.php(129): eval()
#1 phar:///var/www/html/sts3/vendor/phpstan/phpstan/phpstan/src/Reflection/ReflectionProvider/ClassBlacklistReflectionProvider.php(97): PHPStan\Reflection\Runtime\RuntimeReflectionProvider->getAnonymousClassReflection(Object(PhpParser\Node\Stmt\Class_), Object(PHPStan\Analyser\MutatingScope))
#2 phar:///var/www/html/sts3/vendor/phpstan/phpstan/phpstan/src/Reflection/ReflectionProvider/ChainReflectionProvider.php(55): PHPStan\Reflection\ReflectionProvider\ClassBlacklistReflectionProvider->getAnonymousClassReflection(Object(PhpParser\Node\Stmt\Class_), Object(PHPStan\Analyser\MutatingScope))
#3 phar:///var/www/html/sts3/vendor/phpstan/phpstan/phpstan/src/Reflection/ReflectionProvider/MemoizingRef in phar:///var/www/html/sts3/vendor/phpstan/phpstan/phpstan/src/Reflection/Runtime/RuntimeReflectionProvider.php(129) : eval()'d code on line 1
Fatal error: Uncaught Error: Class 'Granularity' not found in phar:///var/www/html/sts3/vendor/phpstan/phpstan/phpstan/src/Reflection/Runtime/RuntimeReflectionProvider.php(129) : eval()'d code:1
Stack trace:
#0 phar:///var/www/html/sts3/vendor/phpstan/phpstan/phpstan/src/Reflection/Runtime/RuntimeReflectionProvider.php(129): eval()
#1 phar:///var/www/html/sts3/vendor/phpstan/phpstan/phpstan/src/Reflection/ReflectionProvider/ClassBlacklistReflectionProvider.php(97): PHPStan\Reflection\Runtime\RuntimeReflectionProvider->getAnonymousClassReflection(Object(PhpParser\Node\Stmt\Class_), Object(PHPStan\Analyser\MutatingScope))
#2 phar:///var/www/html/sts3/vendor/phpstan/phpstan/phpstan/src/Reflection/ReflectionProvider/ChainReflectionProvider.php(55): PHPStan\Reflection\ReflectionProvider\ClassBlacklistReflectionProvider->getAnonymousClassReflection(Object(PhpParser\Node\Stmt\Class_), Object(PHPStan\Analyser\MutatingScope))
#3 phar:///var/www/html/sts3/vendor/phpstan/phpstan/phpstan/src/Reflection/ReflectionProvider/MemoizingRef in phar:///var/www/html/sts3/vendor/phpstan/phpstan/phpstan/src/Reflection/Runtime/RuntimeReflectionProvider.php(129) : eval()'d code on line 1
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels