/** * Generate the XML Schema for a given class name. * * @param string $className Class name to generate the schema for. * @param string $namespace Namespace prefix. Used to split off the first parts of the class name. * @param \SimpleXMLElement $xmlRootNode XML root node where the xsd:element is appended. * @return void * @author Sebastian Kurfürst <*****@*****.**> */ protected function generateXmlForClassName($className, $namespace, \SimpleXMLElement $xmlRootNode) { $reflectionClass = new \F3\FLOW3\Reflection\ClassReflection($className); if (!$reflectionClass->isSubclassOf($this->abstractViewHelperReflectionClass)) { return; } $tagName = $this->getTagNameForClass($className, $namespace); $xsdElement = $xmlRootNode->addChild('xsd:element'); $xsdElement['name'] = $tagName; $this->docCommentParser->parseDocComment($reflectionClass->getDocComment()); $this->addDocumentation($this->docCommentParser->getDescription(), $xsdElement); $xsdComplexType = $xsdElement->addChild('xsd:complexType'); $xsdComplexType['mixed'] = 'true'; $xsdSequence = $xsdComplexType->addChild('xsd:sequence'); $xsdAny = $xsdSequence->addChild('xsd:any'); $xsdAny['minOccurs'] = '0'; $xsdAny['maxOccurs'] = 'unbounded'; $this->addAttributes($className, $xsdComplexType); }
/** * Reflects the given class and stores the results in this service's properties. * * @param string $className Full qualified name of the class to reflect * @return void * @author Robert Lemke <*****@*****.**> */ protected function reflectClass($className) { $this->log('Reflecting class "' . $className . '" (' . ($this->initialized ? '' : 'not ') . 'initialized)', LOG_DEBUG); $class = new \F3\FLOW3\Reflection\ClassReflection($className); $this->reflectedClassNames[$className] = time(); if ($class->isAbstract()) { $this->abstractClasses[$className] = TRUE; } if ($class->isFinal()) { $this->finalClasses[$className] = TRUE; } $constructor = $class->getConstructor(); if ($constructor instanceof \ReflectionMethod) { $this->classConstructorMethodNames[$className] = $constructor->getName(); } foreach ($this->getParentClasses($class) as $parentClass) { $this->subClasses[$parentClass->getName()][$className] = TRUE; } foreach ($class->getInterfaces() as $interface) { if (!isset($this->abstractClasses[$className])) { $this->interfaceImplementations[$interface->getName()][] = $className; } } foreach ($class->getTagsValues() as $tag => $values) { if (array_search($tag, $this->ignoredTags) === FALSE) { $this->taggedClasses[$tag][] = $className; $this->classTagsValues[$className][$tag] = $values; } } foreach ($class->getProperties() as $property) { $propertyName = $property->getName(); $this->classPropertyNames[$className][] = $propertyName; foreach ($property->getTagsValues() as $tag => $values) { if (array_search($tag, $this->ignoredTags) === FALSE) { $this->propertyTagsValues[$className][$propertyName][$tag] = $values; } } } foreach ($class->getMethods() as $method) { $methodName = $method->getName(); if ($method->isFinal()) { $this->finalMethods[$className . '::' . $methodName] = TRUE; } if ($method->isStatic()) { $this->staticMethods[$className . '::' . $methodName] = TRUE; } if ($method->isPublic()) { $this->methodVisibilities[$className][$methodName] = ' '; } if ($method->isProtected()) { $this->methodVisibilities[$className][$methodName] = '*'; } if ($method->isPrivate()) { $this->methodVisibilities[$className][$methodName] = '-'; } foreach ($method->getTagsValues() as $tag => $values) { if (array_search($tag, $this->ignoredTags) === FALSE) { $this->methodTagsValues[$className][$methodName][$tag] = $values; } } foreach ($method->getParameters() as $parameter) { $this->methodParameters[$className][$methodName][$parameter->getName()] = $this->convertParameterReflectionToArray($parameter, $method); if (isset($this->methodTagsValues[$className][$methodName]['param'][$parameter->getPosition()])) { $parameterAnnotation = explode(' ', $this->methodTagsValues[$className][$methodName]['param'][$parameter->getPosition()], 3); if (count($parameterAnnotation) < 2) { $this->log(' Wrong @param use for "' . $method->getName() . '::' . $parameter->getName() . '": "' . implode(' ', $parameterAnnotation) . '"', LOG_DEBUG); } else { if (isset($this->methodParameters[$className][$methodName][$parameter->getName()]['type']) && $this->methodParameters[$className][$methodName][$parameter->getName()]['type'] !== ltrim($parameterAnnotation[0], '\\')) { $this->log(' Wrong type in @param for "' . $method->getName() . '::' . $parameter->getName() . '": "' . $parameterAnnotation[0] . '"', LOG_DEBUG); } if ($parameter->getName() !== ltrim($parameterAnnotation[1], '$&')) { $this->log(' Wrong name in @param for "' . $method->getName() . '::$' . $parameter->getName() . '": "' . $parameterAnnotation[1] . '"', LOG_DEBUG); } } } } } ksort($this->reflectedClassNames); }
/** * @test * @author Robert Lemke <*****@*****.**> */ public function getParentClassReturnsFLOW3sClassReflection() { $class = new \F3\FLOW3\Reflection\ClassReflection(__CLASS__); $parentClass = $class->getParentClass(); $this->assertType('F3\\FLOW3\\Reflection\\ClassReflection', $parentClass); }