Repository navigation
Fix false positives in EntityColumnRule for json columns with enumType - #806
Open
oriolvinals wants to merge 1 commit into
Open
oriolvinals wants to merge 1 commit into
oriolvinals wants to merge 1 commit into
Conversation
oriolvinals
marked this pull request as ready for review
October 30, 2026 14:35
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Doctrine ORM supports
enumTypeonjsoncolumns holding arrays: each value is hydrated withEnum::from()viaarray_map, which preserves keys.EntityColumnRulereports two false positives for such mappings:Cause
Both come from the array branch of the
enumTypehandling added in #605:jsonthat value type ismixed, so the comparison can never succeed.JsonType::getWritableToPropertyType()returnsNeverType("don't check"), but the branch replaces it witharray<key, Enum>intersected with the accessory types ofNeverType. As there is noAccessoryArrayListTypeto keep, the result is a plainarray<Enum>, which then fails againstlist<Enum>. This second error does not happen withsimple_array, whose descriptor returnslist<string>so the list accessory is preserved.Fix
mixed, consistent with the existing "If the type descriptor does not precise the types inside the array, don't report errors" logic in the same rule.$writableToPropertyTypeuntouched when it isNeverType.$writableToDatabaseTypeis still rebuilt as before, so mismatches like alist<string>property on ajson+enumTypecolumn are still reported.Tests
The new
json+enumTypecases inenum-type.php(list<Enum>,array<Enum>,Enum[]) fail on2.1.xwith both errors above, and alist<string>property on such a column is still reported. The existingsimple_arraycases are unchanged. I also checked by hand that the usual mutants on the changed lines (instanceof,!,&&,!== null) are caught, since I couldn't run Infection locally. ODM tests were not run here (noext-mongodb).Fixes #628