public static parseDocComment ( $s ) : array | ||
return | array |
public static function parseDocComment($s)
{
$options = [];
if (!preg_match('#^/\\*\\*(.*?)\\*/#ms', $s, $content)) {
return [];
}
if (preg_match('#^[ \\t\\*]*+([^\\s@].*)#mi', $content[1], $matches)) {
$options[0] = trim($matches[1]);
}
preg_match_all('#^[ \\t\\*]*@(\\w+)([^\\w\\r\\n].*)?#mi', $content[1], $matches, PREG_SET_ORDER);
foreach ($matches as $match) {
$ref =& $options[strtolower($match[1])];
if (isset($ref)) {
$ref = (array) $ref;
$ref =& $ref[];
}
$ref = isset($match[2]) ? trim($match[2]) : '';
}
return $options;
}
private function getAnnotations($file) { $annotations = Helpers::parseDocComment(file_get_contents($file)); $testName = (isset($annotations[0]) ? preg_replace('#^TEST:\\s*#i', '', $annotations[0]) . ' | ' : '') . implode(DIRECTORY_SEPARATOR, array_slice(explode(DIRECTORY_SEPARATOR, $file), -3)); return array($annotations, $testName); }