Skip to content

Undefined method named "__set_state" #28

@yann-eugone

Description

@yann-eugone

Hello 👋

Thank you for this very handy library 🙏
I'm experiencing with it, trying to automate few things in my code base.

But on some Symfony project of mine, I'm stuck using it because of an error, preventing the whole stack to start:

Attempted to call an undefined method named "__set_state" of class "Symfony\Component\Validator\Constraints\Choice".

The error occurs in the vendor/attributes.php file in that section of the file:

  'Symfony\\Component\\Validator\\Constraints\\All' => 
  array (
    0 => 
    array (
      0 => 
      array (
        0 => 
        array (
          0 => 
          \Symfony\Component\Validator\Constraints\Choice::__set_state(array(
             'payload' => NULL,
             'choices' => 
            array (
              0 => 'all',
            ),
             'callback' => NULL,
             'multiple' => false,
             'strict' => true,
             'min' => NULL,
             'max' => NULL,
             'message' => 'The value you selected is not a valid choice.',
             'multipleMessage' => 'One or more of the given values is invalid.',
             'minMessage' => 'You must select at least {{ limit }} choice.|You must select at least {{ limit }} choices.',
             'maxMessage' => 'You must select at most {{ limit }} choice.|You must select at most {{ limit }} choices.',
             'match' => true,
          )),
        ),
      ),
      1 => 'App\\Entity\\AccessToken',
      2 => 'scopes',
    ),
  ),

It seems to be related to that part of my App code:

use Symfony\Component\Validator\Constraints as Assert;

class AccessToken
{
    public const SCOPES = ['all'];

    /**
     * @var array<string>
     */
    #[Assert\Count(min: 1)]
    #[Assert\All([new Assert\Choice(self::SCOPES)])]
    private array $scopes = [];
}

I believe it is about how nested attributes are handled.
Is there anything I can do to help?

Best regards,
Yann

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions