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

Validator cannot be instantiated #170

Closed
KatzoArano opened this issue May 29, 2024 · 5 comments
Closed

Validator cannot be instantiated #170

KatzoArano opened this issue May 29, 2024 · 5 comments

Comments

@KatzoArano
Copy link

Hi,
On a Sylius project (with Symfony 5.4) I get an issue during my project launch :
Misd\PhoneNumberBundle\Validator\Constraints\PhoneNumber::__construct(): Argument #1 ($format) must be of type ?int, array given

@KatzoArano
Copy link
Author

/**
* @param int|null $format Specify the format (\libphonenumber\PhoneNumberFormat::*)
* @param string|string[]|null $type
* @param array<mixed> $options
*/
#[HasNamedArguments]
public function __construct(int $format = null, string|array $type = null, string $defaultRegion = null, string $regionPath = null, string $message = null, array $groups = null, $payload = null, array $options = [])
{
parent::__construct($options, $groups, $payload);
$this->message = $message ?? $this->message;
$this->format = $format ?? $this->format;
$this->type = $type ?? $this->type;
$this->defaultRegion = $defaultRegion ?? $this->defaultRegion;
$this->regionPath = $regionPath ?? $this->regionPath;
}

Previously, on 3.10.0 version, the constructor accepted an array as format. On my project the constructor receives an array, so if I change the $format type to mixed $format I have no errors.

@maxhelias
Copy link
Collaborator

Hi @KatzoArano !

Yes, since #162 because it was legacy code linked to the annotation which is now better managed as an attribute.
And I see that I made a mistake during the release. 3.10.1 shouldn't exist but rather 4.0.0 to avoid this incompatibility.

@maxhelias
Copy link
Collaborator

3.10.1 has been remove and I created the new one : https://github.com/odolbeau/phone-number-bundle/releases/tag/v4.0.0

@maxhelias
Copy link
Collaborator

Zorte on 😉

@KatzoArano
Copy link
Author

KatzoArano commented May 30, 2024

OK, thanks for your feedback ,
Milesker @maxhelias eta laster arte ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants