Skip to content

Commit

Permalink
work with multiple tag types
Browse files Browse the repository at this point in the history
  • Loading branch information
Ondřej Ešler committed Sep 16, 2024
1 parent d7088a0 commit 12fb568
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Fixtures.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function mergeWith(Fixtures $fixtures) : Fixtures {
return new Fixtures(
$this->label,
in_array('write', [$fixtures->mode, $this->mode]) ? 'write' : 'read-only',
array_values(array_unique(array_merge($fixtures->files, $this->files))),
...array_values(array_unique(array_merge($fixtures->files, $this->files))),
);
}
}
12 changes: 8 additions & 4 deletions src/FixturesAnnotationToAttributeRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,19 @@ public function refactor(Node $node): ?Node

foreach ($phpDocInfo->getTagsByName('fixtures') as $fixturesPhpDocTagNode) {
/** @var PhpDocTagNode $fixturesPhpDocTagNode */
if (!$fixturesPhpDocTagNode->value instanceof DoctrineAnnotationTagValueNode) {
continue; // no value

// extract attribute params configuration
if ($fixturesPhpDocTagNode->value instanceof DoctrineAnnotationTagValueNode) {
$fixtures = explode(' ', $fixturesPhpDocTagNode->value->getAttribute('attribute_comment'));
} elseif ($fixturesPhpDocTagNode->value instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\GenericTagValueNode) {
$fixtures = explode(' ', $fixturesPhpDocTagNode->value->value);
} else {
continue;
}

// test from doc blocks
$this->phpDocTagRemover->removeTagValueFromNode($phpDocInfo, $fixturesPhpDocTagNode);

// extract attribute params configuration
$fixtures = explode(' ', $fixturesPhpDocTagNode->value->getAttribute('attribute_comment'));

$attributeGroups[] = $this->phpAttributeGroupFactory
->createFromClassWithItems(Fixtures::class, [$fixtures]);
Expand Down

0 comments on commit 12fb568

Please sign in to comment.