-
-
Notifications
You must be signed in to change notification settings - Fork 23
Open
Labels
bugSomething isn't workingSomething isn't working
Description
$queries = [ 'SELECT 1' ];
foreach( $queries as $test )
{
$test = $pdo->prepare( $test ); // reusing variable
$test->execute();
}
However this doesn't crash:
$test = 'SELECT 1';
$test = Container::Database()->prepare( $test );
$test->execute();
Something about the loop makes it confuse the type. Obviously reusing the variable isn't a good idea (and I fixed it in my code), but it probably shouldn't crash.
Uncaught staabm\PHPStanDba\DbaException: Unexpected expression type [snip] of class PHPStan\Type\Generic\GenericObjectType in phpstan-dba\src\QueryReflection\QuerySimulation.php:117
#0 phpstan-dba\src\QueryReflection\QueryReflection.php(189): staabm\PHPStanDba\QueryReflection\QuerySimulation::simulateParamValueType(Object(PHPStan\Type\Generic\GenericObjectType), false)
#1 phpstan-dba\src\QueryReflection\QueryReflection.php(165): staabm\PHPStanDba\QueryReflection\QueryReflection->resolveQueryStringExpr(Object(PhpParser\Node\Expr\Variable), Object(PHPStan\Analyser\MutatingScope))
#2 phpstan-dba\src\QueryReflection\QueryReflection.php(137): staabm\PHPStanDba\QueryReflection\QueryReflection->resolveQueryExpr(Object(PhpParser\Node\Expr\Variable), Object(PHPStan\Analyser\MutatingScope))
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working