Skip to content

FileTypeMapper: Don't deep traverse method/function/hook bodies - #4730

Closed
staabm wants to merge 1 commit into
phpstan:2.1.xfrom
staabm:dont-deep
Closed

staabm wants to merge 1 commit into
phpstan:2.1.xfrom
staabm:dont-deep

Conversation

@staabm

@staabm staabm commented Jan 7, 2026

Copy link
Copy Markdown
Contributor

in case we would know that a certain file does not contain any inline functions/class-definitions, we could skip deep traverse method/function/hook bodies.

testing suggests, this would save us 10 MB of memory when running
php bin/phpstan analyse src/Analyser/ src/Rules/ -v --debug

@staabm

staabm commented Jan 7, 2026 •

Copy link
Copy Markdown
Contributor Author

this PR doesn't work as is, since I did not find yet a way how we can cheaply identify whether a file contains inline classes/functions. any idea whether/how this can be checked?

@ondrejmirtes

Copy link
Copy Markdown
Member

Can we actually skip it? I think we still need to find all inline @var and @throws...

But there's a lot of time spent in FileTypeMapper, maybe there are ways to optimize it.

@staabm staabm closed this Jan 9, 2026
@staabm
staabm deleted the dont-deep branch January 9, 2026 13:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants