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

Broken magic properties #9692

Closed
danog opened this issue Apr 21, 2023 · 3 comments · Fixed by #9693
Closed

Broken magic properties #9692

danog opened this issue Apr 21, 2023 · 3 comments · Fixed by #9693
Labels

Comments

@danog
Copy link
Collaborator

danog commented Apr 21, 2023

https://psalm.dev/r/5c15139bd5, caused by #9656, working on a fix...

@psalm-github-bot
Copy link

psalm-github-bot bot commented Apr 21, 2023

I found these snippets:

https://psalm.dev/r/5c15139bd5
<?php

/** @property int $content */
class a {
    public function __get($name)
    {
        return 0;
    }
}

/** @var a&object{__tempProperties: "lmao"} */
$r = null;
/** @psalm-trace $v */
$v = $r->content;
Psalm output (using commit a97b6b8):

INFO: MixedAssignment - 14:1 - Unable to determine the type that $v is being assigned to

INFO: Trace - 14:1 - $v: mixed

INFO: UnusedVariable - 14:1 - $v is never referenced or the value is not used

INFO: MissingParamType - 5:27 - Parameter $name has no provided type

@danog danog added the bug label Apr 21, 2023
@orklah
Copy link
Collaborator

orklah commented Apr 21, 2023

are we sure that's what we want?

Intersecting an object with a content property and another object with a __tempProperties is pretty weird, no? Shouldn't that be a union?

@danog
Copy link
Collaborator Author

danog commented Apr 21, 2023

That's an internal detail, our plugin uses intersections to represent "temporary" properties that may be attached to an object (ugly, I know, will phase them out completely eventually).
The crux of the issue is that property fetches on an intersection of a shaped object and a named object are broken.

danog added a commit to nicelocal/psalm that referenced this issue Apr 21, 2023
@danog danog mentioned this issue Apr 21, 2023
orklah added a commit that referenced this issue Apr 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants