Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
mhsdesign opened this issue Jun 14, 2023 · 2 comments · May be fixed by #3214
Open

Comments

@mhsdesign
Copy link
Member

mhsdesign commented Jun 14, 2023

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
     ) {
     }
@mhsdesign mhsdesign changed the title BUG: named arguments with proxy constructor BUG: named arguments with proxied constructor wont work (fx when passing objects as argument) Jun 16, 2023
@mhsdesign
Copy link
Member Author

Implementing this might make #2966 easier ^^

@mhsdesign
Copy link
Member Author

@kitsunet kitsunet linked a pull request Nov 2, 2023 that will close this issue
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging a pull request may close this issue.

1 participant