Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -49,6 +55,8 @@ public function __toString(): string
} else {
$contentItems['callback'] = sprintf('callback="%s"', $this->callback);
}
} elseif ($this->choices) {
$contentItems[] = $this->printArrayItem($this->choices);
}

if ($this->strict !== null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ public function createFromNodeAndTokens(Node $node, TokenIterator $tokenIterator

$annotationContent = $this->resolveContentFromTokenIterator($tokenIterator);

return new AssertChoiceTagValueNode($choice->callback, $choice->strict, $annotationContent);
return new AssertChoiceTagValueNode($choice->callback, $choice->strict, $annotationContent, $choice->choices);
}
}
Original file line number Diff line number Diff line change
@@ -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;
}

?>
5 changes: 5 additions & 0 deletions src/BetterPhpDocParser/Utils/ArrayItemStaticHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ public static function filterAndSortVisibleItems(array $contentItems, array $ord
{
// 1. remove unused items
foreach (array_keys($contentItems) as $key) {
// generic key
if (is_int($key)) {
continue;
}

if (in_array($key, $orderedVisibleItems, true)) {
continue;
}
Expand Down