getAttributes() as $attribute) { try { $list[] = new ReflectedAttribute( tag: substr(strrchr($attribute->getName(), "\\"), 1), object: $attribute->newInstance(), arguments: $attribute->getArguments(), ); } catch(\Throwable $e) { throw new \Exception(sprintf("%s for %s in file '%s'", $e->getMessage(), $reflect, static::getObjectName($reflect))); } } return $list; } protected static function getObjectName(Reflector $reflect) : string { switch(true) { case $reflect instanceof ReflectionMethod : case $reflect instanceof ReflectionProperty : return $reflect->class . "::" . $reflect->name; case $reflect instanceof ReflectionClass : return $reflect->name; } throw new \InvalidArgumentException("Given reflector is not supported within getObjectName()."); } protected static function getObjectNamespace(Reflector $reflect) : string { switch(true) { case $reflect instanceof ReflectionMethod : case $reflect instanceof ReflectionProperty : return $reflect->getDeclaringClass()->getNamespaceName(); case $reflect instanceof ReflectionClass : return $reflect->getNamespaceName(); } throw new \InvalidArgumentException("Given reflector is not supported within getObjectNamespace()."); } }