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

Type not altered after property_exists on object literal #9799

Open
M393 opened this issue May 19, 2023 · 1 comment
Open

Type not altered after property_exists on object literal #9799

M393 opened this issue May 19, 2023 · 1 comment

Comments

@M393
Copy link

M393 commented May 19, 2023

https://psalm.dev/r/55a6758cbd

I'd expect the property to be a string inside the if, but still getting warning about possible undefined property.

Maybe related: #4182, #8196

@psalm-github-bot
Copy link

I found these snippets:

https://psalm.dev/r/55a6758cbd
<?php
/** 
 * @param object{s?: string} $p
 */ 
function f(object $p): void {
    if (property_exists($p, 's')) {
        /** @psalm-trace $p */
    }
}
Psalm output (using commit 0221ff1):

INFO: Trace - 7:0 - $p: object{s?:string}

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

No branches or pull requests

2 participants