Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Firehed opened this issue Nov 8, 2021 · 15 comments
Closed

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

Firehed opened this issue Nov 8, 2021 · 15 comments

Comments

@Firehed
Copy link
Contributor

Firehed commented Nov 8, 2021

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.

@mergeable
Copy link

mergeable bot commented Nov 8, 2021

This bug report is missing a link to reproduction on phpstan.org.

It will most likely be closed after manual review.

@Firehed Firehed changed the title Failed to retrieve the reflection object (PHP 8.1 RC) Internal error: Failed to retrieve the reflection object (PHP 8.1 RC) Nov 8, 2021
@ondrejmirtes
Copy link
Member

Hi, I need a small reproducing repository to understand what's going on.

@edubacco
Copy link

Hi, as I found the same bug, I've created a small repo useful to reproduce it:
https://github.com/edubacco/phpstan-bug-5954-php81

edubacco added a commit to edubacco/phpstan-bug-5954-php81 that referenced this issue Nov 14, 2021
@Firehed
Copy link
Contributor Author

Firehed commented Nov 15, 2021

Thanks @edubacco - I was having trouble boiling down my original issue into a reproduce case, glad you were able to find one!

@1thew
Copy link

1thew commented Nov 16, 2021

hi all. I have laravel 8, php8.1 rc5.
i see this error too. If necessary, I will give the code. Nothing is ordinary there. Plain OOP, inheritance and traits
It debug ouput:
/var/www/html/app/Repositories/RailLocator/RailLocatorDislocationRepository.php 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(252): PHPStan\Reflection\Php\PhpClassReflectionExtension->createMethod(Object(PHPStan\Reflection\ClassReflection), Object(PHPStan\Reflection\Php\NativeBuiltinMethodReflection), true) #3 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/ClassReflection.php(309): PHPStan\Reflection\Php\PhpClassReflectionExtension->getMethod(Object(PHPStan\Reflection\ClassReflection), 'whereHas') #4 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Type/ObjectType.php(452): PHPStan\Reflection\ClassReflection->getMethod('whereHas', Object(PHPStan\Analyser\OutOfClassScope)) #5 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Type/ObjectType.php(429): PHPStan\Type\ObjectType->getUnresolvedMethodPrototype('whereHas', Object(PHPStan\Analyser\OutOfClassScope)) #6 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/Mixin/MixinMethodsClassReflectionExtension.php(44): PHPStan\Type\ObjectType->getMethod('whereHas', Object(PHPStan\Analyser\OutOfClassScope)) #7 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/Mixin/MixinMethodsClassReflectionExtension.php(24): PHPStan\Reflection\Mixin\MixinMethodsClassReflectionExtension->findMethod(Object(PHPStan\Reflection\ClassReflection), 'whereHas') #8 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/ClassReflection.php(292): PHPStan\Reflection\Mixin\MixinMethodsClassReflectionExtension->hasMethod(Object(PHPStan\Reflection\ClassReflection), 'whereHas') #9 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Type/ObjectType.php(419): PHPStan\Reflection\ClassReflection->hasMethod('whereHas') #10 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php(3311): PHPStan\Type\ObjectType->hasMethod('whereHas') #11 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php(3324): PHPStan\Analyser\MutatingScope->getMethodReflection(Object(PHPStan\Type\ObjectType), 'whereHas') #12 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php(1531): PHPStan\Analyser\MutatingScope->methodCallReturnType(Object(PHPStan\Type\ObjectType), 'whereHas', Object(PhpParser\Node\Expr\MethodCall)) #13 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php(1537): PHPStan\Analyser\MutatingScope->PHPStan\Analyser\{closure}() #14 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php(445): PHPStan\Analyser\MutatingScope->resolveType(Object(PhpParser\Node\Expr\MethodCall)) #15 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(1314): PHPStan\Analyser\MutatingScope->getType(Object(PhpParser\Node\Expr\MethodCall)) #16 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(450): PHPStan\Analyser\NodeScopeResolver->findEarlyTerminatingExpr(Object(PhpParser\Node\Expr\MethodCall), Object(PHPStan\Analyser\MutatingScope)) #17 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(249): PHPStan\Analyser\NodeScopeResolver->processStmtNode(Object(PhpParser\Node\Stmt\Expression), Object(PHPStan\Analyser\MutatingScope), Object(Closure)) #18 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(540): PHPStan\Analyser\NodeScopeResolver->processStmtNodes(Object(PhpParser\Node\Stmt\If_), Array, Object(PHPStan\Analyser\MutatingScope), Object(Closure)) #19 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(249): PHPStan\Analyser\NodeScopeResolver->processStmtNode(Object(PhpParser\Node\Stmt\If_), Object(PHPStan\Analyser\MutatingScope), Object(Closure)) #20 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(414): PHPStan\Analyser\NodeScopeResolver->processStmtNodes(Object(PhpParser\Node\Stmt\ClassMethod), Array, Object(PHPStan\Analyser\MutatingScope), Object(Closure)) #21 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)) #22 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)) #23 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)) #24 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)) #25 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)) #26 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)) #27 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/Analyser.php(52): PHPStan\Analyser\FileAnalyser->analyseFile('/var/www/html/a...', Array, Object(PHPStan\Rules\Registry), NULL) #28 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Command/AnalyserRunner.php(56): PHPStan\Analyser\Analyser->analyse(Array, Object(Closure), NULL, true, Array) #29 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_9488d3497\Symfony\Component\Console\Input\ArgvInput)) #30 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_9488d3497\Symfony\Component\Console\Input\ArgvInput)) #31 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_9488d3497\Symfony\Component\Console\Input\ArgvInput)) #32 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Command/Command.php(228): PHPStan\Command\AnalyseCommand->execute(Object(_PHPStan_9488d3497\Symfony\Component\Console\Input\ArgvInput), Object(_PHPStan_9488d3497\Symfony\Component\Console\Output\ConsoleOutput)) #33 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Application.php(856): _PHPStan_9488d3497\Symfony\Component\Console\Command\Command->run(Object(_PHPStan_9488d3497\Symfony\Component\Console\Input\ArgvInput), Object(_PHPStan_9488d3497\Symfony\Component\Console\Output\ConsoleOutput)) #34 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Application.php(237): _PHPStan_9488d3497\Symfony\Component\Console\Application->doRunCommand(Object(PHPStan\Command\AnalyseCommand), Object(_PHPStan_9488d3497\Symfony\Component\Console\Input\ArgvInput), Object(_PHPStan_9488d3497\Symfony\Component\Console\Output\ConsoleOutput)) #35 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Application.php(138): _PHPStan_9488d3497\Symfony\Component\Console\Application->doRun(Object(_PHPStan_9488d3497\Symfony\Component\Console\Input\ArgvInput), Object(_PHPStan_9488d3497\Symfony\Component\Console\Output\ConsoleOutput)) #36 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/bin/phpstan(82): _PHPStan_9488d3497\Symfony\Component\Console\Application->run() #37 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/bin/phpstan(83): _PHPStan_9488d3497\{closure}() #38 /var/www/html/vendor/phpstan/phpstan/phpstan(8): require('phar:///var/www...') #39 {main}

