/** * @test */ public function parseNormal() { \Phake::when($this->commentsParser)->parse(\Phake::anyParameters())->thenReturn(null); $stmts = (include __DIR__ . '/../fixtures/1/Model/Product.php.property_base.cache'); $this->parser->parse($stmts, $this->property, $this->class); \Phake::verify($this->commentsParser)->parse(\Phake::anyParameters()); }
/** * @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; }