flow-development-collection icon indicating copy to clipboard operation
flow-development-collection copied to clipboard

Validator fails if class properties of parameter are not using @var annotations

Open robertlemke opened this issue 3 years ago • 1 comments

Steps to Reproduce

Given, there is an action as part of an Action Controller which expects an object as its argument:

    /**
     * @param MyValueObject $myValueObject
     */
    public function someAction(MyValueObject $myValueObject): string
    { … }

The object's constructor uses a promoted property ($theValue):

final class MyValueObject
{
    protected function __construct(readonly public string $theValue)
    {
    }

    public static function fromString(string $theValue): MyValueObject
    {
        return new MyValueObject($theValue);
    }
}

Expected behavior

The validator checking the arguments for the given action method should accept the value object.

Actual behavior

The validator fails with the following exception:

Exception 1363778104: There is no @var annotation for property "theValue" in class "…\MyValueObject"

Affected Versions

Flow: All currently active versions which should support PHP 7.4 (Flow 5.3 and higher)

robertlemke avatar May 03 '22 10:05 robertlemke

The fix is currently only present in the 5.3 branch, not yet upmerged to later releases.

robertlemke avatar May 18 '22 07:05 robertlemke