Skip to content

Conversation

@staabm
Copy link
Contributor

@staabm staabm commented Jan 20, 2026

closes phpstan/phpstan#13985

partly reverts #4761

@ondrejmirtes
Copy link
Member

I don't get it, why shouldn't it be cached?

@staabm
Copy link
Contributor Author

staabm commented Jan 20, 2026

ClassReflection created via withTypes has properties like isDeprecated, isGeneric, isInternal set to null

grafik

while the one created via getClass contains more information:

grafik

so by caching the withTypes created one, we have less information at hand later on when we respond to a getClassReflection() call with a cached object

@staabm
Copy link
Contributor Author

staabm commented Jan 20, 2026

Hmm no. This doesn't make sense. Will have another look tomorrow

@staabm
Copy link
Contributor Author

staabm commented Jan 21, 2026

had another look but still I am not yet sure about the causation.

the difference between caching and not caching is, that

  • when caching generics ClassReflection for SplObjectStorage the template-type map will be ErrorType, ErrorType which causes lots of if instanceof ErrorType logic to happen and fallbacks are getting evaluated
  • when not caching generics ClassReflection for SplObjectStorage the template-type map will reflect the unresolved types of the phpdoc stub

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.

Errors related to SplObjectStorage in 2.1.34

2 participants