This commit is contained in:
Dave Mc Nicoll committed 2024-06-04 13:33:11 +00:00
1 parent c92baf6cda
commit dd680c8a9a
4 files changed
+14 -9

No files matched your search

+10 -5
View File
@@ -39,12 +39,17 @@ class ReflectedClass implements ReflectedInterface
) : $this->methods;
}
public function getAttributes(bool $deep = true, ?string $attributeType = null) : array
public function getAttributes(bool $deep = true, ? string $attributeType = null) : array
{
return array_reverse($this->getOrderedAttributes($deep, $attributeType));
}
protected function getOrderedAttributes(bool $deep = true, ? string $attributeType = null) : array
{
$attributes = $deep ? array_merge(
$this->parent ? $this->parent->getAttributes(true) : [],
array_merge(...array_map(fn($e) => $e->getAttributes(true), $this->interfaces)),
array_merge(...array_map(fn($e) => $e->getAttributes(true), $this->traits)),
$this->parent ? $this->parent->getOrderedAttributes(true) : [],
array_merge(...array_map(fn($e) => $e->getOrderedAttributes(true), $this->interfaces)),
array_merge(...array_map(fn($e) => $e->getOrderedAttributes(true), $this->traits)),
$this->attributes
) : $this->attributes;
@@ -167,7 +172,7 @@ class ReflectedClass implements ReflectedInterface
public function getAttribute(string $attributeType): ?object
{
foreach($this->getAttributes($attributeType) as $attribute) {
foreach($this->getAttributes(true, $attributeType) as $attribute) {
if ($attribute->object instanceof $attributeType) {
return $attribute;
}