Skip to content

Internal error: Argument 2 passed to PHPStan\Type\FileTypeMapper::getNameScopeKey() must be of the type string or null, bool given #14432

@zhuangyy

Description

@zhuangyy

Bug report

Previously, my workflow functioned flawlessly using version 2.1.31. However, starting with version 2.1.32 through the latest iteration (2.1.46), executing identical commands with the exact same codebase now triggers the following error:

2602/2602 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100% 1 sec


 Error

 Internal error: Argument 2 passed to PHPStan\Type\FileTypeMapper::getNameScopeKey() must be of the type string or null, bool given, called in
 phar:///root/phpstan.phar-2.1.46/src/Type/FileTypeMapper.php on line 379 while analysing file /usr/local/inc/elements/element_upload_pkcs7.inc
 Post the following stack trace to https://github.com/phpstan/phpstan/issues/new?template=Bug_report.yaml:
 ## phar:///root/phpstan.phar-2.1.46/src/Type/FileTypeMapper.php(598)
 #0 phar:///root/phpstan.phar-2.1.46/src/Type/FileTypeMapper.php(379): PHPStan\Type\FileTypeMapper->getNameScopeKey('phar:///root/ph...', false, NULL, false)
 #1 phar:///root/phpstan.phar-2.1.46/src/Type/FileTypeMapper.php(583): PHPStan\Type\FileTypeMapper->PHPStan\Type\{closure}(Object(PhpParser\Node\Stmt\Use_))
 #2 phar:///root/phpstan.phar-2.1.46/src/Type/FileTypeMapper.php(594): PHPStan\Type\FileTypeMapper->processNodes(Object(PhpParser\Node\Stmt\Use_), Object(Closure), Object(Closure))
 #3 phar:///root/phpstan.phar-2.1.46/src/Type/FileTypeMapper.php(519): PHPStan\Type\FileTypeMapper->processNodes(Array, Object(Closure), Object(Closure))
 #4 phar:///root/phpstan.phar-2.1.46/src/Type/FileTypeMapper.php(257): PHPStan\Type\FileTypeMapper->createPhpDocNodeMap('phar:///root/ph...', NULL, NULL, Array, 'phar:///root/ph...')
 #5 phar:///root/phpstan.phar-2.1.46/src/Type/FileTypeMapper.php(168): PHPStan\Type\FileTypeMapper->getNameScopeMap('phar:///root/ph...')
 #6 phar:///root/phpstan.phar-2.1.46/src/Type/FileTypeMapper.php(127): PHPStan\Type\FileTypeMapper->getNameScope('phar:///root/ph...', NULL, NULL, 'file_exists')
 #7 phar:///root/phpstan.phar-2.1.46/src/Reflection/SignatureMap/NativeFunctionReflectionProvider.php(89): PHPStan\Type\FileTypeMapper->getResolvedPhpDoc('phar:///root/ph...', NULL, NULL,
 'file_exists', '/**\n * Checks w...')
 #8 phar:///root/phpstan.phar-2.1.46/src/Reflection/BetterReflection/BetterReflectionProvider.php(247):
 PHPStan\Reflection\SignatureMap\NativeFunctionReflectionProvider->findFunctionReflection('file_exists')
 #9 phar:///root/phpstan.phar-2.1.46/src/Reflection/ReflectionProvider/MemoizingReflectionProvider.php(67):
 PHPStan\Reflection\BetterReflection\BetterReflectionProvider->getFunction(Object(PhpParser\Node\Name), Object(PHPStan\Analyser\MutatingScope))
 #10 phar:///root/phpstan.phar-2.1.46/src/Analyser/ExprHandler/FuncCallHandler.php(484):
 PHPStan\Reflection\ReflectionProvider\MemoizingReflectionProvider->getFunction(Object(PhpParser\Node\Name), Object(PHPStan\Analyser\MutatingScope))
 #11 phar:///root/phpstan.phar-2.1.46/src/Analyser/MutatingScope.php(732): PHPStan\Analyser\ExprHandler\FuncCallHandler->resolveType(Object(PHPStan\Analyser\MutatingScope),
 Object(PhpParser\Node\Expr\FuncCall))
 #12 phar:///root/phpstan.phar-2.1.46/src/Analyser/MutatingScope.php(668): PHPStan\Analyser\MutatingScope->resolveType('file_exists($f)', Object(PhpParser\Node\Expr\FuncCall))
 #13 phar:///root/phpstan.phar-2.1.46/src/Analyser/NodeScopeResolver.php(884): PHPStan\Analyser\MutatingScope->getType(Object(PhpParser\Node\Expr\FuncCall))
 #14 phar:///root/phpstan.phar-2.1.46/src/Analyser/NodeScopeResolver.php(459): PHPStan\Analyser\NodeScopeResolver->processStmtNode(Object(PhpParser\Node\Stmt\If_),
 Object(PHPStan\Analyser\MutatingScope), Object(PHPStan\Analyser\ExpressionResultStorage), Object(Closure), Object(PHPStan\Analyser\StatementContext))
 #15 phar:///root/phpstan.phar-2.1.46/src/Analyser/NodeScopeResolver.php(437):
 PHPStan\Analyser\NodeScopeResolver->processStmtNodesInternalWithoutFlushingPendingFibers(Object(PhpParser\Node\Stmt\ClassMethod), Array, Object(PHPStan\Analyser\MutatingScope),
 Object(PHPStan\Analyser\ExpressionResultStorage), Object(Closure), Object(PHPStan\Analyser\StatementContext))
 #16 phar:///root/phpstan.phar-2.1.46/src/Analyser/NodeScopeResolver.php(684): PHPStan\Analyser\NodeScopeResolver->processStmtNodesInternal(Object(PhpParser\Node\Stmt\ClassMethod), Array,
 Object(PHPStan\Analyser\MutatingScope), Object(PHPStan\Analyser\ExpressionResultStorage), Object(Closure), Object(PHPStan\Analyser\StatementContext))
 #17 phar:///root/phpstan.phar-2.1.46/src/Analyser/NodeScopeResolver.php(459): PHPStan\Analyser\NodeScopeResolver->processStmtNode(Object(PhpParser\Node\Stmt\ClassMethod),
 Object(PHPStan\Analyser\MutatingScope), Object(PHPStan\Analyser\ExpressionResultStorage), Object(PHPStan\Node\ClassStatementsGatherer), Object(PHPStan\Analyser\StatementContext))
 #18 phar:///root/phpstan.phar-2.1.46/src/Analyser/NodeScopeResolver.php(437):
 PHPStan\Analyser\NodeScopeResolver->processStmtNodesInternalWithoutFlushingPendingFibers(Object(PhpParser\Node\Stmt\Class_), Array, Object(PHPStan\Analyser\MutatingScope),
 Object(PHPStan\Analyser\ExpressionResultStorage), Object(PHPStan\Node\ClassStatementsGatherer), Object(PHPStan\Analyser\StatementContext))
 #19 phar:///root/phpstan.phar-2.1.46/src/Analyser/NodeScopeResolver.php(838): PHPStan\Analyser\NodeScopeResolver->processStmtNodesInternal(Object(PhpParser\Node\Stmt\Class_), Array,
 Object(PHPStan\Analyser\MutatingScope), Object(PHPStan\Analyser\ExpressionResultStorage), Object(PHPStan\Node\ClassStatementsGatherer), Object(PHPStan\Analyser\StatementContext))
 #20 phar:///root/phpstan.phar-2.1.46/src/Analyser/NodeScopeResolver.php(459): PHPStan\Analyser\NodeScopeResolver->processStmtNode(Object(PhpParser\Node\Stmt\Class_),
 Object(PHPStan\Analyser\MutatingScope), Object(PHPStan\Analyser\ExpressionResultStorage), Object(PHPStan\Analyser\FileAnalyserCallback), Object(PHPStan\Analyser\StatementContext))
 #21 phar:///root/phpstan.phar-2.1.46/src/Analyser/NodeScopeResolver.php(437):
 PHPStan\Analyser\NodeScopeResolver->processStmtNodesInternalWithoutFlushingPendingFibers(Object(PhpParser\Node\Stmt\Namespace_), Array, Object(PHPStan\Analyser\MutatingScope),
 Object(PHPStan\Analyser\ExpressionResultStorage), Object(PHPStan\Analyser\FileAnalyserCallback), Object(PHPStan\Analyser\StatementContext))
 #22 phar:///root/phpstan.phar-2.1.46/src/Analyser/NodeScopeResolver.php(791): PHPStan\Analyser\NodeScopeResolver->processStmtNodesInternal(Object(PhpParser\Node\Stmt\Namespace_), Array,
 Object(PHPStan\Analyser\MutatingScope), Object(PHPStan\Analyser\ExpressionResultStorage), Object(PHPStan\Analyser\FileAnalyserCallback), Object(PHPStan\Analyser\StatementContext))
 #23 phar:///root/phpstan.phar-2.1.46/src/Analyser/NodeScopeResolver.php(381): PHPStan\Analyser\NodeScopeResolver->processStmtNode(Object(PhpParser\Node\Stmt\Namespace_),
 Object(PHPStan\Analyser\MutatingScope), Object(PHPStan\Analyser\ExpressionResultStorage), Object(PHPStan\Analyser\FileAnalyserCallback), Object(PHPStan\Analyser\StatementContext))
 #24 phar:///root/phpstan.phar-2.1.46/src/Analyser/FileAnalyser.php(108): PHPStan\Analyser\NodeScopeResolver->processNodes(Array, Object(PHPStan\Analyser\MutatingScope),
 Object(PHPStan\Analyser\FileAnalyserCallback))
 #25 phar:///root/phpstan.phar-2.1.46/src/Command/WorkerCommand.php(149): PHPStan\Analyser\FileAnalyser->analyseFile('/usr/local/inc/...', Array, Object(PHPStan\Rules\LazyRegistry),
 Object(PHPStan\Collectors\Registry), NULL)
 #26 phar:///root/phpstan.phar-2.1.46/vendor/evenement/evenement/src/EventEmitterTrait.php(111): PHPStan\Command\WorkerCommand::PHPStan\Command\{closure}(Array)
 #27 phar:///root/phpstan.phar-2.1.46/vendor/clue/ndjson-react/src/Decoder.php(117): _PHPStan_5a70c2d68\Evenement\EventEmitter->emit('data', Array)
 #28 phar:///root/phpstan.phar-2.1.46/vendor/evenement/evenement/src/EventEmitterTrait.php(111): _PHPStan_5a70c2d68\Clue\React\NDJson\Decoder->handleData(Array)
 #29 phar:///root/phpstan.phar-2.1.46/vendor/react/stream/src/Util.php(62): _PHPStan_5a70c2d68\Evenement\EventEmitter->emit('data', Array)
 #30 phar:///root/phpstan.phar-2.1.46/vendor/evenement/evenement/src/EventEmitterTrait.php(111):
 _PHPStan_5a70c2d68\React\Stream\Util::_PHPStan_5a70c2d68\React\Stream\{closure}('{"action":"anal...')
 #31 phar:///root/phpstan.phar-2.1.46/vendor/react/stream/src/DuplexResourceStream.php(168): _PHPStan_5a70c2d68\Evenement\EventEmitter->emit('data', Array)
 #32 phar:///root/phpstan.phar-2.1.46/vendor/react/event-loop/src/StreamSelectLoop.php(201): _PHPStan_5a70c2d68\React\Stream\DuplexResourceStream->handleData(Resource id #7754)
 #33 phar:///root/phpstan.phar-2.1.46/vendor/react/event-loop/src/StreamSelectLoop.php(173): _PHPStan_5a70c2d68\React\EventLoop\StreamSelectLoop->waitForStreamActivity(NULL)
 #34 phar:///root/phpstan.phar-2.1.46/src/Command/WorkerCommand.php(105): _PHPStan_5a70c2d68\React\EventLoop\StreamSelectLoop->run()
 #35 phar:///root/phpstan.phar-2.1.46/vendor/symfony/console/Command/Command.php(259):
 PHPStan\Command\WorkerCommand->execute(Object(_PHPStan_5a70c2d68\Symfony\Component\Console\Input\ArgvInput), Object(_PHPStan_5a70c2d68\Symfony\Component\Console\Output\ConsoleOutput))
 #36 phar:///root/phpstan.phar-2.1.46/vendor/symfony/console/Application.php(868):
 _PHPStan_5a70c2d68\Symfony\Component\Console\Command\Command->run(Object(_PHPStan_5a70c2d68\Symfony\Component\Console\Input\ArgvInput),
 Object(_PHPStan_5a70c2d68\Symfony\Component\Console\Output\ConsoleOutput))
 #37 phar:///root/phpstan.phar-2.1.46/vendor/symfony/console/Application.php(261): _PHPStan_5a70c2d68\Symfony\Component\Console\Application->doRunCommand(Object(PHPStan\Command\WorkerCommand),
 Object(_PHPStan_5a70c2d68\Symfony\Component\Console\Input\ArgvInput), Object(_PHPStan_5a70c2d68\Symfony\Component\Console\Output\ConsoleOutput))
 #38 phar:///root/phpstan.phar-2.1.46/vendor/symfony/console/Application.php(157):
 _PHPStan_5a70c2d68\Symfony\Component\Console\Application->doRun(Object(_PHPStan_5a70c2d68\Symfony\Component\Console\Input\ArgvInput),
 Object(_PHPStan_5a70c2d68\Symfony\Component\Console\Output\ConsoleOutput))
 #39 phar:///root/phpstan.phar-2.1.46/bin/phpstan(104): _PHPStan_5a70c2d68\Symfony\Component\Console\Application->run()
 #40 phar:///root/phpstan.phar-2.1.46/bin/phpstan(105): _PHPStan_5a70c2d68\{closure}()
 #41 /root/phpstan.phar-2.1.46(7): require('phar:///root/ph...')
 #42 {main}

[ERROR] Found 1 error

⚠️ Result is incomplete because of severe errors. ⚠️
Fix these errors first and then re-run PHPStan
to get all reported errors.

Elapsed time: 0.99 seconds
Used memory: 251.5 MB

Code snippet that reproduces the problem

No response

Expected output

PHPStan operates flawlessly, delivering precise and highly accurate problem diagnostics. Thanks for this wonderful product.

Did PHPStan help you today? Did it make you happy in any way?

No response

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