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

@property-read dynamic property type not working sometimes #11151

Open
M393 opened this issue Nov 7, 2024 · 1 comment · May be fixed by #11152
Open

@property-read dynamic property type not working sometimes #11151

M393 opened this issue Nov 7, 2024 · 1 comment · May be fixed by #11152

Comments

@M393
Copy link

M393 commented Nov 7, 2024

https://psalm.dev/r/f818e2d9d9

Type of $_c should be string instead of ''|mixed.

Copy link

I found these snippets:

https://psalm.dev/r/f818e2d9d9
<?php

/**
 * @property-read string|null $p
 */
class CCC {
    public function __get(string $name) {
        return null;
    }
    public function f(): void {
        $_c = $this->p ?? '';
		/** @psalm-trace $_c */
    }
    public function g(): void {
        $_a = $this->p;
        $_b = $this->p ?? '';
		/** @psalm-trace $_a $_b */
    }
}

$_d = (new CCC())->p;
/** @psalm-trace $_d */
Psalm output (using commit 03ee02c):

INFO: Trace - 22:24 - $_d: null|string

INFO: Trace - 12:0 - $_c: ''|mixed

INFO: Trace - 17:0 - $_a: null|string

INFO: Trace - 17:0 - $_b: string

@MoonE MoonE linked a pull request Nov 9, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant