Bug report
This code has a copy paste error, the 2nd phpdoc re-declares the wrong variable:
/** @var array{from: string, to: string} $dates */
$dates = ($_GET['dates'] ?? []) ?: throw new UserError('No Dates selected');
if (empty($dates['from']) || empty($dates['to'])) {
throw new UserError('Dates not selected');
}
/** @var array{latitude: string, longitude: string} $dates */
$locations = ($_GET['location'] ?? []) ?: throw new UserError('No Location selected');
gives this trace:
-- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Error
-- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Internal error: PHPStan\PhpDoc\TypeNodeResolver::resolveIntersectionTypeNode(): Return value must be of type PHPStan\Type\Type, null returned while analysing file <project_folder>/app/Http/Controllers/Internal/Pweb/HotelBookerController.php
Post the following stack trace to https://github.com/phpstan/phpstan/issues/new?template=Bug_report.yaml:
## phar://<project_folder>/vendor/phpstan/phpstan/phpstan.phar/src/PhpDoc/TypeNodeResolver.php(479)
#0 phar://<project_folder>/vendor/phpstan/phpstan/phpstan.phar/src/PhpDoc/TypeNodeResolver.php(167): PHPStan\PhpDoc\TypeNodeResolver->resolveIntersectionTypeNode()
#1 phar://<project_folder>/vendor/phpstan/phpstan/phpstan.phar/src/Rules/PhpDoc/VarTagTypeRuleHelper.php(199): PHPStan\PhpDoc\TypeNodeResolver->resolve()
#2 phar://<project_folder>/vendor/phpstan/phpstan/phpstan.phar/src/Rules/PhpDoc/VarTagTypeRuleHelper.php(191): PHPStan\Rules\PhpDoc\VarTagTypeRuleHelper->isSuperTypeOfVarType()
#3 phar://<project_folder>/vendor/phpstan/phpstan/phpstan.phar/src/Rules/PhpDoc/VarTagTypeRuleHelper.php(157): PHPStan\Rules\PhpDoc\VarTagTypeRuleHelper->isValidSuperType()
#4 phar://<project_folder>/vendor/phpstan/phpstan/phpstan.phar/src/Rules/PhpDoc/VarTagTypeRuleHelper.php(102): PHPStan\Rules\PhpDoc\VarTagTypeRuleHelper->isValidSuperTypeOfExpr()
#5 phar://<project_folder>/vendor/phpstan/phpstan/phpstan.phar/src/Rules/PhpDoc/VarTagChangedExpressionTypeRule.php(28): PHPStan\Rules\PhpDoc\VarTagTypeRuleHelper->checkExprType()
#6 phar://<project_folder>/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/FileAnalyserCallback.php(129): PHPStan\Rules\PhpDoc\VarTagChangedExpressionTypeRule->processNode()
#7 phar://<project_folder>/vendor/phpstan/phpstan/phpstan.phar/src/Node/ClassStatementsGatherer.php(118): PHPStan\Analyser\FileAnalyserCallback->__invoke()
#8 phar://<project_folder>/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(670): PHPStan\Node\ClassStatementsGatherer->__invoke()
#9 phar://<project_folder>/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/Fiber/FiberNodeScopeResolver.php(37): PHPStan\Analyser\NodeScopeResolver::{closure:PHPStan\Analyser\NodeScopeResolver::processStmtNode():669}()
#10 [internal function]: PHPStan\Analyser\Fiber\FiberNodeScopeResolver::{closure:PHPStan\Analyser\Fiber\FiberNodeScopeResolver::callNodeCallback():34}()
#11 phar://<project_folder>/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/Fiber/FiberNodeScopeResolver.php(32): Fiber->resume()
#12 phar://<project_folder>/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(2902): PHPStan\Analyser\Fiber\FiberNodeScopeResolver->callNodeCallback()
#13 phar://<project_folder>/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(512): PHPStan\Analyser\NodeScopeResolver->processStmtVarAnnotation()
#14 phar://<project_folder>/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(470): PHPStan\Analyser\NodeScopeResolver->processStmtNode()
#15 phar://<project_folder>/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(448): PHPStan\Analyser\NodeScopeResolver->processStmtNodesInternalWithoutFlushingPendingFibers()
#16 phar://<project_folder>/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(669): PHPStan\Analyser\NodeScopeResolver->processStmtNodesInternal()
#17 phar://<project_folder>/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(470): PHPStan\Analyser\NodeScopeResolver->processStmtNode()
#18 phar://<project_folder>/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(448): PHPStan\Analyser\NodeScopeResolver->processStmtNodesInternalWithoutFlushingPendingFibers()
#19 phar://<project_folder>/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(854): PHPStan\Analyser\NodeScopeResolver->processStmtNodesInternal()
#20 phar://<project_folder>/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(470): PHPStan\Analyser\NodeScopeResolver->processStmtNode()
#21 phar://<project_folder>/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(448): PHPStan\Analyser\NodeScopeResolver->processStmtNodesInternalWithoutFlushingPendingFibers()
#22 phar://<project_folder>/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(807): PHPStan\Analyser\NodeScopeResolver->processStmtNodesInternal()
#23 phar://<project_folder>/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(392): PHPStan\Analyser\NodeScopeResolver->processStmtNode()
#24 phar://<project_folder>/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/FileAnalyser.php(108): PHPStan\Analyser\NodeScopeResolver->processNodes()
#25 phar://<project_folder>/vendor/phpstan/phpstan/phpstan.phar/src/Command/WorkerCommand.php(150): PHPStan\Analyser\FileAnalyser->analyseFile()
#26 phar://<project_folder>/vendor/phpstan/phpstan/phpstan.phar/vendor/evenement/evenement/src/EventEmitterTrait.php(111): PHPStan\Command\WorkerCommand::{closure:PHPStan\Command\WorkerCommand::runWorker():126}()
#27 phar://<project_folder>/vendor/phpstan/phpstan/phpstan.phar/vendor/clue/ndjson-react/src/Decoder.php(117): _PHPStan_c161e9ff7\Evenement\EventEmitter->emit()
#28 phar://<project_folder>/vendor/phpstan/phpstan/phpstan.phar/vendor/evenement/evenement/src/EventEmitterTrait.php(111): _PHPStan_c161e9ff7\Clue\React\NDJson\Decoder->handleData()
#29 phar://<project_folder>/vendor/phpstan/phpstan/phpstan.phar/vendor/react/stream/src/Util.php(62): _PHPStan_c161e9ff7\Evenement\EventEmitter->emit()
#30 phar://<project_folder>/vendor/phpstan/phpstan/phpstan.phar/vendor/evenement/evenement/src/EventEmitterTrait.php(111): _PHPStan_c161e9ff7\React\Stream\Util::{closure:_PHPStan_c161e9ff7\React\Stream\Util::forwardEvents():61}()
#31 phar://<project_folder>/vendor/phpstan/phpstan/phpstan.phar/vendor/react/stream/src/DuplexResourceStream.php(168): _PHPStan_c161e9ff7\Evenement\EventEmitter->emit()
#32 phar://<project_folder>/vendor/phpstan/phpstan/phpstan.phar/vendor/react/event-loop/src/StreamSelectLoop.php(201): _PHPStan_c161e9ff7\React\Stream\DuplexResourceStream->handleData()
#33 phar://<project_folder>/vendor/phpstan/phpstan/phpstan.phar/vendor/react/event-loop/src/StreamSelectLoop.php(173): _PHPStan_c161e9ff7\React\EventLoop\StreamSelectLoop->waitForStreamActivity()
#34 phar://<project_folder>/vendor/phpstan/phpstan/phpstan.phar/src/Command/WorkerCommand.php(105): _PHPStan_c161e9ff7\React\EventLoop\StreamSelectLoop->run()
#35 phar://<project_folder>/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Command/Command.php(259): PHPStan\Command\WorkerCommand->execute()
#36 phar://<project_folder>/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Application.php(868): _PHPStan_c161e9ff7\Symfony\Component\Console\Command\Command->run()
#37 phar://<project_folder>/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Application.php(261): _PHPStan_c161e9ff7\Symfony\Component\Console\Application->doRunCommand()
#38 phar://<project_folder>/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Application.php(157): _PHPStan_c161e9ff7\Symfony\Component\Console\Application->doRun()
#39 phar://<project_folder>/vendor/phpstan/phpstan/phpstan.phar/bin/phpstan(106): _PHPStan_c161e9ff7\Symfony\Component\Console\Application->run()
#40 phar://<project_folder>/vendor/phpstan/phpstan/phpstan.phar/bin/phpstan(107): {closure:phar://<project_folder>/vendor/phpstan/phpstan/phpstan.phar/bin/phpstan:16}()
#41 <project_folder>/vendor/phpstan/phpstan/phpstan(8): require('...')
#42 <project_folder>/vendor/bin/phpstan(119): include('...')
#43 {main}
Code snippet that reproduces the problem
https://phpstan.org/r/e9ff7810-b976-459c-a4f9-c18476633f8f
Expected output
one small warning about not re-declaring a variable
Did PHPStan help you today? Did it make you happy in any way?
every day
Bug report
This code has a copy paste error, the 2nd phpdoc re-declares the wrong variable:
gives this trace:
Code snippet that reproduces the problem
https://phpstan.org/r/e9ff7810-b976-459c-a4f9-c18476633f8f
Expected output
one small warning about not re-declaring a variable
Did PHPStan help you today? Did it make you happy in any way?
every day