/**
  * @test
  */
 public function parseMethodComment()
 {
     \Phake::when($this->annotationsParser)->parse(\Phake::anyParameters())->thenReturn([]);
     $stmts = (include __DIR__ . '/../fixtures/1/Model/Product.php.method.cache');
     $method = $this->parser->parse($stmts, $this->class);
     $this->assertThat($method->comment, $this->equalTo('Sets updated datetimedetailed description here'));
 }
Example #2
0
 /**
  */
 public function testParse()
 {
     $res = $this->object->parse();
     $this->assertTrue(is_array($res));
     $this->assertEquals(4, count($res));
     $this->assertEquals("test", $res[3]['name']);
     $this->assertEquals("factory", $res[2]['name']);
     $this->assertEquals("testMethod", $res[1]['name']);
     $this->assertEquals("__construct", $res[0]['name']);
 }
 /**
  * @param Stmt $classStmt
  * @param $namespace
  * @param $source
  * @return Element\ClassModel
  */
 public function parse(Stmt $classStmt, $namespace, $source)
 {
     $attrs = $classStmt->getAttributes();
     $class = $this->classFactory->create($classStmt->name);
     $class->setNamespace($namespace);
     $class->setSource($source, $attrs['startLine'], 0);
     // annotation
     $this->commentsParser->parse($attrs, $class);
     // property
     $properties = array_filter($classStmt->stmts, function ($stmt) {
         return $this->propertyParser->match($stmt);
     });
     array_map(function (Stmt $propertiesStmt) use($class) {
         $prop = $this->propertyParser->parse($propertiesStmt, $class);
         $this->propertyAnnotationParser->parse($propertiesStmt, $prop, $class);
         $varAnnotations = $prop->annotations->withName('var');
         if (!$varAnnotations->isEmpty()) {
             /** @var Element\Annotation $var */
             $var = $varAnnotations->first();
             $prop->setAccessModifier($var->parameters);
         }
     }, $properties);
     // method
     $methods = array_filter($classStmt->stmts, function ($stmt) {
         return $this->methodParser->match($stmt);
     });
     array_map(function ($methodStmt) use($class) {
         $this->methodParser->parse($methodStmt, $class);
     }, $methods);
     return $class;
 }