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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optional keys in nested object shapes ($A->B->C ?? []) #10379

Open
leongersen opened this issue Jan 5, 2024 · 0 comments
Open

Optional keys in nested object shapes ($A->B->C ?? []) #10379

leongersen opened this issue Jan 5, 2024 · 0 comments
Labels
Milestone

Comments

@leongersen
Copy link
Contributor

leongersen commented Jan 5, 2024

Bug report

Thank you for releasing 1.10.51 馃帀

Object shapes with optional keys now work with coalescing, but this does not work fully if multiple objects are nested.

This is related to #10317 and #10327.

For context, I'm trying to add stubs to a mess of a library generated from a SOAP spec.

Code snippet that reproduces the problem

https://phpstan.org/r/d8d7859d-6942-4f9d-940e-05ed7b14680d

Expected output

  • Using nullsafe property access "?->Monkey" on left side of ?? is unnecessary. Use -> instead. is correct;
  • Access to an undefined property object{Monkey?: array<int>}::$Monkey. is not correct;

Did PHPStan help you today? Did it make you happy in any way?

No response

@ondrejmirtes ondrejmirtes added this to the Easy fixes milestone Jan 5, 2024
@leongersen leongersen changed the title Optional keys in nested array shapes ($A->B->C ?? []) Optional keys in nested object shapes ($A->B->C ?? []) Jan 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants