-
Notifications
You must be signed in to change notification settings - Fork 664
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
Accessing different nested object properties trigger MixedPropertyFetch #10380
Comments
I found these snippets: https://psalm.dev/r/4ec39c5d44<?php
/**
* @var object{
* Nested: object{
* foo: string,
* bar: string,
* }
* } $object
*/
if ($object->Nested->foo !== 'Foo') {
return null;
}
if ($object->Nested->bar !== 'Bar') {
return null;
}
|
annuh
changed the title
Multiple nested object property fetch trigger "Cannot fetch property on mixed var $object->Nested"
Accessing different nested object properties trigger MixedPropertyFetch
Nov 16, 2023
I ran into a similar issue with nested objects when throwing an exception: https://psalm.dev/r/f7ffc1d343 If I comment out the |
I found these snippets: https://psalm.dev/r/f7ffc1d343<?php
/** @var object{Wrapper: object{
* Header: object{UID: string, Status: string}
* }} $resp
*/
$result = $resp->Wrapper;
if ($result->Header->Status !== "OK") {
throw new Exception("Response failed");
}
return $result->Header->UID;
|
I have the exact same issue. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
I've noticed an issue when accessing multiple nested object properties.
Hopefully this snippet explains the issue:
Link to the snippet https://psalm.dev/r/4ec39c5d44
FYI this only happens with nested objects, accessing multiple properties directly on
$response
works as expected.The text was updated successfully, but these errors were encountered: