Skip to content

Call to undefined method PhpParser\Comment\Doc::getEndLine() with 0.12.19 #3224

@soullivaneuh

Description

@soullivaneuh

Bug report

Using phpstan 0.12.19 with composer bin installation, I have the following crash error:

$ vendor/bin/phpstan analyse -c phpstan.neon -l 7 src

Fatal error: Uncaught Error: Call to undefined method PhpParser\Comment\Doc::getEndLine() in phar:///app/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan/src/Analyser/FileAnalyser.php:202
Stack trace:
#0 phar:///app/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan/src/Analyser/FileAnalyser.php(184): PHPStan\Analyser\FileAnalyser->findLineToIgnoreComment(Object(PhpParser\Comment\Doc))
#1 phar:///app/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan/src/Analyser/FileAnalyser.php(121): PHPStan\Analyser\FileAnalyser->getLinesToIgnore(Object(PHPStan\Node\FileNode))
#2 phar:///app/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan/src/Analyser/FileAnalyser.php(135): PHPStan\Analyser\FileAnalyser->PHPStan\Analyser\{closure}(Object(PHPStan\Node\FileNode), Object(PHPStan\Analyser\MutatingScope))
#3 phar:///app/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan/src/PhpDoc/StubValidator.php(78): PHPStan\Analyser\FileAnalyser->analyseFile('phar:///app/ven...', Array, Object(PHPStan\Rules\Registry), Object(Closure))
#4 phar:///app/ven in phar:///app/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan/src/Analyser/FileAnalyser.php on line 202

Composer dependencies list:

$ composer bin phpstan show
phpstan/phpstan                  0.12.19 PHPStan - PHP Static Analysis Tool
phpstan/phpstan-doctrine         0.12.10 Doctrine extensions for PHPStan
phpstan/phpstan-phpunit          0.12.8  PHPUnit extensions and rules for PHPStan
phpstan/phpstan-strict-rules     0.12.2  Extra strict and opinionated rules for PHPStan
phpstan/phpstan-symfony          0.12.6  Symfony Framework extensions and rules for PHPStan
phpstan/phpstan-webmozart-assert 0.12.3  PHPStan webmozart/assert extension

phpstan.neon file:

includes:
    - vendor-bin/phpstan/vendor/phpstan/phpstan-symfony/extension.neon
    - vendor-bin/phpstan/vendor/phpstan/phpstan-doctrine/extension.neon
    - vendor-bin/phpstan/vendor/phpstan/phpstan-phpunit/extension.neon
    - vendor-bin/phpstan/vendor/phpstan/phpstan-phpunit/rules.neon
    - vendor-bin/phpstan/vendor/phpstan/phpstan-strict-rules/rules.neon
    - vendor-bin/phpstan/vendor/phpstan/phpstan-webmozart-assert/extension.neon

parameters:
    autoload_files:
        - src/autoload.php
        - vendor-bin/phpunit/vendor/autoload.php
    symfony:
        container_xml_path: var/cache/test/srcApp_KernelTestDebugContainer.xml
    ignoreErrors:
        # @see https://github.com/phpstan/phpstan/issues/784
        - '#has invalid typehint type Composer\\Script\\Event.$#'
        # @see https://github.com/phpstan/phpstan/issues/671#issuecomment-359629195
        - '#but returns Doctrine\\Common\\Collections\\Collection.$#'
        # @see https://github.com/sonata-project/SonataAdminBundle/issues/4905
        - '#^Parameter \#1 \$view of method Sonata\\AdminBundle\\Controller\\CRUDController::renderWithExtraParams\(\) expects string#'
        - '#^Parameter \#1 \$view of method Sonata\\AdminBundle\\Controller\\CRUDController::render\(\) expects string#'
        # @see https://github.com/phpstan/phpstan-doctrine/pull/8
        - '#^Call to an undefined method Doctrine\\ORM\\EntityRepository<#'
        # @see https://github.com/phpstan/phpstan/issues/1105
        - '#call_user_func_array expects callable()#'

    excludes_analyse:
        - 'src/Migrations'
        # @see https://github.com/phpstan/phpstan/issues/323
        - tests/AppBundle/Admin/AbstractAdminTest.php
        # @see https://github.com/phpstan/phpstan/issues/323
        - tests/AppBundle/Entity/AbstractEntityTest.php
        # @see https://github.com/FriendsOfSymfony/FOSUserBundle/pull/2719
        - src/AppBundle/Controller/Admin/UserController.php

Works correctly with v0.12.18.

Seems related to #3207, but I have my dependencies installed in contrary to #3207 (comment).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions