debug(__METHOD__,$c->name); if ($inclass) { $c->rfilename = $thiz->rfilename; $c->activeFile = $thiz->activeFile; $thiz->classes[$thiz->_active_class]->Operations[$c->name] = $c; $thiz->classes[$thiz->_active_class]->Operations[$c->name]->class = $thiz->classes[$thiz->_active_class]->name; // silly stuff :) // merge method's author with class. // hey this is a cool use of all those array functions! if (@$a = $thiz->classes[$thiz->_active_class]->Operations[$c->name]->description->author) $thiz->classes[$thiz->_active_class]->description->author = array_reverse(array_values( array_unique (array_reverse(array_merge( $thiz->classes[$thiz->_active_class]->description->author, $a))))); // echo $thiz->methods++; } else { $c->active_package = &$thiz->packages[$thiz->active_package->name]; $c->rfilename = $thiz->rfilename; $c->activeFile = $thiz->activeFile; $thiz->active_directory->functions[] = $c; //$c->active_package->functions[$c->name] = $c; } $thiz->pos = $c->endpos; } } var $_active_method; // return object (PHP_CodeDoc_MethodParser) function parse(PHP_CodeDoc_Parser $thiz) { // really parse // before pos... 2 points... /// probably need to look back for 'string'? $flags= array($thiz->look_nws(-1), $thiz->look_nws(-2), $thiz->look_nws(-3), $thiz->look_nws(-4)); $startpos = $thiz->pos; if ($npos = $thiz->find_token_pos($startpos,array(T_STRING),'(')) { $n = @$thiz->tokens[$npos][1]; } else { return; } $thiz->pos = $thiz->pos + 4; $method = new PHP_CodeDoc_Data_Method; $method->name = $n; $method->type = "Public"; $method->isPublic = 1; $method->isStatic = in_array(T_STATIC, $flags) ? 1 : 0; $method->isFinal = in_array(T_FINAL, $flags) ? 1 : 0; $method->visibility = 1; if (in_array(T_PRIVATE, $flags)) { $method->type = "Private"; $method ->isPublic = 0; $method->visibility = 0; } if (in_array(T_PROTECTED, $flags)) { $method->type = "Protected"; $method ->isPublic = 0; $method->visibility = 0; } $method->Param = PHP_CodeDoc_Parser_Method::_get_args($thiz,$method); if ($v = PHP_CodeDoc_Parser_Comment::parse($thiz)) { $method->description = $v; } $thiz->pos = $startpos; PHP_CodeDoc_Parser_Method::_store_method_tokens($thiz,$method); // store the array of objects so It can be printed out! $thiz->pos = $startpos; $method->endpos = $thiz->endpos; return $method; } function _store_method_tokens(PHP_CodeDoc_Parser $thiz, &$method) { //remember the tokens for a method.. (for printing later) //return; $tokens=array(); $n=0; $in_method =0; $inbrak =0; $level=0; $pos = $thiz->pos; $method->tokenStart = $thiz->pos; $startpos = $thiz->pos; while ($pos < $thiz->total) { $v = $thiz->tokens[$pos]; if (is_array($v)) { if (!$inbrak && $v[0] == T_CURLY_OPEN) { if ($level ==0) $in_method=1; $level++; } //if ($v[1] && $v[1]{0} == "(") // $inbrak++; //$v[0] = token_name($v[0]); $v[2]= "{$level}:{$inbrak}"; } else { if (!$inbrak && trim($v) == "}") $level--; if (!$inbrak && trim($v) == "{") { if ($level ==0) $in_method=1; $level++; } if (trim($v) == "(") $inbrak++; if (trim($v) == ")") $inbrak--; } $tokens[$n] = $v; if ($in_method && !$level) { $thiz->endpos = $pos; $method->tokenEnd = $pos; return; } $pos++; $n++; } $thiz->endpos = $thiz->pos+1; $method->tokenEnd = $thiz->pos+1; } function _get_args (PHP_CodeDoc_Parser $thiz, &$method) {// read arguments of a method call $Param= array(); $level =0; $p = -1; while ($thiz->pos < $thiz->total) { $v = $thiz->tokens[$thiz->pos]; if (is_array($v)) { if ($v[0] == T_WHITESPACE) { $thiz->pos++; continue 1; } switch ($v[0]) { case T_VARIABLE: $p++; $Param[$p] = new StdClass; $Param[$p]->name = $v[1]; break; case T_FILE: case T_LINE: case T_LNUMBER: case T_CONSTANT_ENCAPSED_STRING: if (!@$Param[$p]->Value) $Param[$p]->Value = $v[1]; break; case T_ARRAY: $Param[$p]->Value = "array()"; break; } //echo "XXX:{$thiz->pos}:" .token_name($v[0]) . ":{$thiz->level}:". $v[1] .":\n"; } else { //if ($v == "(") $level++; if ($v == "{") return $Param; //if ($v == ",") $current_var = ""; //echo "XXX:{$thiz->pos}:RAW:{$v}\n"; } $thiz->pos++; } return $Param; // shouldnt really get here } }