/** * Discovers all the annotations of a given class file * * @param string $class a class file * @return array */ public static function discover($class) { try { if (!file_exists($class)) { throw new Exception($class . " does not exist"); } $text = file($class, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); $annotations = array(); $currentAnnotations = array(); foreach ($text as $key => $line) { if (strpos($line, "* @annotation") !== false) { $currentAnnotations[] = trim(str_replace("* @annotation", "", $line)); } else { $functionName = ""; if (count($currentAnnotations) > 0 && Annotation::discoverFunctionName($line, $functionName)) { $annotations[$functionName] = $currentAnnotations; $currentAnnotations = array(); } unset($text[$key]); } } return $annotations; } catch (Exception $e) { Functions::dump($e->getMessage()); return NULL; } }