@ondrejmirtes
Copy link
Member

This is definitely PHP 8.1 bug (can you reproduce that on PHP 8.0 or not?), it's a matter of isolating that to a small piece of PHP code and reporting that to https://bugs.php.net/.

@1thew
Copy link

1thew commented Nov 16, 2021

The phpstun problem appeared only after switching to php 8.1
And this problem repeats itself in completely different code. I have php81 on 4 projects - each problem

@1thew
Copy link

1thew commented Nov 16, 2021

But I'm not surprised.
I had to include a reboot mechanism in FPM. Because the php-children-processes began to fall.

@ondrejmirtes
Copy link
Member

I wasn't able to reproduce this with a simple PHP script, but the crashing code in question is supposed to fix a different PHP bug that should no longer happen on PHP 8.0+, so I just wrote an if statement around it: phpstan/phpstan-src@6573959

@ondrejmirtes
Copy link
Member

Please test PHPStan's dev-master to see if it fixes your problem.

@1thew
Copy link

1thew commented Nov 17, 2021

@ondrejmirtes
I checked - there are fewer alerts. 1 alert on project. It was about 30
It new log:
/var/www/html/app/Repositories/AbstractRepositoryWithFilter.php 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(252): PHPStan\Reflection\Php\PhpClassReflectionExtension->createMethod(Object(PHPStan\Reflection\ClassReflection), Object(PHPStan\Reflection\Php\NativeBuiltinMethodReflection), true) #3 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/ClassReflection.php(309): PHPStan\Reflection\Php\PhpClassReflectionExtension->getMethod(Object(PHPStan\Reflection\ClassReflection), 'when') #4 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Type/ObjectType.php(452): PHPStan\Reflection\ClassReflection->getMethod('when', Object(PHPStan\Analyser\MutatingScope)) #5 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Type/UnionType.php(258): PHPStan\Type\ObjectType->getUnresolvedMethodPrototype('when', Object(PHPStan\Analyser\MutatingScope)) #6 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Type/UnionType.php(249): PHPStan\Type\UnionType->getUnresolvedMethodPrototype('when', Object(PHPStan\Analyser\MutatingScope)) #7 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php(3387): PHPStan\Type\UnionType->getMethod('when', Object(PHPStan\Analyser\MutatingScope)) #8 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php(3397): PHPStan\Analyser\MutatingScope->getMethodReflection(Object(PHPStan\Type\UnionType), 'when') #9 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php(1591): PHPStan\Analyser\MutatingScope->methodCallReturnType(Object(PHPStan\Type\UnionType), 'when', Object(PhpParser\Node\Expr\MethodCall)) #10 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php(1597): PHPStan\Analyser\MutatingScope->PHPStan\Analyser\{closure}() #11 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php(445): PHPStan\Analyser\MutatingScope->resolveType(Object(PhpParser\Node\Expr\MethodCall)) #12 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php(1591): PHPStan\Analyser\MutatingScope->getType(Object(PhpParser\Node\Expr\MethodCall)) #13 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php(1597): PHPStan\Analyser\MutatingScope->PHPStan\Analyser\{closure}() #14 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php(445): PHPStan\Analyser\MutatingScope->resolveType(Object(PhpParser\Node\Expr\MethodCall)) #15 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php(1591): PHPStan\Analyser\MutatingScope->getType(Object(PhpParser\Node\Expr\MethodCall)) #16 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php(1597): PHPStan\Analyser\MutatingScope->PHPStan\Analyser\{closure}() #17 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php(445): PHPStan\Analyser\MutatingScope->resolveType(Object(PhpParser\Node\Expr\MethodCall)) #18 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(1318): PHPStan\Analyser\MutatingScope->getType(Object(PhpParser\Node\Expr\MethodCall)) #19 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(454): PHPStan\Analyser\NodeScopeResolver->findEarlyTerminatingExpr(Object(PhpParser\Node\Expr\MethodCall), Object(PHPStan\Analyser\MutatingScope)) #20 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(253): PHPStan\Analyser\NodeScopeResolver->processStmtNode(Object(PhpParser\Node\Stmt\Expression), Object(PHPStan\Analyser\MutatingScope), Object(Closure)) #21 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(418): PHPStan\Analyser\NodeScopeResolver->processStmtNodes(Object(PhpParser\Node\Stmt\ClassMethod), Array, Object(PHPStan\Analyser\MutatingScope), Object(Closure)) #22 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(253): PHPStan\Analyser\NodeScopeResolver->processStmtNode(Object(PhpParser\Node\Stmt\ClassMethod), Object(PHPStan\Analyser\MutatingScope), Object(PHPStan\Node\ClassStatementsGatherer)) #23 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(2908): PHPStan\Analyser\NodeScopeResolver->processStmtNodes(Object(PhpParser\Node\Stmt\Trait_), Array, Object(PHPStan\Analyser\MutatingScope), Object(PHPStan\Node\ClassStatementsGatherer)) #24 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(2923): PHPStan\Analyser\NodeScopeResolver->processNodesForTraitUse(Object(PhpParser\Node\Stmt\Trait_), 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(2919): PHPStan\Analyser\NodeScopeResolver->processNodesForTraitUse(Array, Object(PHPStan\Reflection\ClassReflection), Object(PHPStan\Analyser\MutatingScope), Array, Object(PHPStan\Node\ClassStatementsGatherer)) #26 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(2923): PHPStan\Analyser\NodeScopeResolver->processNodesForTraitUse(Object(PhpParser\Node\Stmt\Namespace_), Object(PHPStan\Reflection\ClassReflection), Object(PHPStan\Analyser\MutatingScope), Array, Object(PHPStan\Node\ClassStatementsGatherer)) #27 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(2871): PHPStan\Analyser\NodeScopeResolver->processNodesForTraitUse(Array, Object(PHPStan\Reflection\ClassReflection), Object(PHPStan\Analyser\MutatingScope), Array, Object(PHPStan\Node\ClassStatementsGatherer)) #28 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(601): PHPStan\Analyser\NodeScopeResolver->processTraitUse(Object(PhpParser\Node\Stmt\TraitUse), Object(PHPStan\Analyser\MutatingScope), Object(PHPStan\Node\ClassStatementsGatherer)) #29 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(253): PHPStan\Analyser\NodeScopeResolver->processStmtNode(Object(PhpParser\Node\Stmt\TraitUse), Object(PHPStan\Analyser\MutatingScope), Object(PHPStan\Node\ClassStatementsGatherer)) #30 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(2908): PHPStan\Analyser\NodeScopeResolver->processStmtNodes(Object(PhpParser\Node\Stmt\Trait_), Array, Object(PHPStan\Analyser\MutatingScope), Object(PHPStan\Node\ClassStatementsGatherer)) #31 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(2923): PHPStan\Analyser\NodeScopeResolver->processNodesForTraitUse(Object(PhpParser\Node\Stmt\Trait_), Object(PHPStan\Reflection\ClassReflection), Object(PHPStan\Analyser\MutatingScope), Array, Object(PHPStan\Node\ClassStatementsGatherer)) #32 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(2919): PHPStan\Analyser\NodeScopeResolver->processNodesForTraitUse(Array, Object(PHPStan\Reflection\ClassReflection), Object(PHPStan\Analyser\MutatingScope), Array, Object(PHPStan\Node\ClassStatementsGatherer)) #33 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(2923): PHPStan\Analyser\NodeScopeResolver->processNodesForTraitUse(Object(PhpParser\Node\Stmt\Namespace_), Object(PHPStan\Reflection\ClassReflection), Object(PHPStan\Analyser\MutatingScope), Array, Object(PHPStan\Node\ClassStatementsGatherer)) #34 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(2871): PHPStan\Analyser\NodeScopeResolver->processNodesForTraitUse(Array, Object(PHPStan\Reflection\ClassReflection), Object(PHPStan\Analyser\MutatingScope), Array, Object(PHPStan\Node\ClassStatementsGatherer)) #35 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(601): PHPStan\Analyser\NodeScopeResolver->processTraitUse(Object(PhpParser\Node\Stmt\TraitUse), Object(PHPStan\Analyser\MutatingScope), Object(PHPStan\Node\ClassStatementsGatherer)) #36 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(253): PHPStan\Analyser\NodeScopeResolver->processStmtNode(Object(PhpParser\Node\Stmt\TraitUse), Object(PHPStan\Analyser\MutatingScope), Object(PHPStan\Node\ClassStatementsGatherer)) #37 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(502): PHPStan\Analyser\NodeScopeResolver->processStmtNodes(Object(PhpParser\Node\Stmt\Class_), Array, Object(PHPStan\Analyser\MutatingScope), Object(PHPStan\Node\ClassStatementsGatherer)) #38 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(253): PHPStan\Analyser\NodeScopeResolver->processStmtNode(Object(PhpParser\Node\Stmt\Class_), Object(PHPStan\Analyser\MutatingScope), Object(Closure)) #39 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(468): PHPStan\Analyser\NodeScopeResolver->processStmtNodes(Object(PhpParser\Node\Stmt\Namespace_), Array, Object(PHPStan\Analyser\MutatingScope), Object(Closure)) #40 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(221): PHPStan\Analyser\NodeScopeResolver->processStmtNode(Object(PhpParser\Node\Stmt\Namespace_), Object(PHPStan\Analyser\MutatingScope), Object(Closure)) #41 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)) #42 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/Analyser.php(52): PHPStan\Analyser\FileAnalyser->analyseFile('/var/www/html/a...', Array, Object(PHPStan\Rules\Registry), NULL) #43 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Command/AnalyserRunner.php(56): PHPStan\Analyser\Analyser->analyse(Array, Object(Closure), NULL, true, Array) #44 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_53eb2e33a\Symfony\Component\Console\Input\ArgvInput)) #45 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_53eb2e33a\Symfony\Component\Console\Input\ArgvInput)) #46 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_53eb2e33a\Symfony\Component\Console\Input\ArgvInput)) #47 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Command/Command.php(228): PHPStan\Command\AnalyseCommand->execute(Object(_PHPStan_53eb2e33a\Symfony\Component\Console\Input\ArgvInput), Object(_PHPStan_53eb2e33a\Symfony\Component\Console\Output\ConsoleOutput)) #48 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Application.php(856): _PHPStan_53eb2e33a\Symfony\Component\Console\Command\Command->run(Object(_PHPStan_53eb2e33a\Symfony\Component\Console\Input\ArgvInput), Object(_PHPStan_53eb2e33a\Symfony\Component\Console\Output\ConsoleOutput)) #49 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Application.php(237): _PHPStan_53eb2e33a\Symfony\Component\Console\Application->doRunCommand(Object(PHPStan\Command\AnalyseCommand), Object(_PHPStan_53eb2e33a\Symfony\Component\Console\Input\ArgvInput), Object(_PHPStan_53eb2e33a\Symfony\Component\Console\Output\ConsoleOutput)) #50 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Application.php(138): _PHPStan_53eb2e33a\Symfony\Component\Console\Application->doRun(Object(_PHPStan_53eb2e33a\Symfony\Component\Console\Input\ArgvInput), Object(_PHPStan_53eb2e33a\Symfony\Component\Console\Output\ConsoleOutput)) #51 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/bin/phpstan(82): _PHPStan_53eb2e33a\Symfony\Component\Console\Application->run() #52 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/bin/phpstan(83): _PHPStan_53eb2e33a\{closure}() #53 /var/www/html/vendor/phpstan/phpstan/phpstan(8): require('phar:///var/www...') #54 {main} /var/www/html #

@1thew
Copy link

1thew commented Nov 17, 2021

if I'm off in class "use FilterTrait" - phpstan works great!
I found a function that is causing problems. Code simplified. It laravel 8

<?php

namespace App\Repositories;

use App\Repositories\ValueObjects\Sort;
use Illuminate\Database\Eloquent\Builder;

trait TestTrait
{
    protected function createResponseDto(
        Builder|\Illuminate\Database\Query\Builder $builder,
        ?Sort $sort
    ): void {
        $builder
            ->when(null !== $sort, function (
                Builder|\Illuminate\Database\Query\Builder $query
            ) use ($sort) {
                return $query->orderBy($sort->getField(), $sort->getMethod());
            });
    }
}

Any inclusion of a trait in any class - breaks phpstan

@ondrejmirtes
Copy link
Member

Reported in PHP: https://bugs.php.net/bug.php?id=81630

@ondrejmirtes
Copy link
Member

Fixed: php/php-src@6641e3b

@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 19, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants