|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2021-10-19 14:32 UTC] quadxpies at gmail dot com
Description:
------------
Running PHPStan analysis with opcache.enable_cli=1 on below file produces 'Class "Doctrine\DBAL\ParameterType" not found error':
<?php
$connection = \Doctrine\DBAL\DriverManager::getConnection([]);
$stmt = $connection->prepare('');
$stmt->bindValue('', '', \Doctrine\DBAL\Connection::PARAM_STR_ARRAY);
No error is reported when opcache is disabled.
PHP 7.4 is not affected.
Error is also not reported when "use" is added:
use Doctrine\DBAL\ParameterType;
More info:
https://github.com/phpstan/phpstan/issues/5806
https://github.com/phpstan/phpstan/issues/5173
Test script:
---------------
docker run --rm -it bitnami/php-fpm:8.0 bash
composer require doctrine/dbal ^2 phpstan/phpstan
cat <<EOT > index.php
<?php
\$connection = \Doctrine\DBAL\DriverManager::getConnection([]);
\$stmt = \$connection->prepare('');
\$stmt->bindValue('', '', \Doctrine\DBAL\Connection::PARAM_STR_ARRAY);
EOT
php -d opcache.enable_cli=1 vendor/bin/phpstan analyse index.php
Expected result:
----------------
[OK] No errors
Actual result:
--------------
------ ----------------------------------------------------------------------
Line index.php
------ ----------------------------------------------------------------------
Internal error: Class "Doctrine\DBAL\ParameterType" not found
Run PHPStan with --debug option and post the stack trace to:
https://github.com/phpstan/phpstan/issues/new?template=Bug_report.md
------ ----------------------------------------------------------------------
[ERROR] Found 1 error
Stack trace:
Uncaught Error: Class "Doctrine\DBAL\ParameterType" not found in phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/ClassConstantReflection.php:57
#0 phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/ClassConstantReflection.php(57): ReflectionClassConstant->getValue()
#1 phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php(1479): PHPStan\Reflection\ClassConstantReflection->getValue()
#2 phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php(443): PHPStan\Analyser\MutatingScope->resolveType()
#3 phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/ParametersAcceptorSelector.php(84): PHPStan\Analyser\MutatingScope->getType()
#4 phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php(3294): PHPStan\Reflection\ParametersAcceptorSelector::selectFromArgs()
#5 phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php(1526): PHPStan\Analyser\MutatingScope->methodCallReturnType()
#6 phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php(1532): PHPStan\Analyser\MutatingScope->PHPStan\Analyser\{closure}()
#7 phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php(443): PHPStan\Analyser\MutatingScope->resolveType()
#8 phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(1345): PHPStan\Analyser\MutatingScope->getType()
#9 phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(460): PHPStan\Analyser\NodeScopeResolver->findEarlyTerminatingExpr()
#10 phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(227): PHPStan\Analyser\NodeScopeResolver->processStmtNode()
#11 phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/FileAnalyser.php(149): PHPStan\Analyser\NodeScopeResolver->processNodes()
#12 phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/Analyser.php(52): PHPStan\Analyser\FileAnalyser->analyseFile()
#13 phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Command/AnalyserRunner.php(56): PHPStan\Analyser\Analyser->analyse()
#14 phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Command/AnalyseApplication.php(148): PHPStan\Command\AnalyserRunner->runAnalyser()
#15 phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Command/AnalyseApplication.php(79): PHPStan\Command\AnalyseApplication->runAnalyser()
#16 phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Command/AnalyseCommand.php(157): PHPStan\Command\AnalyseApplication->analyse()
#17 phar:///app/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Command/Command.php(228): PHPStan\Command\AnalyseCommand->execute()
#18 phar:///app/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Application.php(856): _PHPStan_76800bfb5\Symfony\Component\Console\Command\Command->run()
#19 phar:///app/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Application.php(237): _PHPStan_76800bfb5\Symfony\Component\Console\Application->doRunCommand()
#20 phar:///app/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Application.php(138): _PHPStan_76800bfb5\Symfony\Component\Console\Application->doRun()
#21 phar:///app/vendor/phpstan/phpstan/phpstan.phar/bin/phpstan(82): _PHPStan_76800bfb5\Symfony\Component\Console\Application->run()
#22 phar:///app/vendor/phpstan/phpstan/phpstan.phar/bin/phpstan(83): _PHPStan_76800bfb5\{closure}()
#23 /app/vendor/phpstan/phpstan/phpstan(8): require('...')
#24 {main}
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 23 08:00:02 2025 UTC |
Keep it enabled and set opcache.revalidate_freq=0 and restart apache Or Put the following somewhere in your laravel application to disable caching for laravel only and only in your debug environment: if (env('APP_DEBUG')) ini_set('opcache.revalidate_freq', '0'); Maybe you need to change APP_DEBUG to your environment. (https://www.credible-bh.com/)github.com