orm
orm copied to clipboard
Add support for using nested DTOs
Continuation of #6709 and #6574
I've cherry picked commits from these and rebased. One test is commented with scalar results because I don't think that it makes sense to returns object when you expect scalars?
Thank you. Can you please have a look at the errors reported by our static analysis?
Thank you. Can you please have a look at the errors reported by our static analysis?
I'd like, but without deep knowledge of internals I can't guarantee anything :expressionless:
Give it a try. If you encounter errors that you don't know how to fix, ask us anything. 🙂
I see a contradiction between psalm and phpstan. From psalm I get:
ERROR: PossiblyUndefinedArrayOffset
at /orm/src/Internal/Hydration/AbstractHydrator.php:350:22
Possibly undefined array key $newObject['args'] on array{args?: array<array-key, BackedEnum|array<array-key, BackedEnum>|mixed>, class: mixed} (see https://psalm.dev/167)
$args = $newObject['args'];
ERROR: PossiblyUndefinedArrayOffset
at /orm/src/Internal/Hydration/AbstractHydrator.php:359:26
Possibly undefined array key $newObject['args'] on array{args?: array<array-key, BackedEnum|array<array-key, BackedEnum>|mixed>, class: mixed} (see https://psalm.dev/167)
$args = $newObject['args'];
But if I modify to $newObject['args'] ?? []
then phpstan says:
Error: Offset 'args' on array{class: mixed, args: non-empty-array<int|string, mixed>} on left side of ?? always exists and is not nullable.
Error: Offset 'args' on array{class: mixed, args: non-empty-array<int|string, mixed>} on left side of ?? always exists and is not nullable
Nice PR, I hope it will be merged soon!
Nice Idea, hope comming soon
Possible next step: write a reproducer for the static analysis issue and try to reproduce it on psalm.dev and phpstan.org. Feel free to help with this @seb-jean @eltharin
I have to make my own PR with changes ? It will be an exact copy of @nokunas changes with PSALM corrections ?
That's another possibility yes