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: Attributes get warped during proxy building #3326

Open
1 task done
nezaniel opened this issue Mar 7, 2024 · 0 comments
Open
1 task done

BUG: Attributes get warped during proxy building #3326

nezaniel opened this issue Mar 7, 2024 · 0 comments
Assignees
Labels

Comments

@nezaniel
Copy link
Member

nezaniel commented Mar 7, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

Given we have the following PHP Code:

#[Flow\Proxy(false)]
final readonly class MyValueObject
{
    public function __construct(
        public string $value,
    ) {
    }
}
#[Flow\Proxy(false)]
#[\Attribute(\Attribute::TARGET_METHOD)]
final readonly class MyMethodAttribute
{
    public function __construct(
        public MyValueObject $something,
    ) {
    }
}
#[Flow\Proxy(false)]
#[\Attribute(\Attribute::TARGET_PARAMETER)]
final readonly class MyParameterAttribute
{
    public function __construct(
        public MyEnum $somethingElse,
    ) {
    }
}
class MyController {

    #[MyMethodAttribute(new MyValueObject('whatever'))]
    public function myAction(
        #[MyParameterAttribute(MyEnum::SOME_CASE)]
        MyCommand $command
    ): MyCommandResponse {
    }
}

When I set a MethodPrivilege on that action, so that the myAction method is proxied, the resulting proxy method looks as follows:

    /** 
    * Autogenerated Proxy Method 
    */ 
    #[\...\MyMethodAttribute(\...\MyValueObject::__set_state(array( 
         'value' => 'whatever', 
    ))] 
    public function myAction(\...\MyCommand $command) : \...\MyCommandResponse 
    {
    }

leading to two issues:

  • the generated static \MyValueObject::__set_state call is not valid PHP as they are not allowed in attributes. Also, no such method exists anyway.
  • the parameter attributes is lost

Expected Behavior

The proxy builder should leave the attributes as they are

Steps To Reproduce

code see above

Environment

- Flow: >=8.3.7
- PHP: 8.2

Anything else?

No response

@nezaniel nezaniel added the Bug label Mar 7, 2024
@kitsunet kitsunet self-assigned this Mar 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants