/** * Creates a new FrogTagParser object for $page. */ public function __construct($page) { $this->page = $page; $this->tags = FrogTagsList::get(); }
/** * Parses a php source file for functions whose names start with "tag_". If * a function declaration has a preceding comment, this comment is treated * as brief for the particular tag. * * This parser is actually quite dumb as it doesn't check whether the * parsed function belongs to a class derived from FrogTags. But it checks * if the function belongs to a tag in the tag list. So there should only * be problems if there is an other function with the same name. */ protected function parse_source($string) { $definedTags = FrogTagsList::get(); $this->briefnum = 0; $string = preg_replace_callback("|/\\*(.*)\\*/|Us", array($this, 'comment_to_tag'), $string); // preprocessing preg_match_all("|<(brief-\\d+)>(.*)</\\1>\\s+(public\\s)?\\s*function\\s+tag_(\\w+)\\s*\\(.*\\)\\s*|Us", $string, $matches, PREG_SET_ORDER); foreach ($matches as $match) { $name = $match[4]; $brief = $match[2]; if (isset($definedTags[$name])) { array_push($this->briefs, new FrogTagBrief($name, $brief)); } } }