private static function parse() { if (self::$data === null || self::$scannedIncludePath !== get_include_path()) { $include_path = explode(PATH_SEPARATOR, get_include_path()); $files = array(); foreach ($include_path as $path) { if (!file_exists($path)) { continue; } foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path)) as $filename) { if (substr_compare($filename->getRealPath(), ".php", -4) === 0) { $files[$filename->getRealPath()] = $filename->getRealPath(); } } } self::$data = array(); $annotations = null; foreach ($files as $file) { $matcher = new Customweb_Annotation_Parser_AnnotationsMatcher(); $tokens = token_get_all(file_get_contents($file)); $max = count($tokens); $i = 0; while ($i < $max) { $token = $tokens[$i]; if (is_array($token)) { list($code, $value) = $token; switch ($code) { case T_DOC_COMMENT: $comment = $value; break; case T_CLASS: case T_INTERFACE: $class = self::getString($tokens, $i, $max); if ($comment !== false) { $matcher->matches($comment, $annotations); foreach ($annotations as $key => $annotation) { self::$data[$class][] = $annotation; } $comment = false; } break; case T_VARIABLE: if ($comment !== false) { $field = substr($token[1], 1); $matcher->matches($comment, $annotations); foreach ($annotations as $key => $annotation) { self::$data[$class . '::$' . $field][] = $annotation; } $comment = false; } break; case T_FUNCTION: if ($comment !== false) { $function = self::getString($tokens, $i, $max); $matcher->matches($comment, $annotations); foreach ($annotations as $key => $annotation) { self::$data[$class . '::' . $function][] = $annotation; } $comment = false; } break; // ignore // ignore case T_WHITESPACE: case T_PUBLIC: case T_PROTECTED: case T_PRIVATE: case T_ABSTRACT: case T_FINAL: case T_VAR: case T_COMMENT: break; default: $comment = false; break; } } else { $comment = false; } $i++; } } self::$sortByTarget = null; self::$scannedIncludePath = get_include_path(); } return self::$data; }