phpstan / phpdoc-parser

Next-gen phpDoc parser with support for intersection types and generics
MIT License
1.32k stars 62 forks source link

Random ClassNotFoundError PhpStanExtractor.php line 67 #163

Open fliespl opened 1 year ago

fliespl commented 1 year ago

A few times a day, I am getting following exception in symfony project. Clearing symfony cache fixes it - any ideas what could be the issue since it's random?

Uncaught Error: Class "PHPStan\PhpDocParser\Parser\PhpDocParser" not found

Uncaught PHP Exception Symfony\Component\ErrorHandler\Error\ClassNotFoundError: "Attempted to load class "PhpDocParser" from namespace "PHPStan\PhpDocParser\Parser". Did you forget a "use" statement for another namespace?" at /home/flies/workspace/sf5/homologacja/vendor/symfony/property-info/Extractor/PhpStanExtractor.php line 67
ondrejmirtes commented 1 year ago

A few times a day, I am getting following exception in symfony project

Please tell us more. What are you running when you get this exception? Is phpstan/phpdoc-parser dependency of your own project?

fliespl commented 1 year ago

Some additional details.

Using phpstorm with inspections enabled. After doing some code changes and going back to browser I get this error: homologacja sf5 wsl_

It will stay that way until I do cache clear in symfony.

Packages used:

       "phpstan/extension-installer": "^1.1",
        "phpstan/phpstan": "^1.7",
        "phpstan/phpstan-deprecation-rules": "^1.0",
        "phpstan/phpstan-doctrine": "^1.3",
        "phpstan/phpstan-phpunit": "^1.1",
        "phpstan/phpstan-strict-rules": "^1.2",
        "phpstan/phpstan-symfony": "^1.2",
        "phpstan/phpstan-webmozart-assert": "^1.2",

phpstan config:

includes:
    - tests/phpstan/custom-parameters.php

parameters:
    scanFiles:
      - src/Kernel.php
    level: max
    paths:
        - migrations
        - src
        - tests
    symfony:
        console_application_loader: tests/phpstan/console-application.php
    doctrine:
        objectManagerLoader: tests/phpstan/object-manager.php
    reportUnmatchedIgnoredErrors: false
    checkGenericClassInNonGenericObjectType: false
    typeAliases:
         SerializerSubscribedEvents: 'array<array{event: string, method: string, class?: class-string, priority?: int, format?: string}>'
fabienlem commented 1 year ago

Same here.

fliespl commented 1 year ago

I am testing right now with adding phpstan/phpdoc-parser as direct dev requirement - seems promising for now.

olijzenga commented 1 year ago

I am testing right now with adding phpstan/phpdoc-parser as direct dev requirement - seems promising for now.

Same issue here, this workaround also works for me.