public getClassAnnotations ( string $className, string $annotationClassName = null ) : array | ||
$className | string | Name of the class |
$annotationClassName | string | Annotation to filter for |
return | array |
public function getClassAnnotations($className, $annotationClassName = null)
{
$className = $this->prepareClassReflectionForUsage($className);
$annotationClassName = $annotationClassName === null ? null : $this->cleanClassName($annotationClassName);
if (!isset($this->classReflectionData[$className][self::DATA_CLASS_ANNOTATIONS])) {
return [];
}
if ($annotationClassName === null) {
return $this->classReflectionData[$className][self::DATA_CLASS_ANNOTATIONS];
}
$annotations = [];
foreach ($this->classReflectionData[$className][self::DATA_CLASS_ANNOTATIONS] as $annotation) {
if ($annotation instanceof $annotationClassName) {
$annotations[] = $annotation;
}
}
return $annotations;
}
/** * Builds the class documentation block for the specified class keeping doc comments and vital annotations * * @return string $methodDocumentation DocComment for the given method */ protected function buildClassDocumentation() { $classDocumentation = "/**\n"; $classReflection = new ClassReflection($this->fullOriginalClassName); $classDescription = $classReflection->getDescription(); $classDocumentation .= ' * ' . str_replace("\n", "\n * ", $classDescription) . "\n"; foreach ($this->reflectionService->getClassAnnotations($this->fullOriginalClassName) as $annotation) { $classDocumentation .= ' * ' . Compiler::renderAnnotation($annotation) . "\n"; } $classDocumentation .= " */\n"; return $classDocumentation; }