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

feature request: warn about possibly undefined symbols #11110

Open
azjezz opened this issue Oct 5, 2024 · 1 comment
Open

feature request: warn about possibly undefined symbols #11110

azjezz opened this issue Oct 5, 2024 · 1 comment

Comments

@azjezz
Copy link
Contributor

azjezz commented Oct 5, 2024

some symbols can be conditionally defined in PHP, such as those defined within another symbol, or inside a conditional statement ( e.g if ).

Psalm should give a warning about using such symbols.

https://psalm.dev/r/1bc794cbb3

PHPStan handles this properly by emitting an erorr: https://phpstan.org/r/1c264348-8f9a-41b7-854b-b08e9148c67c

Copy link

I found these snippets:

https://psalm.dev/r/1bc794cbb3
<?php

if (PHP_VERSION == 80) {
    function biz(): void {
    }
}

function foo(): void {
    function bar(): void {
        class Baz {
            
        }
    }
    
    bar();
}

biz();

bar();

new Baz();
Psalm output (using commit dee5fe4):

No issues!

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

No branches or pull requests

1 participant