- Some bugfixes linked to attributes

This commit is contained in:
Dave M. 2023-07-09 12:41:36 -04:00
parent 7c7d8c9d8d
commit dd0f0271a6
3 changed files with 13 additions and 6 deletions

View File

@ -6,7 +6,7 @@
"authors": [ "authors": [
{ {
"name": "Dave Mc Nicoll", "name": "Dave Mc Nicoll",
"email": "mcndave@gmail.com" "email": "info@mcnd.ca"
} }
], ],
"require": {}, "require": {},

View File

@ -136,7 +136,8 @@ class ObjectReflection {
ReflectionMethod::IS_PUBLIC | ReflectionMethod::IS_PUBLIC |
ReflectionMethod::IS_PROTECTED | ReflectionMethod::IS_PROTECTED |
ReflectionMethod::IS_PRIVATE | ReflectionMethod::IS_PRIVATE |
ReflectionMethod::IS_STATIC ReflectionMethod::IS_STATIC |
ReflectionMethod::IS_FINAL
) : array ) : array
{ {
$list = []; $list = [];
@ -168,6 +169,7 @@ class ObjectReflection {
$current = [ $current = [
'name' => $method->getName(), 'name' => $method->getName(),
'classname' => $method->class,
'type' => $method->hasReturnType() && $method->getReturnType() instanceof \ReflectionNamedType ? $method->getReturnType()->getName() : false, 'type' => $method->hasReturnType() && $method->getReturnType() instanceof \ReflectionNamedType ? $method->getReturnType()->getName() : false,
'constructor' => $method->isConstructor(), 'constructor' => $method->isConstructor(),
'destructor' => $method->isDestructor(), 'destructor' => $method->isDestructor(),

View File

@ -192,9 +192,9 @@ class ObjectResolver {
return $list; 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']; return $tagDefinition['object'];
} }
@ -204,8 +204,13 @@ class ObjectResolver {
return new class() implements Annotation {}; 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)"); # throw new \InvalidArgumentException("Annotation class `{$tagDefinition['tag']}` was not found within {$this->objectClass} uses statement (or it's children / traits)");
} }
try {
$obj = new $class(... $arguments['constructor']); $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) { foreach($arguments['setter'] as $key => $value) {
$obj->$key = $value; $obj->$key = $value;