- Some bugfixes linked to attributes

This commit is contained in:
mcndave committed 2023-07-09 12:41:36 -04:00
1 parent 7c7d8c9d8d
commit dd0f0271a6
3 files changed
+13 -6

No files matched your search

+9 -4
View File
@@ -192,9 +192,9 @@ class ObjectResolver {
return $list;
}
public function instanciateAnnotationObject(array $tagDefinition) : Annotation
public function instanciateAnnotationObject(array $tagDefinition) : Annotation|\Notes\Attribute
{
if (isset($tagDefinition['object']) && $tagDefinition['object'] instanceof \Attribute) {
if (isset($tagDefinition['object']) && $tagDefinition['object'] instanceof \Notes\Attribute) {
return $tagDefinition['object'];
}
@@ -204,8 +204,13 @@ class ObjectResolver {
return new class() implements Annotation {};
# throw new \InvalidArgumentException("Annotation class `{$tagDefinition['tag']}` was not found within {$this->objectClass} uses statement (or it's children / traits)");
}
$obj = new $class(... $arguments['constructor']);
try {
$obj = new $class(... $arguments['constructor']);
}
catch (\Throwable $e) {
$err = $e::class;
throw new $err(sprintf("An error occured trying to instanciate class definition '%s' given argument '%s' : %s", var_export($tagDefinition, true), var_export($arguments['constructor'], true), $e->getMessage()));
}
foreach($arguments['setter'] as $key => $value) {
$obj->$key = $value;