protected function getMethodSrc($methodName, $file = null) { if (is_null($file)) { $file = file($this->analyzer->getReflection()->getFileName()); } try { $startLine = $this->analyzer->getReflection()->getMethod($methodName)->getStartLine() - 1; $endLine = $this->analyzer->getReflection()->getMethod($methodName)->getEndLine() + 1; } catch (\ReflectionException $e) { return ''; } $length = $endLine - $startLine; return implode('', array_slice($file, $startLine, $length)); }
public function defineCollection($entity) { foreach ($this->analyzer->listColumns() as $name => $info) { switch ($info['type']) { case 'array': $value = new ArrayCollection(); break; case 'entity': if ($info['relation']['multi']) { $value = new EntityCollection(EntityCollection::DN, $info['relation']['classname'], array()); } else { $value = null; } break; default: $value = null; } if (!is_null($value)) { $property = $this->analyzer->getReflection()->getProperty($name); $isAccessible = $property->isPublic(); $property->setAccessible(true); $property->setValue($entity, $value); if (!$isAccessible) { $property->setAccessible(false); } } } }