Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Internal error: Failed to retrieve the reflection object (PHP 8.1 RC) #5954

@Firehed

Description

@Firehed

Bug report

PHPStan 1.1.1 on PHP 8.1-RC5 (Docker, php:8.1.0RC5-fpm-alpine3.13) crashes:

Internal error: Internal error: Internal error: Failed to retrieve the reflection object in file /var/www/html/src/Endpoints/Generated/GeneratedMutationRemoveAliasFromConnectedNode.php

Stack trace:

Uncaught Error: Internal error: Failed to retrieve the reflection object in phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/Php/PhpClassReflectionExtension.php:576
#0 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/Php/PhpClassReflectionExtension.php(576): ReflectionClass->getTraitAliases()
#1 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/Php/PhpClassReflectionExtension.php(401): PHPStan\Reflection\Php\PhpClassReflectionExtension->findMethodTrait(Object(PHPStan\Reflection\Php\NativeBuiltinMethodReflection))
#2 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/Php/PhpClassReflectionExtension.php(285): PHPStan\Reflection\Php\PhpClassReflectionExtension->createMethod(Object(PHPStan\Reflection\ClassReflection), Object(PHPStan\Reflection\Php\NativeBuiltinMethodReflection), false)
#3 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/ClassReflection.php(330): PHPStan\Reflection\Php\PhpClassReflectionExtension->getNativeMethod(Object(PHPStan\Reflection\ClassReflection), 'setAuthenticati...')
#4 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(295): PHPStan\Reflection\ClassReflection->getNativeMethod('setAuthenticati...')
#5 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(249): PHPStan\Analyser\NodeScopeResolver->processStmtNode(Object(PhpParser\Node\Stmt\ClassMethod), Object(PHPStan\Analyser\MutatingScope), Object(PHPStan\Node\ClassStatementsGatherer))
#6 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(2890): PHPStan\Analyser\NodeScopeResolver->processStmtNodes(Object(PhpParser\Node\Stmt\Trait_), Array, Object(PHPStan\Analyser\MutatingScope), Object(PHPStan\Node\ClassStatementsGatherer))
#7 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(2905): PHPStan\Analyser\NodeScopeResolver->processNodesForTraitUse(Object(PhpParser\Node\Stmt\Trait_), Object(PHPStan\Reflection\ClassReflection), Object(PHPStan\Analyser\MutatingScope), Array, Object(PHPStan\Node\ClassStatementsGatherer))
#8 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(2901): PHPStan\Analyser\NodeScopeResolver->processNodesForTraitUse(Array, Object(PHPStan\Reflection\ClassReflection), Object(PHPStan\Analyser\MutatingScope), Array, Object(PHPStan\Node\ClassStatementsGatherer))
#9 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(2905): PHPStan\Analyser\NodeScopeResolver->processNodesForTraitUse(Object(PhpParser\Node\Stmt\Namespace_), Object(PHPStan\Reflection\ClassReflection), Object(PHPStan\Analyser\MutatingScope), Array, Object(PHPStan\Node\ClassStatementsGatherer))
#10 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(2853): PHPStan\Analyser\NodeScopeResolver->processNodesForTraitUse(Array, Object(PHPStan\Reflection\ClassReflection), Object(PHPStan\Analyser\MutatingScope), Array, Object(PHPStan\Node\ClassStatementsGatherer))
#11 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(597): PHPStan\Analyser\NodeScopeResolver->processTraitUse(Object(PhpParser\Node\Stmt\TraitUse), Object(PHPStan\Analyser\MutatingScope), Object(PHPStan\Node\ClassStatementsGatherer))
#12 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(249): PHPStan\Analyser\NodeScopeResolver->processStmtNode(Object(PhpParser\Node\Stmt\TraitUse), Object(PHPStan\Analyser\MutatingScope), Object(PHPStan\Node\ClassStatementsGatherer))
#13 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(2890): PHPStan\Analyser\NodeScopeResolver->processStmtNodes(Object(PhpParser\Node\Stmt\Trait_), Array, Object(PHPStan\Analyser\MutatingScope), Object(PHPStan\Node\ClassStatementsGatherer))
#14 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(2905): PHPStan\Analyser\NodeScopeResolver->processNodesForTraitUse(Object(PhpParser\Node\Stmt\Trait_), Object(PHPStan\Reflection\ClassReflection), Object(PHPStan\Analyser\MutatingScope), Array, Object(PHPStan\Node\ClassStatementsGatherer))
#15 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(2901): PHPStan\Analyser\NodeScopeResolver->processNodesForTraitUse(Array, Object(PHPStan\Reflection\ClassReflection), Object(PHPStan\Analyser\MutatingScope), Array, Object(PHPStan\Node\ClassStatementsGatherer))
#16 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(2905): PHPStan\Analyser\NodeScopeResolver->processNodesForTraitUse(Object(PhpParser\Node\Stmt\Namespace_), Object(PHPStan\Reflection\ClassReflection), Object(PHPStan\Analyser\MutatingScope), Array, Object(PHPStan\Node\ClassStatementsGatherer))
#17 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(2853): PHPStan\Analyser\NodeScopeResolver->processNodesForTraitUse(Array, Object(PHPStan\Reflection\ClassReflection), Object(PHPStan\Analyser\MutatingScope), Array, Object(PHPStan\Node\ClassStatementsGatherer))
#18 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(597): PHPStan\Analyser\NodeScopeResolver->processTraitUse(Object(PhpParser\Node\Stmt\TraitUse), Object(PHPStan\Analyser\MutatingScope), Object(PHPStan\Node\ClassStatementsGatherer))
#19 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(249): PHPStan\Analyser\NodeScopeResolver->processStmtNode(Object(PhpParser\Node\Stmt\TraitUse), Object(PHPStan\Analyser\MutatingScope), Object(PHPStan\Node\ClassStatementsGatherer))
#20 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(2890): PHPStan\Analyser\NodeScopeResolver->processStmtNodes(Object(PhpParser\Node\Stmt\Trait_), Array, Object(PHPStan\Analyser\MutatingScope), Object(PHPStan\Node\ClassStatementsGatherer))
#21 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(2905): PHPStan\Analyser\NodeScopeResolver->processNodesForTraitUse(Object(PhpParser\Node\Stmt\Trait_), Object(PHPStan\Reflection\ClassReflection), Object(PHPStan\Analyser\MutatingScope), Array, Object(PHPStan\Node\ClassStatementsGatherer))
#22 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(2901): PHPStan\Analyser\NodeScopeResolver->processNodesForTraitUse(Array, Object(PHPStan\Reflection\ClassReflection), Object(PHPStan\Analyser\MutatingScope), Array, Object(PHPStan\Node\ClassStatementsGatherer))
#23 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(2905): PHPStan\Analyser\NodeScopeResolver->processNodesForTraitUse(Object(PhpParser\Node\Stmt\Namespace_), Object(PHPStan\Reflection\ClassReflection), Object(PHPStan\Analyser\MutatingScope), Array, Object(PHPStan\Node\ClassStatementsGatherer))
#24 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(2853): PHPStan\Analyser\NodeScopeResolver->processNodesForTraitUse(Array, Object(PHPStan\Reflection\ClassReflection), Object(PHPStan\Analyser\MutatingScope), Array, Object(PHPStan\Node\ClassStatementsGatherer))
#25 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(597): PHPStan\Analyser\NodeScopeResolver->processTraitUse(Object(PhpParser\Node\Stmt\TraitUse), Object(PHPStan\Analyser\MutatingScope), Object(PHPStan\Node\ClassStatementsGatherer))
#26 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(249): PHPStan\Analyser\NodeScopeResolver->processStmtNode(Object(PhpParser\Node\Stmt\TraitUse), Object(PHPStan\Analyser\MutatingScope), Object(PHPStan\Node\ClassStatementsGatherer))
#27 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(498): PHPStan\Analyser\NodeScopeResolver->processStmtNodes(Object(PhpParser\Node\Stmt\Class_), Array, Object(PHPStan\Analyser\MutatingScope), Object(PHPStan\Node\ClassStatementsGatherer))
#28 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(249): PHPStan\Analyser\NodeScopeResolver->processStmtNode(Object(PhpParser\Node\Stmt\Class_), Object(PHPStan\Analyser\MutatingScope), Object(Closure))
#29 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(464): PHPStan\Analyser\NodeScopeResolver->processStmtNodes(Object(PhpParser\Node\Stmt\Namespace_), Array, Object(PHPStan\Analyser\MutatingScope), Object(Closure))
#30 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(217): PHPStan\Analyser\NodeScopeResolver->processStmtNode(Object(PhpParser\Node\Stmt\Namespace_), Object(PHPStan\Analyser\MutatingScope), Object(Closure))
#31 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/FileAnalyser.php(164): PHPStan\Analyser\NodeScopeResolver->processNodes(Array, Object(PHPStan\Analyser\MutatingScope), Object(Closure))
#32 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/Analyser.php(52): PHPStan\Analyser\FileAnalyser->analyseFile('/var/www/html/s...', Array, Object(PHPStan\Rules\Registry), NULL)
#33 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Command/AnalyserRunner.php(56): PHPStan\Analyser\Analyser->analyse(Array, Object(Closure), NULL, true, Array)
#34 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Command/AnalyseApplication.php(146): PHPStan\Command\AnalyserRunner->runAnalyser(Array, Array, Object(Closure), NULL, true, true, '/var/www/html/p...', NULL, NULL, Object(_PHPStan_9b5387833\Symfony\Component\Console\Input\ArgvInput))
#35 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Command/AnalyseApplication.php(78): PHPStan\Command\AnalyseApplication->runAnalyser(Array, Array, true, '/var/www/html/p...', Object(PHPStan\Command\Symfony\SymfonyOutput), Object(PHPStan\Command\Symfony\SymfonyOutput), Object(_PHPStan_9b5387833\Symfony\Component\Console\Input\ArgvInput))
#36 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Command/AnalyseCommand.php(144): PHPStan\Command\AnalyseApplication->analyse(Array, false, Object(PHPStan\Command\Symfony\SymfonyOutput), Object(PHPStan\Command\Symfony\SymfonyOutput), false, true, '/var/www/html/p...', Array, Object(_PHPStan_9b5387833\Symfony\Component\Console\Input\ArgvInput))
#37 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Command/Command.php(228): PHPStan\Command\AnalyseCommand->execute(Object(_PHPStan_9b5387833\Symfony\Component\Console\Input\ArgvInput), Object(_PHPStan_9b5387833\Symfony\Component\Console\Output\ConsoleOutput))
#38 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Application.php(856): _PHPStan_9b5387833\Symfony\Component\Console\Command\Command->run(Object(_PHPStan_9b5387833\Symfony\Component\Console\Input\ArgvInput), Object(_PHPStan_9b5387833\Symfony\Component\Console\Output\ConsoleOutput))
#39 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Application.php(237): _PHPStan_9b5387833\Symfony\Component\Console\Application->doRunCommand(Object(PHPStan\Command\AnalyseCommand), Object(_PHPStan_9b5387833\Symfony\Component\Console\Input\ArgvInput), Object(_PHPStan_9b5387833\Symfony\Component\Console\Output\ConsoleOutput))
#40 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Application.php(138): _PHPStan_9b5387833\Symfony\Component\Console\Application->doRun(Object(_PHPStan_9b5387833\Symfony\Component\Console\Input\ArgvInput), Object(_PHPStan_9b5387833\Symfony\Component\Console\Output\ConsoleOutput))
#41 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/bin/phpstan(82): _PHPStan_9b5387833\Symfony\Component\Console\Application->run()
#42 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/bin/phpstan(83): _PHPStan_9b5387833\{closure}()
#43 /var/www/html/vendor/phpstan/phpstan/phpstan(8): require('phar:///var/www...')
#44 {main}

