Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for using nested DTOs #11238

Open
wants to merge 3 commits into
base: 3.1.x
Choose a base branch
from

Conversation

norkunas
Copy link
Contributor

@norkunas norkunas commented Feb 8, 2024

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?

@derrabus
Copy link
Member

derrabus commented Feb 8, 2024

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

@norkunas
Copy link
Contributor Author

norkunas commented Feb 8, 2024

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 😑

@derrabus
Copy link
Member

derrabus commented Feb 8, 2024

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

@norkunas norkunas force-pushed the nested-dtos branch 2 times, most recently from 3abc7d0 to 9420ac1 Compare February 12, 2024 08:41
@norkunas
Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants