class PHP_CodeDoc_Parser_Comment {
- function parse() { // static method !!!! returns a Phpdoc data object
- if ($r = PHP_CodeDoc_Parser_Comment::phpDocParse()) {
+ function parse(PHP_CodeDoc_Parser $thiz) { // static method !!!! returns a Phpdoc data object
+ if ($r = PHP_CodeDoc_Parser_Comment::phpDocParse($thiz)) {
return $r;
}
- return PHP_CodeDoc_Parser_Comment::shortDocParse();
+ return PHP_CodeDoc_Parser_Comment::shortDocParse($thiz);
}
- function phpDocParse() { // parse normal phpdoc comments
+ static function phpDocParse(PHP_CodeDoc_Parser $thiz) { // parse normal phpdoc comments
$desc = new PHP_CodeDoc_Data_PhpDoc;
- if (!$this->last_comment_block)
+ if (!$thiz->last_comment_block)
return;
// clear last comment
- $comment = $this->last_comment_block;
- $this->last_comment_block = "";
+ $comment = $thiz->last_comment_block;
+ $thiz->last_comment_block = "";
if (substr(trim($comment),0,2) != "/*")
return;
$flags['rawdata'] = TRUE;
break;
default:
- $desc->$key = $linedata[2];\r
+ $desc->$key = $linedata[2];\r\r
}
continue;
}
}
- function shortDocParse() { // parse short comments
+ function shortDocParse(PHP_CodeDoc_Parser $thiz) { // parse short comments
$desc = new PHP_CodeDoc_Data_PhpDoc;
- $pos = $this->pos+1;
+ $pos = $thiz->pos+1;
//echo "LOOKING FOR SHORT";
- while($pos < $this->total) {
- $v = $this->tokens[$pos];
+ while($pos < $thiz->total) {
+ $v = $thiz->tokens[$pos];
if (is_array($v)) {
class PHP_CodeDoc_Parser_Method {
- function read($inclass) {
+ static function read(PHP_CodeDoc_Parser $thiz, $inclass) {
- if ($c = PHP_CodeDoc_Parser_Method::parse()) {
- $this->debug(__METHOD__,$c->name);
+ if ($c = PHP_CodeDoc_Parser_Method::parse($thiz)) {
+ $thiz->debug(__METHOD__,$c->name);
if ($inclass) {
- $c->rfilename = $this->rfilename;
- $c->activeFile = $this->activeFile;
+ $c->rfilename = $thiz->rfilename;
+ $c->activeFile = $thiz->activeFile;
- $this->classes[$this->_active_class]->Operations[$c->name] = $c;
- $this->classes[$this->_active_class]->Operations[$c->name]->class = $this->classes[$this->_active_class]->name;
+ $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 :)
// hey this is a cool use of all those array functions!
- if (@$a = $this->classes[$this->_active_class]->Operations[$c->name]->description->author)
- $this->classes[$this->_active_class]->description->author
+ 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(
- $this->classes[$this->_active_class]->description->author, $a)))));
+ $thiz->classes[$thiz->_active_class]->description->author, $a)))));
- // echo $this->methods++;
+ // echo $thiz->methods++;
} else {
- $c->active_package = &$this->packages[$this->active_package->name];
- $c->rfilename = $this->rfilename;
- $c->activeFile = $this->activeFile;
+ $c->active_package = &$thiz->packages[$thiz->active_package->name];
+ $c->rfilename = $thiz->rfilename;
+ $c->activeFile = $thiz->activeFile;
- $this->active_directory->functions[] = $c;
+ $thiz->active_directory->functions[] = $c;
//$c->active_package->functions[$c->name] = $c;
}
- $this->pos = $c->endpos;
+ $thiz->pos = $c->endpos;
}
}
var $_active_method; // return object (PHP_CodeDoc_MethodParser)
- function parse() { // really parse
+ function parse(PHP_CodeDoc_Parser $thiz) { // really parse
// before pos... 2 points...
/// probably need to look back for 'string'?
- $flags= array($this->look_nws(-1), $this->look_nws(-2), $this->look_nws(-3), $this->look_nws(-4));
+ $flags= array($thiz->look_nws(-1), $thiz->look_nws(-2), $thiz->look_nws(-3), $thiz->look_nws(-4));
- $startpos = $this->pos;
- if ($npos = $this->find_token_pos($startpos,array(T_STRING),'(')) {
- $n = @$this->tokens[$npos][1];
+ $startpos = $thiz->pos;
+ if ($npos = $thiz->find_token_pos($startpos,array(T_STRING),'(')) {
+ $n = @$thiz->tokens[$npos][1];
} else {
return;
}
- $this->pos = $this->pos + 4;
+ $thiz->pos = $thiz->pos + 4;
$method = new PHP_CodeDoc_Data_Method;
$method->name = $n;
$method->type = "Public";
}
- $method->Param = PHP_CodeDoc_Parser_Method::_get_args($method);
+ $method->Param = PHP_CodeDoc_Parser_Method::_get_args($thiz,$method);
- if ($v = PHP_CodeDoc_Parser_Comment::parse()) {
+ if ($v = PHP_CodeDoc_Parser_Comment::parse($thiz)) {
$method->description = $v;
}
- $this->pos = $startpos;
- PHP_CodeDoc_Parser_Method::_store_method_tokens($method);
+ $thiz->pos = $startpos;
+ PHP_CodeDoc_Parser_Method::_store_method_tokens($thiz,$method);
// store the array of objects so It can be printed out!
- $this->pos = $startpos;
+ $thiz->pos = $startpos;
- $method->endpos = $this->endpos;
+ $method->endpos = $thiz->endpos;
return $method;
}
- function _store_method_tokens(&$method) { //remember the tokens for a method.. (for printing later)
+ 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 = $this->pos;
- $method->tokenStart = $this->pos;
- $startpos = $this->pos;
- while ($pos < $this->total) {
- $v = $this->tokens[$pos];
+ $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)
$tokens[$n] = $v;
if ($in_method && !$level) {
- $this->endpos = $pos;
+ $thiz->endpos = $pos;
$method->tokenEnd = $pos;
return;
$pos++;
$n++;
}
- $this->endpos = $this->pos+1;
- $method->tokenEnd = $this->pos+1;
+ $thiz->endpos = $thiz->pos+1;
+ $method->tokenEnd = $thiz->pos+1;
}
- function _get_args (&$method) {// read arguments of a method call
+ function _get_args (PHP_CodeDoc_Parser $thiz, &$method) {// read arguments of a method call
$Param= array();
$level =0;
$p = -1;
- while ($this->pos < $this->total) {
- $v = $this->tokens[$this->pos];
+ while ($thiz->pos < $thiz->total) {
+ $v = $thiz->tokens[$thiz->pos];
if (is_array($v)) {
if ($v[0] == T_WHITESPACE) {
- $this->pos++;
+ $thiz->pos++;
continue 1;
}
switch ($v[0]) {
$Param[$p]->Value = "array()";
break;
}
- //echo "XXX:{$this->pos}:" .token_name($v[0]) . ":{$this->level}:". $v[1] .":\n";
+ //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:{$this->pos}:RAW:{$v}\n";
+ //echo "XXX:{$thiz->pos}:RAW:{$v}\n";
}
- $this->pos++;
+ $thiz->pos++;
}
return $Param; // shouldnt really get here
}
var $var; // current return value;
- function read ($inclass) {
+ static function read (PHP_CodeDoc_Parser $thiz, $inclass) {
if (!$inclass) {
return;
}
- if ($c = PHP_CodeDoc_Parser_Var::parse()) {
+ if ($c = PHP_CodeDoc_Parser_Var::parse($thiz)) {
- $c->activeFile = $this->activeFile;
- $this->classes[$this->_active_class]->Attributes[$c->name] = $c;
- $this->classes[$this->_active_class]->Attributes[$c->name]->class =
- $this->classes[$this->_active_class]->name;
+ $c->activeFile = $thiz->activeFile;
+ $thiz->classes[$thiz->_active_class]->Attributes[$c->name] = $c;
+ $thiz->classes[$thiz->_active_class]->Attributes[$c->name]->class =
+ $thiz->classes[$thiz->_active_class]->name;
}
}
- function parse()
+ function parse(PHP_CodeDoc_Parser $thiz)
{ // read var declares in a class
- $flags= array($this->look_nws(-1), $this->look_nws(-2), $this->look_nws(-3), $this->look_nws(-4));
+ $flags= array($thiz->look_nws(-1), $thiz->look_nws(-2), $thiz->look_nws(-3), $thiz->look_nws(-4));
- $startpos = $this->pos;
+ $startpos = $thiz->pos;
$var = new PHP_CodeDoc_Data_Var;
- $var->name = $this->tokens[$this->pos+2][1];
+ $var->name = $thiz->tokens[$thiz->pos+2][1];
$var->type = "Public";
$var->isPublic = 1;
$var->isStatic = 0;
$var->visibility = 1;
- $var->isConstant = $this->tokens[$this->pos][0] == T_CONST;
+ $var->isConstant = $thiz->tokens[$thiz->pos][0] == T_CONST;
if (in_array(T_PRIVATE, $flags)) {
$var->type = "Private";
$var->visibility = 1;
- PHP_CodeDoc_Parser_Var::_store_tokens($var);
+ PHP_CodeDoc_Parser_Var::_store_tokens($thiz, $var);
- if ($v = PHP_CodeDoc_Parser_Comment::parse()) {
+ if ($v = PHP_CodeDoc_Parser_Comment::parse($thiz)) {
$var->description = $v;
}
- $this->pos = $startpos;
+ $thiz->pos = $startpos;
return $var;
/*
remember the tokens for a var.. (for printing later)
*/
- function _store_tokens(&$var) {
+ function _store_tokens(PHP_CodeDoc_Parser $thiz, &$var) {
//return;
- $var->tokenStart=$this->pos;
+ $var->tokenStart=$thiz->pos;
$n=0;
$in_method =0;
$inbrak =0;
$level=0;
- $pos = $this->pos;
- while ($pos < $this->total) {
- $v = $this->tokens[$pos];
+ $pos = $thiz->pos;
+ while ($pos < $thiz->total) {
+ $v = $thiz->tokens[$pos];
if (!is_array($v)) {
if (trim($v) == ";") {
$var->tokenEnd = $pos;
}
-?>
-
+
\ No newline at end of file