Code snippet that reproduces the problem

File from error:

<?php

/**
 * This file was automatically generated by generate:mutationEndpoints
 */

declare(strict_types=1);

namespace Slant\Normalizer\Endpoints\Generated;

use Firehed\API\Interfaces\HandlesOwnErrorsInterface;
use Slant\Normalizer\Attributes\ContextInterface;
use Slant\Normalizer\Endpoints\AuthenticatedEndpointInterface;
use Slant\Normalizer\Endpoints\Traits\GeneratedMutationEndpoint;

class GeneratedMutationRemoveAliasFromConnectedNode implements
    AuthenticatedEndpointInterface,
    HandlesOwnErrorsInterface
{
    use GeneratedMutationEndpoint {
        __construct as traitConstructor;
    }

    public function __construct(ContextInterface $context)
    {
        $this->traitConstructor($context, new \Slant\Normalizer\Mutations\RemoveAliasFromConnectedNode());
    }

    // Not done by provided mutation because this is used in a static
    // context (and the definition hasn't been updated)
    public function getUri(): string
    {
        return '/mutations/remove_alias_from_connected_node$';
    }
}

I can provide the trait in question if it's relevant, but my guess is the problem is around the aliased trait method import.

Expected output

No error/no crash. This analyzes and runs fine in 8.0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions