mirror of
https://github.com/danog/Valinor.git
synced 2024-11-30 04:39:05 +01:00
misc!: change Attributes::ofType
return type to array
There was no benefits having the return type as `iterable`, but it would make it harder to use the result of the method.
This commit is contained in:
parent
fd11177b06
commit
1a599b0bdf
@ -25,5 +25,5 @@ interface Attributes extends IteratorAggregate, Countable
|
||||
* @param class-string<T> $className
|
||||
* @return list<T>
|
||||
*/
|
||||
public function ofType(string $className): iterable;
|
||||
public function ofType(string $className): array;
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ final class AttributesContainer implements Attributes
|
||||
return false;
|
||||
}
|
||||
|
||||
public function ofType(string $className): iterable
|
||||
public function ofType(string $className): array
|
||||
{
|
||||
return array_values(array_filter(
|
||||
$this->attributes,
|
||||
|
@ -44,7 +44,7 @@ final class CombinedAttributes implements Attributes
|
||||
return $this->delegate->has($className);
|
||||
}
|
||||
|
||||
public function ofType(string $className): iterable
|
||||
public function ofType(string $className): array
|
||||
{
|
||||
return $this->delegate->ofType($className);
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ final class DoctrineAnnotations implements Attributes
|
||||
return $this->delegate->has($className);
|
||||
}
|
||||
|
||||
public function ofType(string $className): iterable
|
||||
public function ofType(string $className): array
|
||||
{
|
||||
return $this->delegate->ofType($className);
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ final class EmptyAttributes implements Attributes
|
||||
return false;
|
||||
}
|
||||
|
||||
public function ofType(string $className): iterable
|
||||
public function ofType(string $className): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ final class NativeAttributes implements Attributes
|
||||
return $this->delegate->has($className);
|
||||
}
|
||||
|
||||
public function ofType(string $className): iterable
|
||||
public function ofType(string $className): array
|
||||
{
|
||||
return $this->delegate->ofType($className);
|
||||
}
|
||||
|
@ -22,7 +22,6 @@ final class AttributeObjectBuilderFactory implements ObjectBuilderFactory
|
||||
|
||||
public function for(ClassDefinition $class, $source): ObjectBuilder
|
||||
{
|
||||
/** @var ObjectBuilderFactory[] $attributes */
|
||||
$attributes = $class->attributes()->ofType(ObjectBuilderFactory::class);
|
||||
|
||||
if (count($attributes) === 0) {
|
||||
|
@ -11,7 +11,6 @@ final class AttributeShellVisitor implements ShellVisitor
|
||||
{
|
||||
public function visit(Shell $shell): Shell
|
||||
{
|
||||
/** @var ShellVisitor[] $visitors */
|
||||
$visitors = $shell->attributes()->ofType(ShellVisitor::class);
|
||||
|
||||
foreach ($visitors as $visitor) {
|
||||
|
@ -14,7 +14,7 @@ final class FakeAttributes implements Attributes
|
||||
return false;
|
||||
}
|
||||
|
||||
public function ofType(string $className): iterable
|
||||
public function ofType(string $className): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ final class FakeNonEmptyAttributes implements Attributes
|
||||
return true;
|
||||
}
|
||||
|
||||
public function ofType(string $className): iterable
|
||||
public function ofType(string $className): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
@ -40,8 +40,8 @@ final class AttributesContainerTest extends TestCase
|
||||
$attributes = new AttributesContainer($object, $date);
|
||||
$filteredAttributes = $attributes->ofType(DateTimeInterface::class);
|
||||
|
||||
self::assertNotSame($filteredAttributes, $attributes);
|
||||
self::assertContainsEquals($date, $filteredAttributes);
|
||||
self::assertNotContains($object, $filteredAttributes);
|
||||
self::assertSame($date, $filteredAttributes[0]);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user