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

Intermittent 'Internal error: Internal error: Class 'Doctrine\DBAL\ParameterType' not found' #5173

Closed
junowilderness opened this issue Jun 14, 2021 · 11 comments

Comments

@junowilderness
Copy link

junowilderness commented Jun 14, 2021

Bug report

$ vendor/bin/phpstan --version                                                             
PHPStan - PHP Static Analysis Tool 0.12.89

This happens on our CI runners sometimes and only for this app. Often we re-run and it doesn't happen a second time. But this time it seems persistent. Probably related is that the affected branch is an upgrade of doctrine/orm from 2.9.2 to 2.9.3.

vendor/bin/phpstan analyse --level 7 --memory-limit=1000M --no-progress src tests --debug
Note: Using configuration file /var/gitlab-runner/builds/6AUg6v_L/0/theias/di/updateme/phpstan.neon.
# cut: lots of files scanned...
/var/gitlab-runner/builds/6AUg6v_L/0/theias/di/updateme/src/Component/Onboarding/DatabaseQuery.php
PHP Fatal error:  Uncaught Error: Class 'Doctrine\DBAL\ParameterType' not found in phar:///var/gitlab-runner/builds/6AUg6v_L/0/theias/di/updateme/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/ClassConstantReflection.php:48
Stack trace:
#0 phar:///var/gitlab-runner/builds/6AUg6v_L/0/theias/di/updateme/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/ClassConstantReflection.php(48): ReflectionClassConstant->getValue()
#1 phar:///var/gitlab-runner/builds/6AUg6v_L/0/theias/di/updateme/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/ClassConstantReflection.php(53): PHPStan\Reflection\ClassConstantReflection->getValue()
#2 phar:///var/gitlab-runner/builds/6AUg6v_L/0/theias/di/updateme/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php(1355): PHPStan\Reflection\ClassConstantReflection->getValueType()
#3 phar:///var/gitlab-runner/builds/6AUg6v_L/0/theias/di/updateme/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php(437): PHPStan\Analyser\MutatingScope->resolveType()
#4 phar:///var/gitlab-runn in phar:///var/gitlab-runner/builds/6AUg6v_L/0/theias/di/updateme/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/ClassConstantReflection.php on line 48
Fatal error: Uncaught Error: Class 'Doctrine\DBAL\ParameterType' not found in phar:///var/gitlab-runner/builds/6AUg6v_L/0/theias/di/updateme/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/ClassConstantReflection.php:48
Stack trace:
#0 phar:///var/gitlab-runner/builds/6AUg6v_L/0/theias/di/updateme/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/ClassConstantReflection.php(48): ReflectionClassConstant->getValue()
#1 phar:///var/gitlab-runner/builds/6AUg6v_L/0/theias/di/updateme/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/ClassConstantReflection.php(53): PHPStan\Reflection\ClassConstantReflection->getValue()
#2 phar:///var/gitlab-runner/builds/6AUg6v_L/0/theias/di/updateme/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php(1355): PHPStan\Reflection\ClassConstantReflection->getValueType()
#3 phar:///var/gitlab-runner/builds/6AUg6v_L/0/theias/di/updateme/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php(437): PHPStan\Analyser\MutatingScope->resolveType()
#4 phar:///var/gitlab-runn in phar:///var/gitlab-runner/builds/6AUg6v_L/0/theias/di/updateme/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/ClassConstantReflection.php on line 48

Code snippet that reproduces the problem

includes:
	- phpstan-baseline.neon
parameters:
    inferPrivatePropertyTypeFromConstructor: true
    symfony:
        container_xml_path: var/cache/dev/App_KernelDevDebugContainer.xml
    bootstrapFiles:
        - %currentWorkingDirectory%/tests/bootstrap.php
<?php

namespace App\Component\Onboarding;

use App\Component\Database\Gateway;
use Doctrine\DBAL\Connection;

class DatabaseQuery extends Gateway
{
    /**
     * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
     */
    public function selectUpcomingVisitsForScholar(int $mainid): array
    {
        $sql = 'SELECT foo FROM bar
            WHERE  bar IN (?)';
        $stmt = $this->connection->executeQuery(
            $sql,
            [$mainid, array_keys(Config::TYPES)],
            [\PDO::PARAM_INT, Connection::PARAM_INT_ARRAY]
        );

        return $stmt->fetchAll();
    }

    /**
     * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
     */
    public function selectUpcomingVisits(): array
    {
        $sql = 'SELECT foo FROM bar
            WHERE  bar IN (?)';
        $stmt = $this->connection->executeQuery(
            $sql,
            [array_keys(Config::TYPES)],
            [Connection::PARAM_INT_ARRAY]
        );

        return $stmt->fetchAll();
    }

    public function selectScholarDetails(int $mainid): array
    {
        $sql = 'SELECT foo FROM bar
            WHERE  bar = ?';
        $stmt = $this->connection->executeQuery(
            $sql,
            [$mainid],
            [\PDO::PARAM_INT]
        );

        return $stmt->fetchAll();
    }
}

Did PHPStan help you today? Did it make you happy in any way?

Is that a serious question? I love static analysis, and I love you.

@mergeable
Copy link

mergeable bot commented Jun 14, 2021

This bug report is missing a link to reproduction on phpstan.org.

It will most likely be closed after manual review.

@junowilderness
Copy link
Author

@ondrejmirtes
Copy link
Member

Hi, please create a small reproducing repository that shows the problem, thanks.

@junowilderness
Copy link
Author

Thank you I will try. For some reason it happens only on CI so this may be subtle.

@junowilderness
Copy link
Author

So, by disabling the CI server's cache of the vendor directory, this did not occur. Probably there was some corruption in those files. Let us close this. Sorry for the noise!

@junowilderness
Copy link
Author

My current thinking is that it may be memory-related. I've increased memory-limit.

@junowilderness
Copy link
Author

It seems unrelated to memory. Here is a repo in which I execute:

vendor/bin/phpstan analyse --level 7 --no-progress src

The repo contains only the problem file. I am 99% sure the issue is when following Connection::PARAM_INT_ARRAY where PARAM_INT_ARRAY is initialized by Doctrine to be public const PARAM_INT_ARRAY = ParameterType::INTEGER + self::ARRAY_PARAM_OFFSET. Class ParameterType is in the same namespace as Connection. Both of these are Doctrine library classes. For some reason ParameterType is not found by ClassConstantReflection sometimes. This is intermittent for us so as you can imagine it is difficult to nail down.

@junowilderness junowilderness reopened this Jul 7, 2021
@junowilderness
Copy link
Author

My current avenue of investigation is that perhaps opcache.enable_cli, which is enabled on the CI task runner for some reason, is involved.

@MartinMystikJonas
Copy link
Contributor

I jsut encountered simillar error and disabling opcache.enable_cli solved it for me.

@ondrejmirtes
Copy link
Member

Looks like PHP bug.

@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 10, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants