Skip to content

Conversation

@staabm
Copy link
Contributor

@staabm staabm commented Jan 26, 2026

@staabm
Copy link
Contributor Author

staabm commented Jan 26, 2026

We could raise the threshold to degenerate later.. need to test this in the origin slow snippets though

@ondrejmirtes
Copy link
Member

An idea - we could degrade it only for literal array in code, but we wouldn't need to degrade it for array shapes? Meaning ConstantArrayTypeBuilder in TypeNodeResolver would be created in a different mode.

Also maybe the limit for degrading closures could be higher?

@staabm
Copy link
Contributor Author

staabm commented Jan 26, 2026

An idea - we could degrade it only for literal array in code, but we wouldn't need to degrade it for array shapes? Meaning ConstantArrayTypeBuilder in TypeNodeResolver would be created in a different mode.

I don't see how this is possible, because the worst case scenario is built up over one assign per line
see https://github.com/GrzegorzDrozd/phpstan-performance-issue-reproduction/blob/master/src/index_bad.php

@staabm staabm marked this pull request as draft January 26, 2026 17:32
@staabm
Copy link
Contributor Author

staabm commented Jan 26, 2026

I had to discard the previous fix because it discarded all perf benefits we got previosuly with #4684

@staabm staabm marked this pull request as ready for review January 26, 2026 18:04
@phpstan-bot
Copy link
Collaborator

This pull request has been marked as ready for review.

* isSameAs: \Closure(Scope, Node\Arg, Node\Arg): Node\Expr,
* isScalar: \Closure(Scope, Node\Arg): Node\Expr,
* isString: \Closure(Scope, Node\Arg): Node\Expr,
* isTrue: \Closure(Scope, Node\Arg): Node\Expr,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also assert what's the type of the property here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

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.

Degraded closures in constant arrays are now reported by checkMissingCallableSignature: true

3 participants