Skip to content

Conversation

@yoeunes
Copy link

@yoeunes yoeunes commented Nov 23, 2025

Fixes type inference for primitive scalar types (int, string, bool, float) when used with Serializer::deserialize().

Currently, the extension wraps all base types in ObjectType. This means int[] is incorrectly inferred as an array of objects named "int" rather than scalar integers, causing false positives during arithmetic operations.

@yoeunes
Copy link
Author

yoeunes commented Nov 23, 2025

While working on this fix, I noticed we could simplify and future-proof this code by using PHPStan's native TypeStringResolver instead of manual parsing.

Proposed refactoring:

$types[] = $this->typeStringResolver->resolve($constantString->getValue());

I kept the minimal fix here, because changing the constructor to inject the resolver would be a backward compatibility break

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.

1 participant