mirror of
https://github.com/danog/Valinor.git
synced 2024-11-30 04:39:05 +01:00
fix: return indexed list of attributes when filtering on type
This commit is contained in:
parent
718d3c1bc2
commit
66aa4d688a
@ -7,6 +7,7 @@ namespace CuyZ\Valinor\Definition;
|
||||
use Traversable;
|
||||
|
||||
use function array_filter;
|
||||
use function array_values;
|
||||
use function count;
|
||||
|
||||
/** @internal */
|
||||
@ -33,10 +34,10 @@ final class AttributesContainer implements Attributes
|
||||
|
||||
public function ofType(string $className): iterable
|
||||
{
|
||||
return array_filter(
|
||||
return array_values(array_filter(
|
||||
$this->attributes,
|
||||
static fn (object $attribute): bool => $attribute instanceof $className
|
||||
);
|
||||
));
|
||||
}
|
||||
|
||||
public function count(): int
|
||||
|
@ -41,6 +41,14 @@ final class ObjectBuilderStrategyMappingTest extends IntegrationTest
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
*/
|
||||
#[Attribute(Attribute::TARGET_CLASS)]
|
||||
final class ForeignAttribute
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
*/
|
||||
@ -54,8 +62,10 @@ final class ObjectBuilderStrategyAttribute implements ObjectBuilderFactory
|
||||
}
|
||||
|
||||
/**
|
||||
* @ForeignAttribute
|
||||
* @StaticMethodConstructor("create")
|
||||
*/
|
||||
#[ForeignAttribute]
|
||||
#[StaticMethodConstructor('create')]
|
||||
final class ObjectWithBuilderStrategyAttribute
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user