Skip to content

Commit 8195c6e

Browse files
committed
fix register+non existing attributes pbs
1 parent 6e7696c commit 8195c6e

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

src/Ubiquity/attributes/AttributesEngine.php

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,28 @@ protected function attributesNewInstances(array $attributes): array {
4343
public function getAnnotsOfClass(string $class, ?string $annotationType = null): array {
4444
$reflect = new \ReflectionClass($class);
4545
$annotClass = $this->getAnnotationByKey($annotationType);
46-
return $this->attributesNewInstances($reflect->getAttributes($annotClass));
46+
if (isset($annotClass)) {
47+
return $this->attributesNewInstances($reflect->getAttributes($annotClass));
48+
}
49+
return [];
4750
}
4851

4952
public function getAnnotsOfMethod(string $class, string $method, ?string $annotationType = null): array {
5053
$reflect = new \ReflectionMethod($class, $method);
5154
$annotClass = $this->getAnnotationByKey($annotationType);
52-
return $this->attributesNewInstances($reflect->getAttributes($annotClass));
55+
if (isset($annotClass)) {
56+
return $this->attributesNewInstances($reflect->getAttributes($annotClass));
57+
}
58+
return [];
5359
}
5460

5561
public function getAnnotsOfProperty(string $class, string $property, ?string $annotationType = null): array {
5662
$reflect = new \ReflectionProperty($class, $property);
5763
$annotClass = $this->getAnnotationByKey($annotationType);
58-
return $this->attributesNewInstances($reflect->getAttributes($annotClass));
64+
if (isset($annotClass)) {
65+
return $this->attributesNewInstances($reflect->getAttributes($annotClass));
66+
}
67+
return [];
5968
}
6069

6170
public function start(string $cacheDirectory): void {
@@ -92,7 +101,7 @@ public function getAnnotationByKey(?string $key = null): ?string {
92101
}
93102

94103
public function registerAnnotations(array $nameClasses): void {
95-
\array_merge(self::$registry, $nameClasses);
104+
self::$registry = \array_merge(self::$registry, $nameClasses);
96105
}
97106

98107
public function getAnnotation(?object $container, string $key, array $parameters = []): ?object {
@@ -141,7 +150,7 @@ public function is(string $key, object $annotation): bool {
141150
}
142151

143152
public function registerAcls(): void {
144-
\array_merge(self::$registry, [
153+
self::$registry = \array_merge(self::$registry, [
145154
'allow' => \Ubiquity\attributes\items\acl\Allow::class,
146155
'resource' => \Ubiquity\attributes\items\acl\Resource::class,
147156
'permission' => \Ubiquity\attributes\items\acl\Permission::class

0 commit comments

Comments
 (0)