Skip to content

Undetected syntax error when accessing a constant from a property on PHP < 7.0 #946

@benignant

Description

@benignant

The following code triggers a syntax error on PHP versions below 7.0:

class MyClass
{
    const MY_CONSTANT = 'value';
}

class AnotherClass
{
    public $prop;
    
    public function __construct()
    {
        $this->prop = new MyClass();
    }
}

$instance = new AnotherClass();

echo $instance->prop::MY_CONSTANT; // Parse error: syntax error, unexpected '::' (T_PAAMAYIM_NEKUDOTAYIM)

Can this be detected?

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions