Commit 944bc15
committed
Fix useless string cast on already-string-typed map keys in normalize()
MapType::createNormalizationLoopOutputAssignement() unconditionally cast
the loop key to string, but normalization always iterates a getter whose
declared return type is this MapType's own array<string, ...> contract
(see getDocTypeHint()) -- the key is already provably string, so PHPStan
correctly flags the cast as dead code (cast.useless).
Denormalization's createLoopOutputAssignement() is untouched: it processes
raw mixed-typed external data where the key's type isn't statically known,
so the cast there is legitimately defensive.
Surfaced by Zoho CRM's record.json spec (a project consuming this fork via
require-dev) generating a normalizer for a free-form additionalProperties
map for the first time -- Desk's specs never exercised this MapType
normalization path.1 parent 1bbb439 commit 944bc15
1 file changed
Lines changed: 7 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
74 | | - | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
75 | 81 | | |
76 | 82 | | |
0 commit comments