/** * @param \ReflectionClass $reflection * * @return bool|\SplFixedArray */ public function extractRelations(\ReflectionClass $reflection) { $propertyList = $reflection->getDefaultProperties(); if ($this->cache && ($res = $this->cache->get(md5(json_encode($propertyList))))) { return $res; } $relation = []; foreach ($propertyList as $name => $value) { $comment = $reflection->getProperty($name)->getDocComment(); $d = $this->parser->parse($comment); if (!$d) { continue; } $relation[] = ['mapping_id' => $d[0], 'model' => $d[1], 'target' => $name]; } if ($this->cache) { $this->cache->set(md5(json_encode($propertyList)), $relation, 300); } return $relation; }
/** * @test */ public function ormParserWithValidAnnotationString() { $parser = new AnnotationOrmParser(); $returnValue = $parser->parse($this->validDocProvider()); self::assertEquals([['something', 'stuff']], $returnValue); }