Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Discussion options

I keep running out of memory, even when only checking 30 files.
Running PHPStan in debug mode, gives this output:

Result cache not used because the metadata do not match: projectConfig
 35/35 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100% 13 secs/13 secs

Result cache was not saved because of error in dependencies.
 -- -------------------------------------------------------------------------- 
     Error                                                                     
 -- -------------------------------------------------------------------------- 
     Child process error (exit code 255): [25-Sep-2025 13:18:44 UTC] PHP       
     Fatal error:  Allowed memory size of 10737418240 bytes exhausted (tried   
     to allocate 262144 bytes) in                                              
     phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Type/Static  
     Type.php on line 82                                                       
     [25-Sep-2025 13:18:44 UTC] PHP Fatal error:  Allowed memory size of       
     10737418240 bytes exhausted (tried to allocate 262144 bytes) in           
     /var/www/html/vendor/spatie/ray/src/helpers.php on line 54                
      while running parallel worker                                            
 -- -------------------------------------------------------------------------- 


                                                                               
 [ERROR] Found 1 error                                                         
                                                                               

PHP runtime version: 8.4.8
PHP composer.json required version: 8.4-8.5.99
PHP version for analysis: 8.4.8 (from runtime)

PHPStan version: 2.1.29
PHPStan running from:
/var/www/html/vendor/phpstan/phpstan

Extension installer: Not installed

Included configs from Composer packages:
larastan/larastan (extension.neon): v3.7.2
phpstan/phpstan-deprecation-rules (rules.neon): 2.0.3

Discovered Composer project root:
/var/www/html

Parallel processing scheduler:
# of detected CPU cores:   8
# of analysed files:       35
# of jobs:                 2
# of spawned processes:    1

⚠️  Result is incomplete because of severe errors. ⚠️
   Fix these errors first and then re-run PHPStan
   to get all reported errors.

Elapsed time: 13 seconds
Used memory: 288 MB
Script ./vendor/bin/phpstan analyze --memory-limit=10G --configuration=phpstan.neon -vvv handling the phpstan event returned with error code 1

Using the latest version of PHPStan (2.1.29).

My phpstan.neon file looks like this:

includes:
    - %rootDir%/../../larastan/larastan/extension.neon
    - %rootDir%/../../phpstan/phpstan-deprecation-rules/rules.neon

parameters:
    reportUnmatchedIgnoredErrors: false
    level: 6
    checkMissingOverrideMethodAttribute: false
    paths:
        - config
    excludePaths:
        - */vendor/*
        - */storage/*
        - */node_modules/*

Does someone know some things I can check or change?

You must be logged in to vote

Replies: 2 comments · 5 replies

Comment options

Most likely infinite recursion. Please run PHPStan with -vvv --debug and pinpoint which exact line of code or a small amount of lines of code lead to this issue.

You must be logged in to vote
5 replies
@EranNL
Comment options

Thanks for your quick reply! With recursion, you mean some phpstan types referencing each other?

@ondrejmirtes
Comment options

Not type recursion, but any recursion (bug in PHPStan).

@EranNL
Comment options

Also "recursion" like imports that use each other? And is it something that will or can be fixed in PHPStan (since you indicate that it is a bug in PHPStan)?

Using --debug, the code is stuck in a simple file that returns an array, with imports. So the recursion could be anywhere in the tree 😬

@ondrejmirtes
Comment options

Yeah so try to simplify the other files that contain the imported symbols.

@EranNL
Comment options

Okay, will try. Thanks @ondrejmirtes.

Comment options

Possibly might be scanning its own cache files, this will send it into a tailspin. Delete the cache and ignore the directory to fix.

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Support
Labels
None yet
3 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.