Skip to content

PHP 8.3 Lazy static initialization for non constants #8073

@Wukkopi

Description

@Wukkopi

Apache NetBeans version

Apache NetBeans 24

What happened

I'm getting syntax error on valid syntax when language level is on 8.3.

Since PHP 8.3 lazy static initialization happens during runtime instead of compile time, allowing non-constants to be assigned (functions, and even class variables).

Language / Project Type / NetBeans Component

No response

How to reproduce

class MyClass
{
    private int $variable = 1;
    function run() : void
    {
        static $functionResult = rand(); // shows "unexpected '(' after rand" error
        static $classVariable = $this->variable; // shows "unexpected '$this' after =" error
    }
}

Did this work correctly in an earlier version?

No / Don't know

Operating System

Debian 12

JDK

OpenJDK 64-Bit Server VM (build 17.0.13+11-Debian-2deb12u1, mixed mode, sharing)

Apache NetBeans packaging

Apache NetBeans binary zip

Anything else

No response

Are you willing to submit a pull request?

No

Metadata

Metadata

Assignees

Labels

PHP[ci] enable extra PHP tests (php/php.editor)kind:bugBug report or fix

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions