Skip to content

Commit

Permalink
Remove deprecated code
Browse files Browse the repository at this point in the history
  • Loading branch information
odolbeau committed Dec 5, 2023
1 parent 93594a2 commit f5770c3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 42 deletions.
10 changes: 0 additions & 10 deletions src/Twig/Extension/PhoneNumberHelperExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
use Misd\PhoneNumberBundle\Templating\Helper\PhoneNumberHelper;
use Twig\Extension\AbstractExtension;
use Twig\TwigFilter;
use Twig\TwigFunction;
use Twig\TwigTest;

/**
Expand All @@ -41,15 +40,6 @@ public function __construct(PhoneNumberHelper $helper)
$this->helper = $helper;
}

public function getFunctions(): array
{
return [
// Deprecated in favor of the phone_number_format filter
new TwigFunction('phone_number_format', [$this->helper, 'format'], ['deprecated' => '1.2']),
new TwigFunction('phone_number_is_type', [$this->helper, 'isType'], ['deprecated' => '1.2']),
];
}

public function getFilters(): array
{
return [
Expand Down
37 changes: 5 additions & 32 deletions src/Validator/Constraints/PhoneNumber.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,6 @@ class PhoneNumber extends Constraint
self::INVALID_PHONE_NUMBER_ERROR => 'INVALID_PHONE_NUMBER_ERROR',
];

/**
* @deprecated since PhoneNumberBundle 3.6, use const ERROR_NAMES instead
*
* @var string[]
*/
protected static array $errorNames = self::ERROR_NAMES;

public ?string $message = null;
/**
* @var string|string[]
Expand All @@ -61,42 +54,22 @@ class PhoneNumber extends Constraint
public ?int $format = null;

/**
* @param int|array<mixed>|null $format Specify the format (\libphonenumber\PhoneNumberFormat::*)
* or options (an associative array)
* @param string|string[]|null $type
* @param array<mixed> $options
* @param int|null $format Specify the format (\libphonenumber\PhoneNumberFormat::*)
* @param string|string[]|null $type
* @param array<mixed> $options
*/
#[HasNamedArguments]
public function __construct(int|array $format = null, string|array $type = null, string $defaultRegion = null, string $regionPath = null, string $message = null, array $groups = null, $payload = null, array $options = [])
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 = [])
{
if (\is_array($format)) {
@trigger_error('Usage of the argument $format to specify options is deprecated and will be removed in 4.0. Use "$option" argument instead.', \E_USER_DEPRECATED);
$options = array_merge($format, $options);
} else {
$phoneFormat = $format;
}

parent::__construct($options, $groups, $payload);

$this->message = $message ?? $this->message;
$this->format = $phoneFormat ?? $this->format;
$this->format = $format ?? $this->format;
$this->type = $type ?? $this->type;
$this->defaultRegion = $defaultRegion ?? $this->defaultRegion;
$this->regionPath = $regionPath ?? $this->regionPath;
}

public function getType(): ?string
{
@trigger_error(__METHOD__.' is deprecated and will be removed in 4.0. Use "getTypes" instead.', \E_USER_DEPRECATED);

$types = $this->getTypes();
if (0 === \count($types)) {
return null;
}

return reset($types);
}

/**
* @return string[]
*/
Expand Down

0 comments on commit f5770c3

Please sign in to comment.