phpstan-dba
phpstan-dba copied to clipboard
try reproduce #276
refs https://github.com/staabm/phpstan-dba/issues/276
@xPaw it seems I cannot reproduce your problem reported in https://github.com/staabm/phpstan-dba/issues/276
Hmm, I briefly couldn't reproduce it either while I was shuffling versions, but after clearing cache it seems to reproduce again.
Not sure why it doesn't reproduce in test suite here.
Using 0.2.18 Entire file:
<?php
declare(strict_types=1);
$pdo = new PDO('');
$queries = [
'SELECT 1',
'SELECT 1',
];
foreach( $queries as $test )
{
$test = $pdo->prepare( $test ); // reusing variable
$test->execute();
}
Uncaught staabm\PHPStanDba\DbaException: Unexpected expression type PDOStatement<array{}, array{1: int<-128, 127>, 0: int<-128, 127>}> of class PHPStan\Type\Generic\GenericObjectType in vendor\staabm\phpstan-dba\src\QueryReflection\QuerySimulation.php:117
#0 vendor\staabm\phpstan-dba\src\QueryReflection\QueryReflection.php(189): staabm\PHPStanDba\QueryReflection\QuerySimulation::simulateParamValueType(Object(PHPStan\Type\Generic\GenericObjectType), false)#1 vendor\staabm\phpstan-dba\src\QueryReflection\QueryReflection.php(165): staabm\PHPStanDba\QueryReflection\QueryReflection->resolveQueryStringExpr(Object(PhpParser\Node\Expr\Variable), Object(PHPStan\Analyser\MutatingScope))
#2 vendor\staabm\phpstan-dba\src\QueryReflection\QueryReflection.php(137): staabm\PHPStanDba\QueryReflection\QueryReflection->resolveQueryExpr(Object(PhpParser\Node\Expr\Variable), Object(PHPStan\Analyser\MutatingScope))
#3 vendor\staabm\phpstan-dba\src\QueryReflection\PlaceholderValidation.php(21): staabm\PHPStanDba\QueryReflection\QueryReflection->resolveQueryStrings(Object(PhpParser\Node\Expr\Variable), Object(PHPStan\Analyser\MutatingScope))
#4 vendor\staabm\phpstan-dba\src\Rules\PdoStatementExecuteMethodRule.php(108): staabm\PHPStanDba\QueryReflection\PlaceholderValidation->checkQuery(Object(PhpParser\Node\Expr\Variable), Object(PHPStan\Analyser\MutatingScope), Array)
#5 vendor\staabm\phpstan-dba\src\Rules\PdoStatementExecuteMethodRule.php(55): staabm\PHPStanDba\Rules\PdoStatementExecuteMethodRule->checkErrors(Object(PHPStan\Reflection\ResolvedMethodReflection), Object(PhpParser\Node\Expr\MethodCall), Object(PHPStan\Analyser\MutatingScope))
#6 phar://vendor/phpstan/phpstan/phpstan.phar/src/Analyser/FileAnalyser.php(102): staabm\PHPStanDba\Rules\PdoStatementExecuteMethodRule->processNode(Object(PhpParser\Node\Expr\MethodCall), Object(PHPStan\Analyser\MutatingScope))
#7 phar://vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(2334): PHPStan\Analyser\FileAnalyser->PHPStan\Analyser\{closure}(Object(PhpParser\Node\Expr\MethodCall), Object(PHPStan\Analyser\MutatingScope))
#8 phar://vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(1415): PHPStan\Analyser\NodeScopeResolver->callNodeCallbackWithExpression(Object(Closure), Object(PhpParser\Node\Expr\MethodCall), Object(PHPStan\Analyser\MutatingScope), Object(PHPStan\Analyser\ExpressionContext))
#9 phar://vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(500): PHPStan\Analyser\NodeScopeResolver->processExprNode(Object(PhpParser\Node\Expr\MethodCall), Object(PHPStan\Analyser\MutatingScope), Object(Closure), Object(PHPStan\Analyser\ExpressionContext))
#10 phar://vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(301): PHPStan\Analyser\NodeScopeResolver->processStmtNode(Object(PhpParser\Node\Stmt\Expression), Object(PHPStan\Analyser\MutatingScope), Object(Closure))
#11 phar://vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(680): PHPStan\Analyser\NodeScopeResolver->processStmtNodes(Object(PhpParser\Node\Stmt\Foreach_), Array, Object(PHPStan\Analyser\MutatingScope), Object(Closure))
#12 phar://vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(272): PHPStan\Analyser\NodeScopeResolver->processStmtNode(Object(PhpParser\Node\Stmt\Foreach_), Object(PHPStan\Analyser\MutatingScope), Object(Closure))
#13 phar://vendor/phpstan/phpstan/phpstan.phar/src/Analyser/FileAnalyser.php(189): PHPStan\Analyser\NodeScopeResolver->processNodes(Array, Object(PHPStan\Analyser\MutatingScope), Object(Closure))
#14 phar://vendor/phpstan/phpstan/phpstan.phar/src/Analyser/Analyser.php(61): PHPStan\Analyser\FileAnalyser->analyseFile('D:\\GitHub\\Steam...', Array, Object(PHPStan\Rules\Registry), NULL)
#15 phar://vendor/phpstan/phpstan/phpstan.phar/src/Command/AnalyserRunner.php(62): PHPStan\Analyser\Analyser->analyse(Array, Object(Closure), NULL, true, Array)
#16 phar://vendor/phpstan/phpstan/phpstan.phar/src/Command/AnalyseApplication.php(133): PHPStan\Command\AnalyserRunner->runAnalyser(Array, Array, Object(Closure), NULL, true, true, 'D:\\GitHub\\Steam...', NULL, NULL, Object(_PHPStan_3e014c27f\Symfony\Component\Console\Input\ArgvInput))
#17 phar://vendor/phpstan/phpstan/phpstan.phar/src/Command/AnalyseApplication.php(64): PHPStan\Command\AnalyseApplication->runAnalyser(Array, Array, true, 'D:\\GitHub\\Steam...', Object(PHPStan\Command\Symfony\SymfonyOutput), Object(PHPStan\Command\Symfony\SymfonyOutput), Object(_PHPStan_3e014c27f\Symfony\Component\Console\Input\ArgvInput))
#18 phar://vendor/phpstan/phpstan/phpstan.phar/src/Command/AnalyseCommand.php(175): PHPStan\Command\AnalyseApplication->analyse(Array, true, Object(PHPStan\Command\Symfony\SymfonyOutput), Object(PHPStan\Command\Symfony\SymfonyOutput), false, true, 'D:\\GitHub\\Steam...', Array, Object(_PHPStan_3e014c27f\Symfony\Component\Console\Input\ArgvInput))
#19 phar://vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Command/Command.php(259): PHPStan\Command\AnalyseCommand->execute(Object(_PHPStan_3e014c27f\Symfony\Component\Console\Input\ArgvInput), Object(_PHPStan_3e014c27f\Symfony\Component\Console\Output\ConsoleOutput))
#20 phar://vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Application.php(856): _PHPStan_3e014c27f\Symfony\Component\Console\Command\Command->run(Object(_PHPStan_3e014c27f\Symfony\Component\Console\Input\ArgvInput), Object(_PHPStan_3e014c27f\Symfony\Component\Console\Output\ConsoleOutput))
#21 phar://vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Application.php(259): _PHPStan_3e014c27f\Symfony\Component\Console\Application->doRunCommand(Object(PHPStan\Command\AnalyseCommand),
Object(_PHPStan_3e014c27f\Symfony\Component\Console\Input\ArgvInput), Object(_PHPStan_3e014c27f\Symfony\Component\Console\Output\ConsoleOutput))
#22 phar://vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Application.php(157): _PHPStan_3e014c27f\Symfony\Component\Console\Application->doRun(Object(_PHPStan_3e014c27f\Symfony\Component\Console\Input\ArgvInput), Object(_PHPStan_3e014c27f\Symfony\Component\Console\Output\ConsoleOutput))
#23 phar://vendor/phpstan/phpstan/phpstan.phar/bin/phpstan(94): _PHPStan_3e014c27f\Symfony\Component\Console\Application->run()
#24 phar://vendor/phpstan/phpstan/phpstan.phar/bin/phpstan(95): _PHPStan_3e014c27f\{closure}()
#25 vendor\phpstan\phpstan\phpstan(8): require('phar://D:/GitHu...')
#26 vendor\bin\phpstan(117): include('D:\\GitHub\\Steam...')
#27 {main}