Skip to content

Recursion Memory Bug when using Traits #6740

@yphoenix

Description

@yphoenix

Bug report

PHPStan 1.4.3-1.4.8 (doesn't occur with 1.4.2 and earlier, bug introduced with 1.4.3)

When you have a Trait defined in one file and refer to it in a different file you run out of memory, no matter how much memory you give PHPStan

Code snippet that reproduces the problem

As you need to use two files to reproduce the problem, it can't be reproduced using a single file. See attached zip file.

TraitFail.zip

phpstan --memory-limit=8G 
Note: Using configuration file /.../TraitFail/phpstan.neon.
 -- ------------------------------------------------------------------------------------------------------------------------------------ 
     Error                                                                                                                               
 -- ------------------------------------------------------------------------------------------------------------------------------------ 
     Child process error (exit code 255): PHP Fatal error:  Allowed memory size of 8589934592 bytes exhausted (tried to allocate 262144  
     bytes) in phar:///.../phpstan.phar/src/Type/FileTypeMapper.php on line 491                                       
     Fatal error: Allowed memory size of 8589934592 bytes exhausted (tried to allocate 262144 bytes) in                                  
     phar:///.../phpstan.phar/src/Type/FileTypeMapper.php on line 491                                                 
     PHP Fatal error:  Allowed memory size of 8589934592 bytes exhausted (tried to allocate 262144 bytes) in Unknown on line 0           
     Fatal error: Allowed memory size of 8589934592 bytes exhausted (tried to allocate 262144 bytes) in Unknown on line 0                
                                                                                                                                         
 -- -----------------------------------------

Expected output

[OK] No errors

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

PHPStan helps me every day, but I'm stuck on 1.4.2 because of this

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