-
Notifications
You must be signed in to change notification settings - Fork 668
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
Undefined variables in string interpolation are not being caught #5331
Labels
Comments
I found these snippets: https://psalm.dev/r/d5662fa596<?php
(function () : void {
echo (fn(string $b) => "$b - $undefined")("hello");
})();
|
Simplified and added one more variation: https://psalm.dev/r/9520a78b52 |
I found these snippets: https://psalm.dev/r/9520a78b52<?php
function a(): void {
fn(): string => (string) $undefined;
}
function b(): void {
fn(): string => "$undefined";
}
|
weirdan
added a commit
to weirdan/psalm
that referenced
this issue
Mar 8, 2021
Previously Psalm would assume that any variable it sees in the arrow function body is defined (and mixed, if it's not available in the outer scope). This prevented undefined variable detection. Dropping that assumption allows it to work. Fixes vimeo#5331
muglug
pushed a commit
that referenced
this issue
Mar 11, 2021
Previously Psalm would assume that any variable it sees in the arrow function body is defined (and mixed, if it's not available in the outer scope). This prevented undefined variable detection. Dropping that assumption allows it to work. Fixes #5331
Thanks, @muglug! |
And thanks @weirdan for the PR! :) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Taken from the convo @ https://twitter.com/mattbrowndev/status/1367965245084491783 (sorry, I just happen to review too much code :| )
https://psalm.dev/r/d5662fa596
It should report
$undefined
as undefined, but it doesn't.See https://3v4l.org/D8tJR for runtime verification.
The text was updated successfully, but these errors were encountered: