Skip to content

Add support for PHP 7.4 typed properties while type guessing #51

@mattjanssen

Description

@mattjanssen

The TypeTokenFactory could be fixed and enhanced to support PHP typed properties.

Fix:

The following currently throws an exception if it encounters a non-initialized typed property:

$property->getDeclaringClass()->getDefaultProperties()[$property->getName()];

See https://3v4l.org/gVdKO to illustrate why this happens.
An easy fix would be to add ?? null to the end.

Enhancement:

Somewhere in this chain of guessing the property's type could be a check for the property type:

$propertyAsTyped = $property->getType()->getName();

Obviously it would need a PHP version check around execution, and a null check in case it's not typed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions