Ejemplo n.º 1
0
 /**
  * @param \ReflectionClass $class
  * @return \Weasel\Common\Annotation\IAnnotationReader
  */
 public function getReaderForClass(\ReflectionClass $class)
 {
     $reader = new AnnotationReader($class, $this->configProvider);
     if (isset($this->logger)) {
         $reader->setLogger($this->logger);
     }
     return $reader;
 }
Ejemplo n.º 2
0
 /**
  * Test for the fix for issue #41
  */
 public function testCompilerLeftOverDocblock()
 {
     $mockConfigProvider = m::mock('\\Weasel\\Annotation\\AnnotationConfigProvider');
     $mockConfigProvider->shouldReceive('get')->with('\\HelloWorld')->andReturn(new Annotation('\\stdClass', array(), 1));
     require __DIR__ . '/resources/AnnotatedClass.php';
     $reader = new AnnotationReader(new \ReflectionClass('\\Weasel_Annotation_TestResources_AnnotatedClass'), $mockConfigProvider);
     $read = $reader->getClassAnnotations();
     // Ordering is important. We need to require the NoDocBlock file immediately to ensure that the last thing
     // parsed was the AnnotatedClass
     require __DIR__ . '/resources/NoDocBlock.php';
     $this->assertNotEmpty($read);
     $reader = new AnnotationReader(new \ReflectionClass('\\Weasel_Annotation_TestResources_NoDocBlock'), $mockConfigProvider);
     $this->assertEmpty($reader->getClassAnnotations());
 }
Ejemplo n.º 3
0
 /**
  * @covers \Weasel\JsonMarshaller\Config\Annotations\JsonCreator
  */
 public function testParseMethodAnnotations()
 {
     $rClass = new \ReflectionClass('\\Weasel\\JsonMarshaller\\Config\\Annotations\\JsonCreator');
     $annotationReader = new AnnotationReader($rClass, new AnnotationConfigurator());
     $found = array();
     foreach ($rClass->getMethods() as $method) {
         /**
          * @var \ReflectionMethod $method
          */
         $name = $method->getName();
         if (substr($name, 0, 2) === '__' && !($method->isStatic() || $method->isConstructor())) {
             continue;
         }
         $found[$name] = $annotationReader->getMethodAnnotations($name);
     }
     $expected = array("__construct" => array('\\Weasel\\Annotation\\Config\\Annotations\\AnnotationCreator' => array(new AnnotationCreator(array(new Parameter("params", '\\Weasel\\JsonMarshaller\\Config\\Annotations\\JsonProperty[]', false))))), "getParams" => array());
     $this->assertEquals($expected, $found);
 }