Skip to content

Cannot simulate parameter value for type: non-empty-array<int, int>. #176

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

Closed
staabm opened this issue Jan 21, 2022 · 7 comments · Fixed by #228
Closed

Cannot simulate parameter value for type: non-empty-array<int, int>. #176

staabm opened this issue Jan 21, 2022 · 7 comments · Fixed by #228
Labels
bug Something isn't working

Comments

@staabm
Copy link
Owner

staabm commented Jan 21, 2022

composer/packagist#1232

https://github.com/composer/packagist/blob/c7d192a3bb5a48a2c5d54a5ede4115fa9d188d6a/src/Package/SymlinkDumper.php#L426-L434

                    $this->getEM()->getConnection()->executeQuery(
                        'UPDATE package SET dumpedAt=:dumped WHERE id IN (:ids)',
                        [
                            'ids' => $ids,
                            'dumped' => $dt,
                        ],
                        ['ids' => Connection::PARAM_INT_ARRAY]
                    );

leads to

  426    Unresolvable Query: Cannot simulate parameter value for type:  
         non-empty-array<int, int>.                                     
         💡 Make sure all variables involved have a non-mixed type and   
         array-types are specified. 
@staabm staabm added the bug Something isn't working label Jan 30, 2022
@staabm
Copy link
Owner Author

staabm commented Feb 2, 2022

@Seldaek if you could record the current queries of phpstan-dba and commit the phpstan-dba-cache-file (e.g. in a temporary branch), it would ease debugging remaining problems.

see https://github.com/staabm/phpstan-dba#record-and-replay

@Seldaek
Copy link
Contributor

Seldaek commented Feb 2, 2022

Pushed to Seldaek/packagist@50474ca the cache file from a composer phpstan -- --debug src/Entity/PackageRepository.php run. I changed the type to a different type on purpose (list<int> instead of list<string>) to make sure the error isn't suppressed by baseline, so it shows:

 263    Method App\Entity\PackageRepository::getStalePackagesForDumping() should return array<int, int> but returns array<int, mixed>.

@Seldaek
Copy link
Contributor

Seldaek commented Feb 2, 2022

Ah sorry maybe this is for #225 rather - too many things going on in parallel here :)

What can I do to help you with this issue?

I tried this it still fails:

$ composer phpstan -- --debug src/Package/SymlinkDumper.php
> vendor/bin/phpstan analyse '--debug' 'src/Package/SymlinkDumper.php'
Note: Using configuration file /var/www/packagist/phpstan.neon.
/var/www/packagist/src/Package/SymlinkDumper.php
Uncaught staabm\PHPStanDba\UnresolvableQueryException: Cannot simulate parameter value for type: non-empty-array<int, int> in /var/www/packagist/vendor/staabm/phpstan-dba/src/QueryReflection/QuerySimulation.php:85
#0 /var/www/packagist/vendor/staabm/phpstan-dba/src/QueryReflection/QueryReflection.php(258): staabm\PHPStanDba\QueryReflection\QuerySimulation::simulateParamValueType()
#1 /var/www/packagist/vendor/staabm/phpstan-dba/src/QueryReflection/QueryReflection.php(223): staabm\PHPStanDba\QueryReflection\QueryReflection->resolveConstantArray()
#2 /var/www/packagist/vendor/staabm/phpstan-dba/src/QueryReflection/QueryReflection.php(112): staabm\PHPStanDba\QueryReflection\QueryReflection->resolveParameters()
#3 /var/www/packagist/vendor/staabm/phpstan-dba/src/Extensions/DoctrineConnectionExecuteQueryDynamicReturnTypeExtension.php(70): staabm\PHPStanDba\QueryReflection\QueryReflection->resolvePreparedQueryString()
#4 /var/www/packagist/vendor/staabm/phpstan-dba/src/Extensions/DoctrineConnectionExecuteQueryDynamicReturnTypeExtension.php(57): staabm\PHPStanDba\Extensions\DoctrineConnectionExecuteQueryDynamicReturnTypeExtension->inferType()
#5 phar:///var/www/packagist/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php(3851): staabm\PHPStanDba\Extensions\DoctrineConnectionExecuteQueryDynamicReturnTypeExtension->getTypeFromMethodCall()
#6 phar:///var/www/packagist/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php(1813): PHPStan\Analyser\MutatingScope->methodCallReturnType()
#7 phar:///var/www/packagist/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php(1819): PHPStan\Analyser\MutatingScope->PHPStan\Analyser\{closure}()
#8 phar:///var/www/packagist/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php(534): PHPStan\Analyser\MutatingScope->resolveType()
#9 phar:///var/www/packagist/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(1382): PHPStan\Analyser\MutatingScope->getType()
#10 phar:///var/www/packagist/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(496): PHPStan\Analyser\NodeScopeResolver->findEarlyTerminatingExpr()
#11 phar:///var/www/packagist/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(298): PHPStan\Analyser\NodeScopeResolver->processStmtNode()
#12 phar:///var/www/packagist/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(975): PHPStan\Analyser\NodeScopeResolver->processStmtNodes()
#13 phar:///var/www/packagist/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(298): PHPStan\Analyser\NodeScopeResolver->processStmtNode()
#14 phar:///var/www/packagist/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(708): PHPStan\Analyser\NodeScopeResolver->processStmtNodes()
#15 phar:///var/www/packagist/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(298): PHPStan\Analyser\NodeScopeResolver->processStmtNode()
#16 phar:///var/www/packagist/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(656): PHPStan\Analyser\NodeScopeResolver->processStmtNodes()
#17 phar:///var/www/packagist/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(298): PHPStan\Analyser\NodeScopeResolver->processStmtNode()
#18 phar:///var/www/packagist/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(460): PHPStan\Analyser\NodeScopeResolver->processStmtNodes()
#19 phar:///var/www/packagist/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(298): PHPStan\Analyser\NodeScopeResolver->processStmtNode()
#20 phar:///var/www/packagist/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(544): PHPStan\Analyser\NodeScopeResolver->processStmtNodes()
#21 phar:///var/www/packagist/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(298): PHPStan\Analyser\NodeScopeResolver->processStmtNode()
#22 phar:///var/www/packagist/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(510): PHPStan\Analyser\NodeScopeResolver->processStmtNodes()
#23 phar:///var/www/packagist/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(269): PHPStan\Analyser\NodeScopeResolver->processStmtNode()
#24 phar:///var/www/packagist/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/FileAnalyser.php(189): PHPStan\Analyser\NodeScopeResolver->processNodes()
#25 phar:///var/www/packagist/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/Analyser.php(61): PHPStan\Analyser\FileAnalyser->analyseFile()
#26 phar:///var/www/packagist/vendor/phpstan/phpstan/phpstan.phar/src/Command/AnalyserRunner.php(62): PHPStan\Analyser\Analyser->analyse()
#27 phar:///var/www/packagist/vendor/phpstan/phpstan/phpstan.phar/src/Command/AnalyseApplication.php(131): PHPStan\Command\AnalyserRunner->runAnalyser()
#28 phar:///var/www/packagist/vendor/phpstan/phpstan/phpstan.phar/src/Command/AnalyseApplication.php(69): PHPStan\Command\AnalyseApplication->runAnalyser()
#29 phar:///var/www/packagist/vendor/phpstan/phpstan/phpstan.phar/src/Command/AnalyseCommand.php(175): PHPStan\Command\AnalyseApplication->analyse()
#30 phar:///var/www/packagist/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Command/Command.php(259): PHPStan\Command\AnalyseCommand->execute()
#31 phar:///var/www/packagist/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Application.php(848): _PHPStan_c17a331f2\Symfony\Component\Console\Command\Command->run()
#32 phar:///var/www/packagist/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Application.php(259): _PHPStan_c17a331f2\Symfony\Component\Console\Application->doRunCommand()
#33 phar:///var/www/packagist/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Application.php(157): _PHPStan_c17a331f2\Symfony\Component\Console\Application->doRun()
#34 phar:///var/www/packagist/vendor/phpstan/phpstan/phpstan.phar/bin/phpstan(94): _PHPStan_c17a331f2\Symfony\Component\Console\Application->run()
#35 phar:///var/www/packagist/vendor/phpstan/phpstan/phpstan.phar/bin/phpstan(95): _PHPStan_c17a331f2\{closure}()
#36 /var/www/packagist/vendor/phpstan/phpstan/phpstan(8): require('...')
#37 /var/www/packagist/vendor/bin/phpstan(117): include('...')
#38 {main}

But I have nothing to share then, it doesn't create the cache file when it crashes like that.

@staabm
Copy link
Owner Author

staabm commented Feb 2, 2022

please just use the RecoringQueryReflector without debug mode enabled (in the phpstan-dba config file), like described in the example on https://github.com/staabm/phpstan-dba#record-and-replay (enabling phpstan --debug shouldn't make a difference)

this should generate the cache file.

just push it into the repo so I can checkout and run the analysis locally without a packagist.org database setup

@Seldaek
Copy link
Contributor

Seldaek commented Feb 2, 2022

Sorry but I don't get it I guess..

I disabled debug mode, ran composer phpstan -- src/Entity/PackageRepository.php src/Package/SymlinkDumper.php, and the cache file is still exactly the same I committed in Seldaek/packagist@50474ca - is that not enough?

@staabm
Copy link
Owner Author

staabm commented Feb 2, 2022

please let phpstan analyse the whole project. the cache file will contain any db query which is necessary to scan the whole project (that way I can also analyze other problems).

@Seldaek
Copy link
Contributor

Seldaek commented Feb 2, 2022

OK pushed again Seldaek/packagist@68b6a7e

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants