/** * Reads annotations for a selected property in the class * * @param ReflectionProperty $property * @param ClassMetadata $metadata */ private function readProperty($property, $metadata) { $reflClass = $metadata->getReflectionClass(); // Skip if this property is not from this class if ($property->getDeclaringClass()->getName() != $metadata->getClassName()) { return; } //Iterate over all annotations foreach ($this->reader->getPropertyAnnotations($property) as $rule) { //Skip is its not a rule if (!$rule instanceof Rules\Rule) { continue; } //Add Rule $metadata->addPropertyRule($property->getName(), $rule); } }
public static function createProxyClassFile($proxyPath, ClassMetadata $classMetadata) { $classReflection = new \ReflectionClass($classMetadata->getClassName()); $replaces = array('CLASS_NAMESPACE' => $classReflection->getNamespaceName(), 'CLASS_NAME' => $classReflection->getShortName(), 'BASE_CLASS' => '\\' . $classReflection->getName()); $proxyFileContent = file_get_contents(__DIR__ . '/Proxy.template'); foreach ($replaces as $key => $value) { $proxyFileContent = str_replace('##' . $key . '##', $value, $proxyFileContent); } file_put_contents($proxyPath, $proxyFileContent); require_once $proxyPath; }