mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-18 05:48:21 +01:00
commit
d4743ca43d
@ -70,9 +70,9 @@ Tip: If you have EasyCodingStandard, you can start your set with [`ecs-after-rec
|
||||
|
||||
## Try Rector Online
|
||||
|
||||
Too litle time to download?
|
||||
Too litle time to download?
|
||||
|
||||
We have **[online demo](https://getrector.org/demo) just for you!**
|
||||
We have **[online demo](https://getrector.org/demo) just for you!**
|
||||
|
||||
## Install
|
||||
|
||||
|
@ -29,14 +29,20 @@ final class AssertChoiceTagValueNode extends AbstractConstraintTagValueNode
|
||||
*/
|
||||
private $strict;
|
||||
|
||||
/**
|
||||
* @var array|null
|
||||
*/
|
||||
private $choices;
|
||||
|
||||
/**
|
||||
* @param mixed[]|string|null $callback
|
||||
*/
|
||||
public function __construct($callback, ?bool $strict, string $annotationContent)
|
||||
public function __construct($callback, ?bool $strict, string $annotationContent, ?array $choices)
|
||||
{
|
||||
$this->callback = $callback;
|
||||
$this->strict = $strict;
|
||||
$this->resolveOriginalContentSpacingAndOrder($annotationContent);
|
||||
$this->choices = $choices;
|
||||
}
|
||||
|
||||
public function __toString(): string
|
||||
@ -49,6 +55,8 @@ final class AssertChoiceTagValueNode extends AbstractConstraintTagValueNode
|
||||
} else {
|
||||
$contentItems['callback'] = sprintf('callback="%s"', $this->callback);
|
||||
}
|
||||
} elseif ($this->choices) {
|
||||
$contentItems[] = $this->printArrayItem($this->choices);
|
||||
}
|
||||
|
||||
if ($this->strict !== null) {
|
||||
|
@ -36,6 +36,6 @@ final class AssertChoicePhpDocNodeFactory extends AbstractPhpDocNodeFactory
|
||||
|
||||
$annotationContent = $this->resolveContentFromTokenIterator($tokenIterator);
|
||||
|
||||
return new AssertChoiceTagValueNode($choice->callback, $choice->strict, $annotationContent);
|
||||
return new AssertChoiceTagValueNode($choice->callback, $choice->strict, $annotationContent, $choice->choices);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace Rector\Php74\Tests\Rector\Property\TypedPropertyRector\Fixture;
|
||||
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
class AssertChoice
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
* @Assert\Choice({"chalet", "apartment"})
|
||||
*/
|
||||
public $type;
|
||||
}
|
||||
|
||||
?>
|
||||
-----
|
||||
<?php
|
||||
|
||||
namespace Rector\Php74\Tests\Rector\Property\TypedPropertyRector\Fixture;
|
||||
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
class AssertChoice
|
||||
{
|
||||
/**
|
||||
* @Assert\Choice({"chalet", "apartment"})
|
||||
*/
|
||||
public string $type;
|
||||
}
|
||||
|
||||
?>
|
@ -35,6 +35,11 @@ final class ArrayItemStaticHelper
|
||||
{
|
||||
// 1. remove unused items
|
||||
foreach (array_keys($contentItems) as $key) {
|
||||
// generic key
|
||||
if (is_int($key)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (in_array($key, $orderedVisibleItems, true)) {
|
||||
continue;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user