Skip to content
This repository was archived by the owner on Sep 24, 2020. It is now read-only.
This repository was archived by the owner on Sep 24, 2020. It is now read-only.

Technically valid PHP code causes fatal error #334

@garrettw

Description

@garrettw

If I have a class that contains something like this:

class Something
{
    // ...
    private static $propOne, $propTwo;
    // ...
}

What happens is that after parsing, the resulting ClassDefinition contains both properties, but only one property statement (named for only $propTwo, incidentally).

So far, this partly seems to make sense, but the problem comes in
PHPSA\Compiler\Expression\StaticPropertyFetch::compile() which has the following code:

// ...
if (!$classDefinition->hasProperty($name, true)) {
    // return;
}
$property = $classDefinition->getPropertyStatement($name, true);
if (!$property->isStatic()) { // <<<< LINE 46
    // ...
}
// ...

With the code sample given above, hasProperty() returns true for $propOne, making it skip the first if block. Then, because there is no property statement named for $propOne, calling getPropertyStatement() returns null.
So, on line 46, $property is set to null, making the call to isStatic() cause a fatal error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions