phpstan-doctrine
phpstan-doctrine copied to clipboard
The type integration does not properly support enumType on an array-based type
Currently, the resolution of doctrine types considers that any field that uses enumType
will have a PHP type of new ObjectType($enumType)
(potentially nullable depending on the nullability of the field).
This is a wrong assumption about the way this feature works in the Doctrine ORM. The enumType
feature supports 2 cases:
- if the converted field value (based on the DBAL type of the field) is a scalar, it gets turned into an enum instance
- if the converted field value is an array, each value of the array gets turned into an enum instance
That second case is not supported by phpstan-doctrine, reporting the wrong type. Both QueryResultTypeWalker and EntityColumnRule are impacted by that.
This is easy to fix, the right code in EntityColumnRule will make it work.
And yeah, you'll have to touch QueryResultTypeWalker too