Skip to content

Ghost parse errors persist due to incremental analysis #3056

@dktapps

Description

@dktapps

Bug report

Code snippet that reproduces the problem

Given the following:

Class1.php

<?php

namespace test;

class Class1{

and Class2.php

<?php

namespace test;

class Class2 extends Class1{

}

produces the below errors (as expected):

------ ----------------------------------------
  Line   Class1.php
 ------ ----------------------------------------
  8      Syntax error, unexpected EOF on line 8
 ------ ----------------------------------------

 ------ ----------------------------------------------------------------------
  Line   Class2.php
 ------ ----------------------------------------------------------------------
         ParseError (syntax error, unexpected end of file, expecting function
         (T_FUNCTION) or const (T_CONST)) thrown while autoloading class
         test\Class2.
  5      ParseError (syntax error, unexpected end of file, expecting function
         (T_FUNCTION) or const (T_CONST)) thrown while autoloading class
         test\Class1.
 ------ ----------------------------------------------------------------------

However, after fixing the parse error in Class1.php, the following errors persist unless the result cache is destroyed manually:

------ ----------------------------------------------------------------------
  Line   Class2.php
 ------ ----------------------------------------------------------------------
         ParseError (syntax error, unexpected end of file, expecting function
         (T_FUNCTION) or const (T_CONST)) thrown while autoloading class
         test\Class2.
  5      ParseError (syntax error, unexpected end of file, expecting function
         (T_FUNCTION) or const (T_CONST)) thrown while autoloading class
         test\Class1.
 ------ ----------------------------------------------------------------------

Not able to reproduce on phpstan.org due to unable to provide multiple files.

Expected output

After fixing the parse error, no errors should be reported.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions