/**
  * @covers common\classes\Application::handle_annotations
  */
 public function test_handle_annotations()
 {
     $obj = new AnnotationDecorated();
     $annotations = ReflectionHelper::get_class_annotations($obj);
     $method = new ReflectionMethod(Application::class, 'handle_annotations');
     $method->setAccessible(true);
     self::assertTrue($method->invoke(null, $obj, $annotations) instanceof AnnotationsDecorator);
     $obj = new NotDecorated();
     $annotations = ReflectionHelper::get_class_annotations($obj);
     self::assertTrue($method->invoke(null, $obj, $annotations) instanceof NotDecorated);
     $obj = new DumbDecorated();
     $annotations = ReflectionHelper::get_class_annotations($obj);
     self::assertTrue($method->invoke(null, $obj, $annotations) instanceof DumbDecorated);
 }
 /**
  * @param $name
  * @param array $params
  * @return mixed
  * @throws \InvalidArgumentException
  */
 public static function get_class($name, array $params = [])
 {
     if (class_exists($name)) {
         if (!array_key_exists($name, static::$instances)) {
             $reflection = new \ReflectionClass($name);
             static::$instances[$name] = $reflection->newInstanceArgs($params);
         }
         $annotations = ReflectionHelper::get_class_annotations(static::$instances[$name]);
         if (count($annotations)) {
             $obj = static::handle_annotations(static::$instances[$name], $annotations);
             static::$instances[$name] = $obj;
         }
         return static::$instances[$name];
     } else {
         throw new \InvalidArgumentException("class {$name} does not exists");
     }
 }
 /**
  * @covers common\helpers\ReflectionHelper::get_class_annotations
  * @covers common\helpers\ReflectionHelper::parse_doc_comment
  */
 public function test_get_class_annotations()
 {
     self::assertEquals(ReflectionHelper::get_class_annotations(Annotated::class), [['name' => 'decorate', 'value' => 'common\\decorators\\AnnotationsDecorator']]);
 }