Exemplo n.º 1
0
 public function testCached()
 {
     $meta = new Meta();
     $meta->set('a', 1);
     $meta->ofProperty('b')->set('c', 2);
     $this->cache->set('abc', $meta);
     $this->assertTrue($this->cache->has('abc'));
     $this->assertEquals($meta, $this->cache->get('abc'));
     $this->assertNotSame($meta, $this->cache->get('abc'));
 }
Exemplo n.º 2
0
 /**
  * Get metadata
  * 
  * @return \Jasny\Meta
  */
 public static function meta()
 {
     $class = get_called_class();
     if (!isset(self::$meta__[$class])) {
         self::$meta__[$class] = \Jasny\Meta::fromAnnotations(new \ReflectionClass($class));
     }
     return self::$meta__[$class];
 }
Exemplo n.º 3
0
 /**
  * Add metadata for properties of a class
  *
  * @param Meta             $meta
  * @param ReflectionClass $refl
  */
 protected function addPropertyAnnotations(Meta $meta, ReflectionClass $refl)
 {
     $props = $refl->getProperties();
     foreach ($props as $prop) {
         $propertyMeta = $this->create($prop);
         $meta->ofProperty($prop->getName())->set($propertyMeta);
     }
 }