$className */ public function extractAnnotationFromClass(string $className, string $annotation) : ?string { $reflectionClass = new ReflectionClass($className); $docComment = $reflectionClass->getDocComment(); if (!\is_string($docComment)) { return null; } // @see https://3v4l.org/ouYfB // uses 'r?\n' instead of '$' because windows compat $pattern = '#' . \preg_quote($annotation, '#') . '\\s+(?.*?)\\r?\\n#m'; $matches = Strings::match($docComment, $pattern); return $matches['content'] ?? null; } }