Skip to content

BUG: named arguments with proxied constructor wont work (fx when passing objects as argument) #3076

@mhsdesign

Description

@mhsdesign

see 2f7003f

for a failing test to prove ;)

class PrototypeClassJ
 {
     public function __construct(
         public ValueObjectClassA $classA
     ) {
     }
 }

you cant currently instantiate this like

new PrototypeClassJ(classA: $classA);

as the constructor of the proxy class will have no arguments.

a proxy constructor looks like:

#
# Start of Flow generated Proxy code
#
/**
 * A class of scope prototype with a value object as constructor argument
 * @codeCoverageIgnore
 */
class PrototypeClassJ extends PrototypeClassJ_Original implements \Neos\Flow\ObjectManagement\Proxy\ProxyInterface {


    /**
     * Autogenerated Proxy Method
     */
    public function __construct()
    {
        $arguments = func_get_args();


        if (!array_key_exists(0, $arguments)) $arguments[0] = \Neos\Flow\Core\Bootstrap::$staticObjectManager->get('Neos\Flow\Tests\Functional\ObjectManagement\Fixtures\ValueObjectClassA');
        if (!array_key_exists(0, $arguments)) throw new \Neos\Flow\ObjectManagement\Exception\UnresolvedDependenciesException('Missing required constructor argument $classA in class ' . __CLASS__ . '. Note that constructor injection is only support for objects of scope singleton (and this is not a singleton) – for other scopes you must pass each required argument to the constructor yourself.', 1296143788);
        parent::__construct(...$arguments);
    }
}

the proxy constructor should have all arguments, but nullable

     public function __construct(
         ?ValueObjectClassA $classA = null
     ) {
     }

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions