Skip to content
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

Throw on invalid UnionType with AccessoryTypes #3500

Closed
wants to merge 1 commit into from

Conversation

staabm
Copy link
Contributor

@staabm staabm commented Sep 27, 2024

@phpstan-bot
Copy link
Collaborator

You've opened the pull request against the latest branch 2.0.x. PHPStan 2.0 is not going to be released for months. If your code is relevant on 1.12.x and you want it to be released sooner, please rebase your pull request and change its target to 1.12.x.

@staabm
Copy link
Contributor Author

staabm commented Sep 27, 2024

ha, this change brings up super interessting exception cases :-)

Uncaught PHPStan\ShouldNotHappenException: Cannot create PHPStan\Type\UnionType with: non-empty-array, array{} in C:\dvl\Workspace\phpstan-src-staabm\src\Type\UnionType.php:61
#0 C:\dvl\Workspace\phpstan-src-staabm\src\Type\UnionType.php(73): PHPStan\Type\UnionType::PHPStan\Type\{closure}()
#1 C:\dvl\Workspace\phpstan-src-staabm\src\Type\TypeCombinator.php(369): PHPStan\Type\UnionType->__construct()
#2 C:\dvl\Workspace\phpstan-src-staabm\src\Analyser\ExpressionTypeHolder.php(41): PHPStan\Type\TypeCombinator::union()
#3 C:\dvl\Workspace\phpstan-src-staabm\src\Analyser\MutatingScope.php(4691): PHPStan\Analyser\ExpressionTypeHolder->and()
#4 C:\dvl\Workspace\phpstan-src-staabm\src\Analyser\MutatingScope.php(4565): PHPStan\Analyser\MutatingScope->mergeVariableHolders()
#5 C:\dvl\Workspace\phpstan-src-staabm\src\Analyser\NodeScopeResolver.php(1444): PHPStan\Analyser\MutatingScope->mergeWith()
#6 C:\dvl\Workspace\phpstan-src-staabm\src\Analyser\NodeScopeResolver.php(346): PHPStan\Analyser\NodeScopeResolver->processStmtNode()
#7 C:\dvl\Workspace\phpstan-src-staabm\src\Analyser\NodeScopeResolver.php(682): PHPStan\Analyser\NodeScopeResolver->processStmtNodes()
#8 C:\dvl\Workspace\phpstan-src-staabm\src\Analyser\NodeScopeResolver.php(346): PHPStan\Analyser\NodeScopeResolver->processStmtNode()
#9 C:\dvl\Workspace\phpstan-src-staabm\src\Analyser\NodeScopeResolver.php(871): PHPStan\Analyser\NodeScopeResolver->processStmtNodes()
#10 C:\dvl\Workspace\phpstan-src-staabm\src\Analyser\NodeScopeResolver.php(346): PHPStan\Analyser\NodeScopeResolver->processStmtNode()
#11 C:\dvl\Workspace\phpstan-src-staabm\src\Analyser\NodeScopeResolver.php(839): PHPStan\Analyser\NodeScopeResolver->processStmtNodes()
#12 C:\dvl\Workspace\phpstan-src-staabm\src\Analyser\NodeScopeResolver.php(302): PHPStan\Analyser\NodeScopeResolver->processStmtNode()
#13 C:\dvl\Workspace\phpstan-src-staabm\src\Analyser\FileAnalyser.php(212): PHPStan\Analyser\NodeScopeResolver->processNodes()
#14 C:\dvl\Workspace\phpstan-src-staabm\src\Analyser\Analyser.php(75): PHPStan\Analyser\FileAnalyser->analyseFile()
#15 C:\dvl\Workspace\phpstan-src-staabm\src\Command\AnalyserRunner.php(79): PHPStan\Analyser\Analyser->analyse()
#16 C:\dvl\Workspace\phpstan-src-staabm\src\Command\AnalyseApplication.php(215): PHPStan\Command\AnalyserRunner->runAnalyser()
#17 C:\dvl\Workspace\phpstan-src-staabm\src\Command\AnalyseApplication.php(69): PHPStan\Command\AnalyseApplication->runAnalyser()
#18 C:\dvl\Workspace\phpstan-src-staabm\src\Command\AnalyseCommand.php(283): PHPStan\Command\AnalyseApplication->analyse()
#19 C:\dvl\Workspace\phpstan-src-staabm\vendor\symfony\console\Command\Command.php(298): PHPStan\Command\AnalyseCommand->execute()
#20 C:\dvl\Workspace\phpstan-src-staabm\vendor\symfony\console\Application.php(1040): Symfony\Component\Console\Command\Command->run()
#21 C:\dvl\Workspace\phpstan-src-staabm\vendor\symfony\console\Application.php(301): Symfony\Component\Console\Application->doRunCommand()
#22 C:\dvl\Workspace\phpstan-src-staabm\vendor\symfony\console\Application.php(171): Symfony\Component\Console\Application->doRun()
#23 C:\dvl\Workspace\phpstan-src-staabm\bin\phpstan(165): Symfony\Component\Console\Application->run()
#24 C:\dvl\Workspace\phpstan-src-staabm\bin\phpstan(166): {closure}()
#25 {main}

I think we cannot do it like this

@staabm staabm closed this Sep 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants