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

Undefined variable when using static keyword in function #2311

Closed
mecha opened this issue Jun 24, 2023 · 1 comment
Closed

Undefined variable when using static keyword in function #2311

mecha opened this issue Jun 24, 2023 · 1 comment

Comments

@mecha
Copy link
Contributor

mecha commented Jun 24, 2023

Static variables in functions always trigger an "Undefined variable" diagnostic:

function foo() {
    static $var = 0;

    $var++; // Undefined variable "$var"
}

Might be worth mentioning that a similar issue was previously reported (#2237) related to using static with class properties.

dantleech added a commit that referenced this issue Jun 24, 2023
dantleech added a commit that referenced this issue Jun 24, 2023
* FAiling test for gh-2311

* Do not report statically declared variables as undefined
@dantleech
Copy link
Collaborator

Fixed in #2312

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

2 participants