orm icon indicating copy to clipboard operation
orm copied to clipboard

Add support for using nested DTOs

Open norkunas opened this issue 1 year ago • 9 comments

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?

norkunas avatar Feb 08 '24 08:02 norkunas

Thank you. Can you please have a look at the errors reported by our static analysis?

derrabus avatar Feb 08 '24 12:02 derrabus

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:

norkunas avatar Feb 08 '24 14:02 norkunas

Give it a try. If you encounter errors that you don't know how to fix, ask us anything. 🙂

derrabus avatar Feb 08 '24 16:02 derrabus

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

norkunas avatar Feb 12 '24 08:02 norkunas

Nice PR, I hope it will be merged soon!

seb-jean avatar May 28 '24 18:05 seb-jean

Nice Idea, hope comming soon

eltharin avatar Jul 02 '24 13:07 eltharin

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

greg0ire avatar Jul 02 '24 15:07 greg0ire

I have to make my own PR with changes ? It will be an exact copy of @nokunas changes with PSALM corrections ?

eltharin avatar Jul 02 '24 17:07 eltharin

That's another possibility yes

greg0ire avatar Jul 02 '24 18:07 greg0ire