3 * tokenizer extension-based parser for PHP code
\r
5 * phpDocumentor :: automatic documentation generator
\r
7 * PHP versions 4 and 5
\r
9 * Copyright (c) 2002-2007 Gregory Beaver
\r
13 * This library is free software; you can redistribute it
\r
14 * and/or modify it under the terms of the GNU Lesser General
\r
15 * Public License as published by the Free Software Foundation;
\r
16 * either version 2.1 of the License, or (at your option) any
\r
19 * This library is distributed in the hope that it will be useful,
\r
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
\r
22 * Lesser General Public License for more details.
\r
24 * You should have received a copy of the GNU Lesser General Public
\r
25 * License along with this library; if not, write to the Free Software
\r
26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
\r
28 * @category ToolsAndUtilities
\r
29 * @package phpDocumentor
\r
30 * @subpackage Parsers
\r
31 * @author Gregory Beaver <cellog@php.net>
\r
32 * @copyright 2002-2007 Gregory Beaver
\r
33 * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
\r
34 * @version CVS: $Id: phpDocumentorTParser.inc,v 1.29 2007/12/14 16:25:00 ashnazg Exp $
\r
35 * @link http://www.phpdoc.org
\r
36 * @link http://pear.php.net/PhpDocumentor
\r
38 * @todo CS cleanup - change package to PhpDocumentor
\r
42 * Tokenizer-based parser for PHP source code
\r
44 * @category ToolsAndUtilities
\r
45 * @package phpDocumentor
\r
46 * @subpackage Parsers
\r
47 * @author Gregory Beaver <cellog@php.net>
\r
48 * @copyright 2002-2007 Gregory Beaver
\r
49 * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
\r
50 * @version Release: 1.4.1
\r
51 * @link http://www.phpdoc.org
\r
52 * @link http://pear.php.net/PhpDocumentor
\r
53 * @todo CS cleanup - change package to PhpDocumentor
\r
54 * @todo CS cleanup - change classname to PhpDocumentor_*
\r
56 class phpDocumentorTParser extends Parser
\r
66 * last event triggered before the current event
\r
76 * full path of the currently parsed file
\r
89 var $_pv_define_name;
\r
90 var $_pv_define_value;
\r
91 var $_pv_define_params_data;
\r
96 var $_pv_func_param;
\r
97 var $_pv_findglobal;
\r
98 var $_pv_global_name;
\r
99 var $_pv_global_val;
\r
101 var $_pv_global_count;
\r
102 var $_pv_include_params_data;
\r
103 var $_pv_include_name;
\r
104 var $_pv_include_value;
\r
106 var $_pv_periodline;
\r
107 var $_pv_paren_count = 0;
\r
109 var $_pv_static_count;
\r
110 var $_pv_static_val;
\r
111 var $_pv_quote_data;
\r
112 var $_pv_function_data;
\r
115 var $_pv_var_value;
\r
122 var $_pf_definename_isset = false;
\r
123 var $_pf_includename_isset = false;
\r
124 var $_pf_get_source = false;
\r
125 var $_pf_getting_source = false;
\r
126 var $_pf_internal = false;
\r
127 var $_pf_in_class = false;
\r
128 var $_pf_in_define = false;
\r
129 var $_pf_in_global = false;
\r
130 var $_pf_in_include = false;
\r
131 var $_pf_in_include_value = false;
\r
132 var $_pf_in_var = false;
\r
133 var $_pf_interface = false;
\r
134 var $_pf_funcparam_val = false;
\r
135 var $_pf_quote_active = false;
\r
136 var $_pf_reset_quote_data = true;
\r
137 var $_pf_useperiod = false;
\r
138 var $_pf_set_var_value = false;
\r
139 var $_pf_var_equals = false;
\r
143 * relative path of the parsed file from the base parse directory
\r
146 var $source_location;
\r
147 var $eventHandlers = array(
\r
148 PARSER_EVENT_ARRAY => 'handleArray',
\r
149 PARSER_EVENT_VAR_ARRAY => 'handleArray',
\r
150 PARSER_EVENT_VAR_ARRAY_COMMENT => 'handleVarArrayComment',
\r
151 PARSER_EVENT_CLASS => 'handleClass',
\r
152 PARSER_EVENT_COMMENT => 'handleComment',
\r
153 PARSER_EVENT_DOCBLOCK_TEMPLATE => 'handleDocBlockTemplate',
\r
154 PARSER_EVENT_END_DOCBLOCK_TEMPLATE => 'handleEndDocBlockTemplate',
\r
155 PARSER_EVENT_LOGICBLOCK => 'handleLogicBlock',
\r
156 PARSER_EVENT_NOEVENTS => 'defaultHandler',
\r
157 PARSER_EVENT_OUTPHP => 'defaultHandler',
\r
158 PARSER_EVENT_DEFINE => 'handleDefine',
\r
159 PARSER_EVENT_DEFINE_PARAMS => 'handleDefineParams',
\r
160 PARSER_EVENT_DEFINE_PARAMS_PARENTHESIS => 'handleDefineParamsParenthesis',
\r
161 PARSER_EVENT_INCLUDE_PARAMS_PARENTHESIS => 'handleIncludeParamsParenthesis',
\r
162 PARSER_EVENT_DOCBLOCK => 'handleDocBlock',
\r
163 PARSER_EVENT_TAGS => 'handleTags',
\r
164 PARSER_EVENT_DESC => 'handleDesc',
\r
165 PARSER_EVENT_DOCKEYWORD => 'handleTag',
\r
166 PARSER_EVENT_DOCKEYWORD_EMAIL => 'handleDockeywordEmail',
\r
167 PARSER_EVENT_EOFQUOTE => 'handleHereDoc',
\r
168 PARSER_EVENT_FUNCTION => 'handleFunction',
\r
169 PARSER_EVENT_FUNCTION_PARAMS => 'handleFunctionParams',
\r
170 PARSER_EVENT_FUNCTION_PARAM_VAR => 'handleFunctionParams',
\r
171 PARSER_EVENT_FUNC_GLOBAL => 'handleFuncGlobal',
\r
172 PARSER_EVENT_DEFINE_GLOBAL => 'handleGlobal',
\r
173 PARSER_EVENT_GLOBAL_VALUE => 'handleGlobalValue',
\r
174 PARSER_EVENT_INLINE_DOCKEYWORD => 'handleInlineDockeyword',
\r
175 PARSER_EVENT_INCLUDE => 'handleInclude',
\r
176 PARSER_EVENT_INCLUDE_PARAMS => 'handleIncludeParams',
\r
177 PARSER_EVENT_QUOTE => 'handleQuote',
\r
178 PARSER_EVENT_PHPCODE => 'handlePhpCode',
\r
179 PARSER_EVENT_SINGLEQUOTE => 'handleSingleQuote',
\r
180 PARSER_EVENT_STATIC_VAR => 'handleStaticVar',
\r
181 PARSER_EVENT_STATIC_VAR_VALUE => 'handleStaticValue',
\r
182 PARSER_EVENT_VAR => 'handleVar',
\r
183 PARSER_EVENT_ACCESS_MODIFIER => 'handleAccessModifier',
\r
184 PARSER_EVENT_IMPLEMENTS => 'handleImplements',
\r
185 PARSER_EVENT_CLASS_CONSTANT => 'handleClassConstant',
\r
188 var $inlineTagHandlers = array(
\r
189 '*' => 'handleDefaultInlineTag',
\r
190 'link' => 'handleLinkInlineTag',
\r
197 function phpDocumentorTParser()
\r
199 $this->allowableTags
\r
200 = $GLOBALS['_phpDocumentor_tags_allowed'];
\r
201 $this->allowableInlineTags
\r
202 = $GLOBALS['_phpDocumentor_inline_doc_tags_allowed'];
\r
203 $this->subscribe(PHPDOCUMENTOR_EVENT_NEWLINENUM,
\r
204 $GLOBALS['phpDocumentor_errors']);
\r
205 $this->subscribe(PHPDOCUMENTOR_EVENT_NEWFILE,
\r
206 $GLOBALS['phpDocumentor_errors']);
\r
207 $this->tagHandlers['author'] = 'authorTagHandler';
\r
208 $this->tagHandlers['filesource'] = 'filesourceTagHandler';
\r
209 $this->setupEventStates();
\r
215 * @param string &$parse_data the parse data
\r
216 * @param string $path the path
\r
217 * @param int $base number of directories to drop off the bottom
\r
218 * when creating names using path
\r
219 * @param bool $packages ???
\r
221 * @staticvar int used for recursion limiting
\r
222 * if a handler for an event is not found
\r
225 function parse (&$parse_data, $path, $base = 0, $packages = false)
\r
227 global $_phpDocumentor_options;
\r
228 static $endrecur = 0;
\r
230 $this->setupStates();
\r
231 if (strlen($parse_data) == 0) {
\r
235 $this->configWordParser($parse_data);
\r
236 // initialize variables so E_ALL error_reporting doesn't complain
\r
240 $page = new ParserPage;
\r
241 $page->setSource($this->_wp->getFileSource());
\r
242 $page->setPath($path);
\r
243 $this->_path = $path;
\r
244 $page->setPackageOutput($packages);
\r
245 $page->setFile(basename($path));
\r
246 $this->publishEvent(PHPDOCUMENTOR_EVENT_NEWFILE, basename($path));
\r
247 //$name = str_replace("/","_",dirname($path)) . "_"
\r
248 // . array_shift(explode(".",$page->getFile()));
\r
249 // fc@fc.clever-soft.com 11/29/2001
\r
250 $name = str_replace(':', '', dirname($path)
\r
251 . PATH_DELIMITER . $page->getFile());
\r
252 $tmp = explode(PATH_DELIMITER, $name);
\r
253 $name = implode("---", array_slice($tmp, $base));
\r
254 // if base is '', drive letter is present in windows
\r
256 $page->setName($name);
\r
257 $temploc = $_phpDocumentor_options['Program_Root']
\r
258 . PATH_DELIMITER . implode(PATH_DELIMITER,
\r
259 array_slice(explode(PATH_DELIMITER, $path), $base));
\r
261 if ($temploc == $_phpDocumentor_options['Program_Root'] . PATH_DELIMITER) {
\r
265 $this->source_location = $source_location = $temploc;
\r
266 $page->setSourceLocation($source_location);
\r
268 $this->publishEvent(PHPDOCUMENTOR_EVENT_PAGE, $page);
\r
271 $lpevent = $pevent;
\r
272 $pevent = $this->_event_stack->getEvent();
\r
273 if ($lpevent != $pevent) {
\r
274 $this->_last_pevent = $lpevent;
\r
277 $this->publishEvent(PHPDOCUMENTOR_EVENT_NEWSTATE, ($pevent + 100));
\r
279 $this->_pv_last_word = $word;
\r
281 $word = $this->_wp->getWord();
\r
282 if (isset($this->_pv_findglobal) && $word == $this->_pv_findglobal) {
\r
283 $this->_last_pevent = $pevent;
\r
285 $this->_event_stack->pushEvent($pevent = PARSER_EVENT_DEFINE_GLOBAL);
\r
287 // in wordparser, have to keep track of lines
\r
288 $this->publishEvent(PHPDOCUMENTOR_EVENT_NEWLINENUM, $this->_wp->linenum);
\r
289 if ($this->_pf_get_source) {
\r
290 if ($word[0] == T_FUNCTION) {
\r
291 $this->_wp->retrievesource($word);
\r
292 $this->_pf_get_source = false;
\r
293 $this->_pf_getting_source = true;
\r
297 if (PHPDOCUMENTOR_DEBUG == true) {
\r
299 if (is_array($this->_pv_last_word)) {
\r
300 echo token_name($this->_pv_last_word[0]) . ' => |'
\r
301 . htmlspecialchars($this->_pv_last_word[1]);
\r
303 echo "|" . $this->_pv_last_word;
\r
306 echo "PEVENT: " . $this->getParserEventName($pevent) . "\n";
\r
307 echo "LASTPEVENT: "
\r
308 . $this->getParserEventName($this->_last_pevent) . "\n";
\r
309 echo $this->_wp->getPos() . ": ";
\r
310 if (is_array($word)) {
\r
311 echo token_name($word[0]) . ' => |'
\r
312 . htmlspecialchars($word[1]);
\r
314 echo '|' . htmlspecialchars($word);
\r
316 echo "|\n-------------------\n\n\n";
\r
319 // $this->_pf_getting_source &&
\r
320 // ($pevent == PARSER_EVENT_DOCBLOCK) ||
\r
321 // ($pevent == PARSER_EVENT_NOEVENTS))
\r
323 addError(PDERROR_SOURCE_TAG_FUNCTION_NOT_FOUND);
\r
324 // throw away source
\r
325 $this->_wp->getSource();
\r
327 if (isset($this->eventHandlers[$pevent])) {
\r
328 $handle = $this->eventHandlers[$pevent];
\r
329 $this->$handle($word, $pevent);
\r
331 debug('WARNING: possible error, no handler for event number '
\r
333 if ($endrecur++ == 25) {
\r
334 die("FATAL ERROR, recursion limit reached");
\r
337 } while (!($word === false));
\r
338 $this->publishEvent(PHPDOCUMENTOR_EVENT_NEWSTATE,
\r
339 PHPDOCUMENTOR_EVENT_END_PAGE);
\r
343 * @param string $word the string word
\r
344 * @param int $pevent the token constant
\r
350 * handler for COMMENT
\r
352 function handleComment($word, $pevent)
\r
354 $this->_wp->backupPos();
\r
355 $this->_event_stack->popEvent();
\r
359 * handler for PHPCODE.
\r
361 * this handler recognizes the <code><?</code> php processor directive,
\r
362 * and begins parsing php code
\r
364 function handlePhpCode($word, $pevent)
\r
366 $e = $this->checkEventPush($word, $pevent);
\r
367 if (isset($this->_pv_findglobal) && $e) {
\r
368 if ($e != PARSER_EVENT_DEFINE_GLOBAL
\r
369 && $e != PARSER_EVENT_ARRAY
\r
370 && $e != PARSER_EVENT_QUOTE
\r
371 && $e != PARSER_EVENT_SINGLEQUOTE
\r
372 && $e != PARSER_EVENT_COMMENT
\r
373 && $e != PARSER_EVENT_COMMENTBLOCK
\r
375 addError(PDERROR_GLOBAL_NOT_FOUND, $this->_pv_findglobal);
\r
376 $this->_wp->findGlobal(false);
\r
377 unset($this->_pv_findglobal);
\r
383 * handler for FUNC_GLOBAL.
\r
385 * this handler recognizes "global $var1, $var2" declarations in a function,
\r
388 function handleFuncGlobal($word, $pevent)
\r
390 if ($this->checkEventPop($word, $pevent)) {
\r
393 if (!$this->checkEventPush($word, $pevent)) {
\r
394 if ($word == ',') {
\r
395 // another variable
\r
396 $this->_pv_global_count++;
\r
398 if (!isset($this->_pv_globals[$this->_pv_global_count])) {
\r
399 $this->_pv_globals[$this->_pv_global_count] = '';
\r
402 // if (!empty($this->_pv_globals[$this->_pv_global_count])) {
\r
403 // $this->_pv_global_count++;
\r
406 if (is_array($word)) {
\r
409 $this->_pv_globals[$this->_pv_global_count] .= $word;
\r
415 * handler for DEFINE_GLOBAL
\r
417 function handleGlobal($word, $pevent)
\r
419 if (isset($this->_pv_findglobal)) {
\r
420 $this->_pv_global_name = $this->_pv_findglobal;
\r
421 unset($this->_pv_findglobal);
\r
423 if (!$this->_pf_in_global) {
\r
424 $this->_pv_linenum = $this->_wp->linenum + 1;
\r
426 $this->_pf_in_global = true;
\r
427 if ($this->checkEventPush($word, $pevent)) {
\r
428 $this->_wp->setWhitespace(true);
\r
430 if ($this->checkEventPop($word, $pevent)) {
\r
431 $this->_pf_in_global = false;
\r
432 $a = new parserGlobal;
\r
433 $a->setDataType($this->_pv_global_type);
\r
434 $this->_pv_global_type = '';
\r
435 $a->setLineNumber($this->_pv_linenum);
\r
436 $a->setName($this->_pv_global_name);
\r
437 if (isset($this->_pv_global_val)) {
\r
438 $a->setValue(trim($this->_pv_global_val));
\r
440 $this->publishEvent(PHPDOCUMENTOR_EVENT_GLOBAL, $a);
\r
441 unset($this->_pv_global_val);
\r
442 unset($this->_pv_global_type);
\r
447 * handler for GLOBAL_VALUE
\r
449 function handleGlobalValue($word, $pevent)
\r
451 if ($this->checkEventPush($word, $pevent)) {
\r
454 $this->_wp->setWhitespace(true);
\r
455 if (!isset($this->_pv_global_val)) {
\r
456 $this->_pv_global_val = '';
\r
458 if ($this->_last_pevent == PARSER_EVENT_ARRAY) {
\r
459 $this->_pv_global_val .= $this->_pv_function_data;
\r
460 $this->_pv_function_data = '';
\r
462 if ($this->_last_pevent == PARSER_EVENT_QUOTE ||
\r
463 $this->_last_pevent == PARSER_EVENT_EOFQUOTE
\r
465 $this->_pv_global_val .= $this->_pv_quote_data;
\r
466 unset($this->_pv_quote_data);
\r
468 if ($this->checkEventPop($word, $pevent)) {
\r
469 $this->_wp->setWhitespace(false);
\r
470 $this->_wp->backupPos();
\r
473 if (is_array($word)) {
\r
476 $this->_pv_global_val .= $word;
\r
480 * handler for STATIC_VAR.
\r
482 * this handler recognizes "static $var1,
\r
483 * $var2 = 6" declarations in a function,
\r
486 function handleStaticVar($word, $pevent)
\r
488 if ($this->checkEventPop($word, $pevent)) {
\r
489 $this->_pv_static_count++;
\r
492 if (!$this->checkEventPush($word, $pevent)) {
\r
493 if ($word == ',') {
\r
494 $this->_pv_static_count++;
\r
497 if (!isset($this->_pv_statics[$this->_pv_static_count])) {
\r
498 $this->_pv_statics[$this->_pv_static_count] = '';
\r
500 if (!empty($this->_pv_statics[$this->_pv_static_count])) {
\r
501 $this->_pv_static_count++;
\r
503 if (is_array($word)) {
\r
506 $this->_pv_statics[$this->_pv_static_count] = $word;
\r
511 * handler for STATIC_VAR_VALUE.
\r
513 * this handler parses the 6 in "static $var1, $var2 = 6"
\r
515 function handleStaticValue($word, $pevent)
\r
517 if ($this->checkEventPush($word, $pevent)) {
\r
520 if (!isset($this->_pv_static_val[$this->_pv_static_count])) {
\r
521 $this->_pv_static_val[$this->_pv_static_count] = '';
\r
523 if ($this->_last_pevent == PARSER_EVENT_QUOTE) {
\r
524 $this->_pv_static_val[$this->_pv_static_count]
\r
525 .= $this->_pv_quote_data;
\r
526 unset($this->_pv_quote_data);
\r
528 if ($this->_last_pevent == PARSER_EVENT_ARRAY) {
\r
529 $this->_pv_static_val[$this->_pv_static_count]
\r
530 .= $this->_pv_function_data;
\r
531 $this->_pv_function_data = '';
\r
533 if ($this->checkEventPop($word, $pevent)) {
\r
534 $this->_pv_static_val[$this->_pv_static_count]
\r
535 = trim($this->_pv_static_val[$this->_pv_static_count]);
\r
536 $this->_wp->backupPos($word);
\r
539 if (is_array($word)) $word = $word[1];
\r
540 $this->_pv_static_val[$this->_pv_static_count] .= $word;
\r
545 * handler for LOGICBLOCK
\r
547 * Logic Blocks are the stuff between { and } in a function/method. A
\r
548 * logic block can clearly contain other logic blocks, as in:
\r
551 * function test($a)
\r
553 * if (testcondition)
\r
554 * { // nested logic block
\r
559 * So, the exit portion of the logic block handler must check to see if the
\r
560 * logic block being exited is the top-level, and it does this by retrieving
\r
561 * the last event from the stack. If it is a function (and not a logic block)
\r
562 * then it backs up the word parser so that the function will exit properly.
\r
566 function handleLogicBlock($word, $pevent)
\r
568 $a = $this->checkEventPush($word, $pevent);
\r
569 if ($this->checkEventPop($word, $pevent)) {
\r
570 $e = $this->_event_stack->popEvent();
\r
571 $this->_event_stack->pushEvent($e);
\r
572 if ($e == PARSER_EVENT_FUNCTION) {
\r
573 $this->_wp->backupPos();
\r
579 * handler for FUNCTION.
\r
581 * this handler recognizes function declarations, and parses them. The body
\r
582 * of the function is parsed by handleLogicBlock()
\r
584 * @see handleLogicBlock()
\r
586 function handleFunction($word, $pevent)
\r
588 if ($e = $this->checkEventPush($word, $pevent)) {
\r
589 $this->_pv_function_data = '';
\r
590 if ($e == PARSER_EVENT_FUNCTION_PARAMS && !is_object($this->_pv_func)
\r
592 addErrorDie(PDERROR_FUNCTION_HAS_NONAME);
\r
594 if ($e == PARSER_EVENT_COMMENT || $e == PARSER_EVENT_COMMENTBLOCK ||
\r
595 $e == PARSER_EVENT_FUNCTION_PARAMS || $e == PARSER_EVENT_LOGICBLOCK
\r
601 if (!isset($this->_pv_func)) {
\r
602 $this->_pv_func = false;
\r
604 if (! is_object($this->_pv_func)) {
\r
605 $this->_pv_globals = array();
\r
606 $this->_pv_global_count = $this->_pv_static_count = 0;
\r
607 if ($this->_pf_in_class) {
\r
608 $this->_pv_func = new parserMethod($this->_pv_cur_class);
\r
610 $this->_pv_func = new parserFunction;
\r
611 unset($this->_accessModifiers);
\r
613 if (isset($this->_accessModifiers)) {
\r
614 $this->_pv_func->setModifiers($this->_accessModifiers);
\r
615 unset($this->_accessModifiers);
\r
617 $this->_pv_func->setLineNumber($this->_wp->linenum + 1);
\r
618 if (is_string($word) && $word == '&') {
\r
619 $this->_pv_func->setReturnsReference();
\r
621 if (is_array($word) && $word[0] == T_STRING) {
\r
622 $this->_pv_func->setName($word[1]);
\r
625 if ($this->_pv_func->getReturnsReference()) {
\r
626 if (is_array($word) && $word[0] == T_STRING) {
\r
627 $this->_pv_func->setName($word[1]);
\r
631 if ($this->checkEventPop($word, $pevent)) {
\r
632 $this->_pv_func->setEndLineNumber($this->_wp->linenum + 1);
\r
633 $this->_pv_func->addGlobals($this->_pv_globals);
\r
634 $this->_pv_func->addStatics($this->_pv_statics, $this->_pv_static_val);
\r
635 $this->_pv_globals = array();
\r
636 $this->_pv_global_count = 0;
\r
637 if ($this->_pf_getting_source) {
\r
638 $x = $this->_wp->getSource();
\r
639 $this->_pv_func->addSource($x);
\r
640 $this->_pf_get_source = false;
\r
641 $this->_pf_getting_source = false;
\r
643 $this->publishEvent(PHPDOCUMENTOR_EVENT_FUNCTION, $this->_pv_func);
\r
644 $this->_pv_func = false;
\r
646 // subtle bug fixed by this, sometimes string from function body
\r
647 unset($this->_pv_quote_data); // was picked up by the next function
\r
648 // as a default value for a parameter!
\r
653 * handler for FUNCTION_PARAMS.
\r
655 * this handler recognizes the parameters of a function within parentheses
\r
656 * like function(param, param = default_value) and parses them
\r
658 * @see endFunctionParam()
\r
660 function handleFunctionParams($word, $pevent)
\r
662 //echo $this->_wp->getPos() . ": word=|$word|\t\t\tlastword=|"
\r
663 // . $this->_pv_last_word."|\n";
\r
664 //echo "function_param = '".$this->_pv_function_param."'\n";
\r
665 //echo "function_data = '".$this->_pv_function_data."'\n";
\r
666 $e1 = $this->checkEventPush($word, $pevent);
\r
669 if (($pop = $this->checkEventPop($word, $pevent)) &&
\r
670 $pevent == PARSER_EVENT_FUNCTION_PARAM_VAR
\r
672 // end of [typehint ]$param[= defaultval]
\r
673 if (is_string($word) && $word == ')') {
\r
674 $this->_wp->backupPos();
\r
676 $this->endFunctionParam($word);
\r
677 } elseif ($word == '=') {
\r
678 // about to parse the default value
\r
679 $this->_pf_funcparam_val = true;
\r
681 if ($this->_pf_funcparam_val) {
\r
682 // parsing default value
\r
683 if (isset($this->_pv_quote_data)) {
\r
684 $this->_pv_function_data .= $this->_pv_quote_data;
\r
685 unset($this->_pv_quote_data);
\r
687 if (is_array($word)) {
\r
690 $this->_pv_function_data .= $word;
\r
696 if (!isset($this->_pv_function_param)) {
\r
697 $this->_pv_function_param = '';
\r
699 if (is_array($word) && $pevent == PARSER_EVENT_FUNCTION_PARAMS
\r
701 if ($word[0] == T_STRING || $word[0] == T_ARRAY) {
\r
702 // object or array type hint
\r
703 $this->_pv_function_param_type = $word[1];
\r
708 $this->_pv_function_param .= $word;
\r
711 } elseif ($e1 == PARSER_EVENT_ARRAY) {
\r
712 $this->_wp->setWhiteSpace(true);
\r
713 } elseif ($e1 == PARSER_EVENT_FUNCTION_PARAM_VAR) {
\r
714 if (!isset($this->_pv_function_param)) {
\r
715 $this->_pv_function_param = '';
\r
717 // we just got the $var part of the param
\r
718 $this->_pv_function_param .= $word[1];
\r
723 * handler for ARRAY.
\r
725 * this event handler parses arrays in default values of function
\r
726 * and var definitions
\r
728 function handleArray($word, $pevent)
\r
730 $e = $this->checkEventPush($word, $pevent);
\r
735 if (!isset($this->_pv_function_data) ||
\r
736 (isset($this->_pv_function_data) && empty($this->_pv_function_data))
\r
738 $this->_pv_function_data = "array";
\r
741 if ($word == '(' && $this->_pv_paren_count++) {
\r
742 // need extra parentheses help
\r
743 $this->_event_stack->pushEvent($pevent);
\r
745 if (is_array($word)) {
\r
746 $this->_pv_function_data .= $word[1];
\r
748 $this->_pv_function_data .= $word;
\r
750 //echo "function_data = |$this->_pv_function_data|\n";
\r
752 if ($this->checkEventPop($word, $pevent)) {
\r
753 $this->_pv_paren_count--;
\r
754 $this->_wp->setWhiteSpace(false);
\r
759 * handler for HEREDOC in a function logic block.
\r
761 * this handler recognizes function declarations, and parses them. The body
\r
762 * of the function is parsed by handleLogicBlock()
\r
764 * @see handleLogicBlock()
\r
766 function handleHereDoc($word, $pevent)
\r
768 if (is_array($this->_pv_last_word) &&
\r
769 $this->_pv_last_word[0] == T_START_HEREDOC
\r
772 if (is_array($word)) {
\r
775 $this->_pv_quote_data = $this->_pv_last_word[1] . $word;
\r
776 $this->_pf_quote_active = true;
\r
777 } elseif (!$this->_pf_quote_active) {
\r
778 $this->_pv_quote_data = $this->_pv_last_word[1];
\r
779 $this->_event_stack->popEvent();
\r
780 $this->_wp->backupPos();
\r
784 if (is_array($word)) {
\r
787 $this->_pv_quote_data .= $word;
\r
788 if ($this->checkEventPop($save, $pevent)) {
\r
789 $this->_pf_quote_active = false;
\r
794 * handler for QUOTE.
\r
796 * this handler recognizes strings defined with double quotation marks (")
\r
797 * and single quotation marks and handles them correctly
\r
798 * in any place that they legally appear in php code
\r
800 function handleQuote($word, $pevent)
\r
802 if ($this->_pv_last_word == '"' || $this->_pv_last_word == "'" &&
\r
803 $this->_last_pevent != PARSER_EVENT_QUOTE
\r
806 if (is_array($word)) {
\r
809 $this->_pv_quote_data = $this->_pv_last_word . $word;
\r
810 $this->_pf_quote_active = true;
\r
811 $this->checkEventPop($save, $pevent);
\r
812 } elseif (!$this->_pf_quote_active) {
\r
813 $this->_pv_quote_data = $this->_pv_last_word[1];
\r
814 $this->_event_stack->popEvent();
\r
815 $this->_wp->backupPos();
\r
819 if (is_array($word)) {
\r
822 $this->_pv_quote_data .= $word;
\r
823 if ($this->checkEventPop($save, $pevent)) {
\r
824 $this->_pf_quote_active = false;
\r
829 * handler for INCLUDE.
\r
831 * this handler recognizes include/require/include_once/include_once statements,
\r
832 * and publishes the data to Render
\r
834 function handleInclude($word, $pevent)
\r
836 if (!$this->_pf_in_include) {
\r
837 $this->_pv_linenum = $this->_wp->linenum;
\r
839 $this->_pf_in_include = true;
\r
841 $a = $this->checkEventPush($word, $pevent);
\r
842 if (!$this->_pf_includename_isset) {
\r
843 $this->_pf_includename_isset = true;
\r
845 $w = $this->_pv_last_word;
\r
846 if (is_array($w)) {
\r
849 $this->_pv_include_name = $w;
\r
851 $this->_pv_include_value = '';
\r
853 if (is_array($word)) {
\r
856 $this->_pv_include_value = $word;
\r
858 unset($this->_pv_quote_data);
\r
861 if (empty($this->_pv_include_params_data)) {
\r
862 if ($word != ';') {
\r
863 if (is_array($word)) $word = $word[1];
\r
864 $this->_pv_include_value .= $word;
\r
868 if ($this->_pf_in_include_value && $a == PARSER_EVENT_INCLUDE_PARAMS
\r
870 /* we're already inside the include value,
\r
871 * so an open paren does NOT mean the beginning
\r
872 * of "include parameters"...
\r
873 * it's just a part of the include's value string...
\r
874 * but we've already pushed PARSER_EVENT_INCLUDE_PARAMS
\r
875 * onto the stack...
\r
876 * we need to pop it off
\r
877 * before handleIncludeParams gets called...
\r
879 $this->_event_stack->popEvent();
\r
880 // also need to keep that open parens...
\r
881 $this->_pv_include_value .= $word;
\r
883 $this->_pv_include_params_data = '';
\r
887 if (!empty($this->_pv_include_value)) {
\r
888 $this->_pf_in_include_value = true;
\r
891 if ($this->checkEventPop($word, $pevent)) {
\r
892 $this->_pv_include = new parserInclude;
\r
893 $this->_pv_include->setLineNumber($this->_pv_linenum + 1);
\r
894 $this->_pf_in_include = false;
\r
895 $this->_pv_include->setName($this->_pv_include_name);
\r
896 $this->_pv_include->setValue($this->_pv_include_value);
\r
897 $this->publishEvent(PHPDOCUMENTOR_EVENT_INCLUDE, $this->_pv_include);
\r
898 $this->_pf_includename_isset = false;
\r
899 $this->_pf_in_include_value = false;
\r
900 unset($this->_pv_include);
\r
901 unset($this->_pv_include_name);
\r
902 unset($this->_pv_include_value);
\r
903 unset($this->_pv_include_params_data);
\r
904 } elseif ($this->_last_pevent == PARSER_EVENT_INCLUDE_PARAMS) {
\r
905 // include is part of a larger statement
\r
906 // force ending of include
\r
907 $this->_event_stack->popEvent();
\r
908 $this->_pv_include = new parserInclude;
\r
909 $this->_pv_include->setLineNumber($this->_pv_linenum + 1);
\r
910 $this->_pf_in_include = false;
\r
911 $this->_pv_include->setName($this->_pv_include_name);
\r
912 $this->_pv_include->setValue($this->_pv_include_value);
\r
913 $this->publishEvent(PHPDOCUMENTOR_EVENT_INCLUDE, $this->_pv_include);
\r
914 $this->_pf_includename_isset = false;
\r
915 $this->_pf_in_include_value = false;
\r
916 unset($this->_pv_include);
\r
917 unset($this->_pv_include_name);
\r
918 unset($this->_pv_include_value);
\r
919 unset($this->_pv_include_params_data);
\r
924 * handler for INCLUDE_PARAMS.
\r
926 * this handler parses the contents of ( )
\r
927 * in include/require/include_once/include_once statements
\r
929 function handleIncludeParams($word, $pevent)
\r
931 $e = $this->checkEventPush($word, $pevent);
\r
932 if ($e == PARSER_EVENT_COMMENT) {
\r
936 if (!isset($this->_pv_include_params_data)) {
\r
937 $this->_pv_include_params_data = '';
\r
940 if ($this->checkEventPop($word, $pevent)) {
\r
941 if (!empty($this->_pv_include_params_data)) {
\r
942 $this->_pv_include_value = $this->_pv_include_params_data;
\r
944 $w = $this->_pv_last_word;
\r
945 if (is_array($w)) {
\r
948 $this->_pv_include_value = $w;
\r
951 if (is_array($word)) {
\r
954 $this->_pv_include_params_data .= $word;
\r
958 * handler for INCLUDE_PARAMS_PARENTHESIS.
\r
960 * this handler takes all parenthetical statements within file in:
\r
961 * include statement include(file), and handles them properly
\r
963 function handleIncludeParamsParenthesis($word, $pevent)
\r
965 $this->checkEventPush($word, $pevent);
\r
966 $this->checkEventPop($word, $pevent);
\r
967 if (is_array($word)) {
\r
970 $this->_pv_include_params_data .= $word;
\r
974 * handler for DEFINE.
\r
976 * handles define(constant, value); statements
\r
978 function handleDefine($word, $pevent)
\r
980 if (!$this->_pf_in_define) {
\r
981 $this->_pv_linenum = $this->_wp->linenum + 1;
\r
983 $this->_pf_in_define = true;
\r
984 $this->checkEventPush($word, $pevent);
\r
986 $this->_pf_definename_isset = false;
\r
987 $this->_pv_define_params_data = '';
\r
988 unset($this->_pv_quote_data);
\r
989 if ($this->checkEventPop($word, $pevent)) {
\r
990 $this->_pf_in_define = false;
\r
991 $this->_pv_define = new parserDefine;
\r
992 $this->_pv_define->setLineNumber($this->_pv_linenum);
\r
993 $this->_pv_define->setName($this->_pv_define_name);
\r
994 $this->_pv_define->setValue($this->_pv_define_value);
\r
995 $this->publishEvent(PHPDOCUMENTOR_EVENT_DEFINE, $this->_pv_define);
\r
996 $this->_pf_definename_isset = false;
\r
997 unset($this->_pv_define);
\r
998 unset($this->_pv_define_name);
\r
999 unset($this->_pv_define_value);
\r
1000 $this->_pf_in_define = false;
\r
1001 $this->_pv_define_params_data = '';
\r
1006 * handler for DEFINE_PARAMS.
\r
1008 * handles the parsing of constant and value in define(constant, value);
\r
1010 function handleDefineParams($word, $pevent)
\r
1012 $e = $this->checkEventPush($word, $pevent);
\r
1013 if ($e && $e != PARSER_EVENT_DEFINE_PARAMS_PARENTHESIS) {
\r
1017 if (!isset($this->_pv_define_params_data)) {
\r
1018 $this->_pv_define_params_data = '';
\r
1021 if ($this->checkEventPop($word, $pevent)) {
\r
1022 if ($this->_last_pevent == PARSER_EVENT_QUOTE ||
\r
1023 $this->_last_pevent == PARSER_EVENT_EOFQUOTE
\r
1025 $this->_pv_define_params_data .= $this->_pv_quote_data;
\r
1026 unset($this->_pv_quote_data);
\r
1028 if (is_array($word)) {
\r
1031 if (!empty($this->_pv_define_params_data)) {
\r
1032 //echo $this->_pv_define_params_data."\n";
\r
1033 $this->_pv_define_value = $this->_pv_define_params_data;
\r
1035 $w = $this->_pv_last_word;
\r
1036 if (is_array($this->_pv_last_word)) {
\r
1037 $w = $this->_pv_last_word[1];
\r
1040 $this->_pv_define_value = $w;
\r
1042 $this->_pv_define_value = "";
\r
1045 $this->_pv_define_value = "0";
\r
1048 $this->_pv_define_value = "null";
\r
1051 $this->_pv_define_value = "";
\r
1057 if ($this->_pf_definename_isset) {
\r
1058 if (is_array($word)) {
\r
1061 $this->_pv_define_params_data .= $word;
\r
1063 if ($word != ",") {
\r
1064 if (is_array($word)) {
\r
1067 $this->_pv_define_params_data .= $word;
\r
1069 if (substr($this->_pv_define_params_data, 0, 1) ==
\r
1070 substr($this->_pv_define_params_data,
\r
1071 strlen($this->_pv_define_params_data) - 1) &&
\r
1072 in_array(substr($this->_pv_define_params_data,
\r
1073 0, 1), array('"', "'"))
\r
1075 // remove leading and ending quotation marks
\r
1076 // if there are only two
\r
1077 $a = substr($this->_pv_define_params_data, 0, 1);
\r
1078 $b = substr($this->_pv_define_params_data, 1,
\r
1079 strlen($this->_pv_define_params_data) - 2);
\r
1080 if (strpos($b, $a) === false) {
\r
1081 $this->_pv_define_params_data = $b;
\r
1084 $this->_pf_definename_isset = true;
\r
1085 $this->_pv_define_name = $this->_pv_define_params_data;
\r
1086 $this->_pv_define_params_data = '';
\r
1092 * handler for DEFINE_PARAMS_PARENTHESIS.
\r
1094 * this handler takes all parenthetical statements within constant or value in:
\r
1095 * define(constant, value) of a define statement, and handles them properly
\r
1097 function handleDefineParamsParenthesis($word, $pevent)
\r
1099 $e = $this->checkEventPush($word, $pevent);
\r
1100 $this->checkEventPop($word, $pevent);
\r
1101 if ($this->_last_pevent == PARSER_EVENT_QUOTE) {
\r
1102 $this->_pv_define_params_data .= $this->_pv_quote_data;
\r
1103 unset($this->_pv_quote_data);
\r
1105 if (is_array($word)) {
\r
1108 $this->_pv_define_params_data .= $word;
\r
1112 * handler for IMPLEMENTS.
\r
1114 * this handler parses a class statement's implements clause (PHP 5)
\r
1116 function handleImplements($word, $pevent)
\r
1118 if ($this->checkEventPop($word, $pevent)) {
\r
1119 $this->_wp->backupPos();
\r
1122 if (is_array($word) && $word[0] == T_STRING) {
\r
1123 $this->_pv_class->addImplements($word[1]);
\r
1128 * handler for ACCESS_MODIFIER.
\r
1130 * this handler parses public/private/protected/static/abstract PHP 5 modifiers
\r
1132 function handleAccessModifier($word, $pevent)
\r
1134 if (!isset($this->_accessModifiers)) {
\r
1135 $this->_accessModifiers = array();
\r
1137 $this->_wp->backupPos();
\r
1138 $this->_event_stack->popEvent();
\r
1139 if ($word[0] == T_VARIABLE) {
\r
1140 // this is a PHP5-style variable with no "var"
\r
1141 $this->_event_stack->pushEvent(PARSER_EVENT_VAR);
\r
1143 $this->_accessModifiers[] = strtolower($this->_pv_last_word[1]);
\r
1147 * handler for CLASS.
\r
1149 * this handler parses a class/interface statement
\r
1151 function handleClass($word, $pevent)
\r
1153 if (!$this->_pf_in_class) {
\r
1154 $this->_pf_in_class = true;
\r
1155 if ($this->_pv_last_word[0] == T_INTERFACE) {
\r
1156 $this->_pf_interface = true;
\r
1158 $this->_pf_interface = false;
\r
1161 $a = $this->checkEventPush($word, $pevent);
\r
1163 if (!isset($this->_pv_class)) {
\r
1164 $this->_pv_class = false;
\r
1166 if (!is_subclass_of($this->_pv_class, "parserBase")) {
\r
1167 $this->_pv_class = new parserClass;
\r
1168 if (isset($this->_accessModifiers)) {
\r
1169 $this->_pv_class->setModifiers($this->_accessModifiers);
\r
1170 unset($this->_accessModifiers);
\r
1172 if ($this->_pf_interface) {
\r
1173 $this->_pv_class->setInterface();
\r
1175 $this->_pv_class->setLineNumber($this->_wp->linenum + 1);
\r
1176 $this->_pv_class->setname($word[1]);
\r
1177 $this->_pv_cur_class = $word[1];
\r
1178 $this->_pv_class->setSourceLocation($this->source_location);
\r
1181 if (is_array($this->_pv_last_word) && $this->_pv_last_word[0] == T_EXTENDS
\r
1183 // I don't know why I am so nice, this fixes 1150809
\r
1184 if ($word[1] == $this->_pv_class->getName()) {
\r
1185 addErrorDie(PDERROR_CANNOT_EXTEND_SELF, $word[1]);
\r
1187 $this->_pv_class->setExtends($word[1]);
\r
1190 if ($word == "{") {
\r
1191 $this->publishEvent(PHPDOCUMENTOR_EVENT_CLASS, $this->_pv_class);
\r
1193 //echo $this->wp->getPos() . ": |$word|\n";
\r
1194 if ($this->checkEventPop($word, $pevent)) {
\r
1195 $this->_pv_class->setEndLineNumber($this->_wp->linenum + 1);
\r
1196 $this->_pf_in_class = $this->_pf_interface = false;
\r
1197 // throw an event when class is done
\r
1198 $this->publishEvent(PHPDOCUMENTOR_EVENT_NEWSTATE, STATE_END_CLASS);
\r
1199 $this->_pv_class = false;
\r
1204 * handler for VAR_ARRAY_COMMENT
\r
1206 * if parsing a default value, add the comment to the text
\r
1208 function handleVarArrayComment($word, $pevent)
\r
1210 $this->_pv_function_data .= $this->_pv_last_word[1];
\r
1211 return $this->handleComment($word, $pevent);
\r
1215 * handler for VAR.
\r
1217 * handle a var $varname = default_value;
\r
1218 * or var $varname; statement
\r
1219 * in a class definition
\r
1221 function handleVar($word, $pevent)
\r
1223 if (!$this->_pf_in_var) {
\r
1224 $this->_pf_set_var_value = false;
\r
1225 $this->_pv_var_value = '';
\r
1226 $this->_pv_linenum = $this->_wp->linenum + 1;
\r
1228 $this->_pf_in_var = true;
\r
1229 //echo $word."\n";
\r
1230 $e = $this->checkEventPush($word, $pevent);
\r
1232 if (!isset($this->_pv_var)) {
\r
1233 $this->_pv_var = false;
\r
1235 if ($word == '=' || $word == ';' || $word == ',') {
\r
1236 $this->_wp->setWhitespace(true);
\r
1237 $this->_pf_var_equals = true;
\r
1238 $this->_pv_var = new parserVar($this->_pv_cur_class);
\r
1239 $this->_pv_var->setName($this->_pv_varname);
\r
1241 if ($this->_last_pevent == PARSER_EVENT_VAR_ARRAY) {
\r
1242 if (isset($this->_pv_function_data)) {
\r
1243 $this->_pv_var->setValue($this->_pv_function_data);
\r
1245 $this->_pf_set_var_value = true;
\r
1246 unset($this->_pv_function_data);
\r
1247 } elseif ($this->_pf_var_equals && $word != ';' &&
\r
1248 $word != '=' && $word != ',' && !$e
\r
1250 if (is_array($word)) {
\r
1253 $this->_pv_var_value .= $word;
\r
1255 if ($word == ',') {
\r
1256 if (!$this->_pf_set_var_value) {
\r
1257 $this->_pv_var->setValue($this->_pv_var_value);
\r
1259 $this->_pf_set_var_value = false;
\r
1260 unset($this->_pv_var_value);
\r
1261 $this->_pv_var->setEndLineNumber($this->_wp->linenum + 1);
\r
1262 $this->_pv_var->setLineNumber($this->_pv_linenum);
\r
1263 if (isset($this->_accessModifiers)) {
\r
1264 $this->_pv_var->setModifiers($this->_accessModifiers);
\r
1266 $this->publishEvent(PHPDOCUMENTOR_EVENT_VAR, $this->_pv_var);
\r
1267 unset($this->_pv_var);
\r
1268 $this->_pf_in_var = false;
\r
1269 $this->_pf_var_equals = false;
\r
1270 $this->_pv_varname = '';
\r
1273 if ($this->checkEventPop($word, $pevent)) {
\r
1274 $this->_wp->setWhitespace(false);
\r
1275 if (!$this->_pf_set_var_value) {
\r
1276 $this->_pv_var->setValue($this->_pv_var_value);
\r
1278 $this->_pf_set_var_value = false;
\r
1279 unset($this->_pv_var_value);
\r
1280 $this->_pv_var->setEndLineNumber($this->_wp->linenum + 1);
\r
1281 $this->_pv_var->setLineNumber($this->_pv_linenum);
\r
1282 if (isset($this->_accessModifiers)) {
\r
1283 $this->_pv_var->setModifiers($this->_accessModifiers);
\r
1284 unset($this->_accessModifiers);
\r
1286 $this->publishEvent(PHPDOCUMENTOR_EVENT_VAR, $this->_pv_var);
\r
1287 unset($this->_pv_var);
\r
1288 $this->_pf_in_var = false;
\r
1289 $this->_pf_var_equals = false;
\r
1290 $this->_pv_varname = '';
\r
1293 if ($word[0] == T_VARIABLE) {
\r
1294 $this->_pv_varname = $word[1];
\r
1299 * handler for CLASS_CONSTANT.
\r
1301 * handle a const constname = default_value; statement in a class definition
\r
1303 function handleClassConstant($word, $pevent)
\r
1305 if (!$this->_pf_in_const) {
\r
1306 $this->_pf_set_const_value = false;
\r
1307 $this->_pv_const_value = '';
\r
1308 $this->_pv_linenum = $this->_wp->linenum + 1;
\r
1310 $this->_pf_in_const = true;
\r
1311 //echo $word."\n";
\r
1312 $e = $this->checkEventPush($word, $pevent);
\r
1314 if (!isset($this->_pv_const)) {
\r
1315 $this->_pv_const = false;
\r
1317 if ($word == '=' || $word == ';' || $word == ',') {
\r
1318 $this->_wp->setWhitespace(true);
\r
1319 $this->_pf_const_equals = true;
\r
1320 $this->_pv_const = new parserConst($this->_pv_cur_class);
\r
1321 $this->_pv_const->setName($this->_pv_constname);
\r
1323 if ($this->_last_pevent == PARSER_EVENT_VAR_ARRAY) {
\r
1324 if (isset($this->_pv_function_data)) {
\r
1325 $this->_pv_const->setValue($this->_pv_function_data);
\r
1327 $this->_pf_set_const_value = true;
\r
1328 unset($this->_pv_function_data);
\r
1329 } elseif ($this->_pf_const_equals && $word != ';' &&
\r
1330 $word != '=' && $word != ',' && !$e
\r
1332 if (is_array($word)) {
\r
1335 $this->_pv_const_value .= $word;
\r
1337 if ($word == ',') {
\r
1338 if (!$this->_pf_set_const_value) {
\r
1339 $this->_pv_const->setValue($this->_pv_const_value);
\r
1341 $this->_pf_set_const_value = false;
\r
1342 unset($this->_pv_const_value);
\r
1343 $this->_pv_const->setEndLineNumber($this->_wp->linenum + 1);
\r
1344 $this->_pv_const->setLineNumber($this->_pv_linenum);
\r
1345 $this->publishEvent(PHPDOCUMENTOR_EVENT_CONST, $this->_pv_const);
\r
1346 unset($this->_pv_const);
\r
1347 $this->_pf_in_const = false;
\r
1348 $this->_pf_const_equals = false;
\r
1349 $this->_pv_constname = '';
\r
1352 if ($this->checkEventPop($word, $pevent)) {
\r
1353 $this->_wp->setWhitespace(false);
\r
1354 if (!$this->_pf_set_const_value) {
\r
1355 $this->_pv_const->setValue($this->_pv_const_value);
\r
1357 $this->_pf_set_const_value = false;
\r
1358 unset($this->_pv_const_value);
\r
1359 $this->_pv_const->setEndLineNumber($this->_wp->linenum + 1);
\r
1360 $this->_pv_const->setLineNumber($this->_pv_linenum);
\r
1361 $this->publishEvent(PHPDOCUMENTOR_EVENT_VAR, $this->_pv_const);
\r
1362 unset($this->_pv_const);
\r
1363 $this->_pf_in_const = false;
\r
1364 $this->_pf_const_equals = false;
\r
1365 $this->_pv_constname = '';
\r
1368 if ($word[0] == T_STRING && !$this->_pf_const_equals) {
\r
1369 $this->_pv_constname = $word[1];
\r
1374 * Handler for the
\r
1375 * {@tutorial phpDocumentor.howto.pkg#using.command-line.javadocdesc}
\r
1376 * command-line switch DocBlocks.
\r
1378 * @todo CS cleanup - rename to javaDoc* for camelCasing rule
\r
1380 function JavaDochandleDocblock($word, $pevent)
\r
1382 $this->commonDocBlock($word, $pevent, 'handleJavaDocDesc');
\r
1386 * Handler for normal DocBlocks
\r
1388 function handleDocBlock($word, $pevent)
\r
1390 $this->commonDocBlock($word, $pevent, 'handleDesc');
\r
1395 * Helper function for {@link handleFunctionParams()}
\r
1397 * This function adds a new parameter to the parameter list
\r
1399 * @param string $word the parameter word
\r
1404 function endFunctionParam($word)
\r
1406 if (isset($this->_pv_quote_data)) {
\r
1407 $this->_pv_function_data .= $this->_pv_quote_data;
\r
1408 unset($this->_pv_quote_data);
\r
1410 if (isset($this->_pv_function_param)) {
\r
1411 $this->_pv_func->addParam($this->_pv_function_param,
\r
1412 $this->_pv_function_data,
\r
1413 $this->_pf_funcparam_val,
\r
1414 $this->_pv_function_param_type);
\r
1415 unset($this->_pv_function_param);
\r
1416 $this->_pv_function_data = '';
\r
1417 $this->_pf_funcparam_val = false;
\r
1418 $this->_pv_function_param_type = null;
\r
1423 * Common DocBlock Handler for both JavaDoc-format and normal DocBlocks
\r
1425 * @param string $word the word
\r
1426 * @param int $pevent the parser event
\r
1427 * @param string $deschandler the handler to use
\r
1432 function commonDocBlock($word, $pevent, $deschandler)
\r
1434 $this->_wp->backupPos();
\r
1435 $this->_event_stack->popEvent();
\r
1436 $word = $this->_pv_last_word[1];
\r
1437 $dtype = '_pv_docblock';
\r
1438 if (strpos($word, '/**') !== 0) {
\r
1440 // $this->_wp->backupPos();
\r
1441 $this->_event_stack->pushEvent(PARSER_EVENT_COMMENT);
\r
1444 if ($word == '/**#@-*/') {
\r
1445 // stop using docblock template
\r
1446 $this->publishEvent(PHPDOCUMENTOR_EVENT_NEWSTATE,
\r
1447 PHPDOCUMENTOR_EVENT_END_DOCBLOCK_TEMPLATE);
\r
1448 unset($this->_pv_dtemplate);
\r
1451 if (strpos($word, '/**#@+') === 0) {
\r
1452 // docblock template definition
\r
1453 $dtype = '_pv_dtemplate';
\r
1454 // strip /**#@+ and */
\r
1455 $word = substr($word, 6).'*';
\r
1456 $word = trim(substr($word, 0, strlen($word) - 3));
\r
1457 if (strlen($word) && $word{0} != '*') {
\r
1458 $word = "* $word";
\r
1461 // strip /** and */
\r
1462 $word = substr($word, 2);
\r
1463 $word = substr($word, 0, strlen($word) - 2);
\r
1465 $lines = explode("\n", trim($word));
\r
1466 $go = count($lines);
\r
1467 for ($i=0; $i < $go; $i++) {
\r
1468 if (substr(trim($lines[$i]), 0, 1) != '*') {
\r
1469 unset($lines[$i]);
\r
1471 // remove leading "* "
\r
1472 $lines[$i] = substr(trim($lines[$i]), 1);
\r
1475 // remove empty lines
\r
1476 if ($lines == array(false)) {
\r
1477 // prevent PHP 5.2 segfault (see http://bugs.php.net/bug.php?id=39350)
\r
1478 $lines = array('');
\r
1480 $lines = explode("\n", trim(join("\n", $lines)));
\r
1481 for ($i = 0; $i < count($lines); $i++) {
\r
1482 if (substr(trim($lines[$i]), 0, 1) == '@' &&
\r
1483 substr(trim($lines[$i]), 0, 2) != '@ '
\r
1486 $i = count($lines);
\r
1489 if (isset($tagindex)) {
\r
1490 $tags = array_slice($lines, $tagindex);
\r
1491 $desc = array_slice($lines, 0, $tagindex);
\r
1496 //var_dump($desc,$tags);
\r
1497 $this->$dtype = new parserDocBlock;
\r
1498 $this->$dtype->setLineNumber($this->_wp->_docblock_linenum + 1);
\r
1499 $this->$dtype->setEndLineNumber($this->_wp->linenum);
\r
1500 $this->_pv_dtype = $dtype;
\r
1501 $this->$deschandler($desc);
\r
1502 $this->handleTags($tags);
\r
1503 if ($dtype == '_pv_docblock') {
\r
1504 $this->publishEvent(PHPDOCUMENTOR_EVENT_DOCBLOCK, $this->$dtype);
\r
1505 $this->$dtype = new parserDocBlock();
\r
1507 $this->publishEvent(PHPDOCUMENTOR_EVENT_DOCBLOCK_TEMPLATE,
\r
1513 * Handles JavaDoc descriptions
\r
1515 * @param string $desc the description
\r
1520 function handleJavaDocDesc($desc)
\r
1522 unset($this->_pv_periodline);
\r
1523 $this->_pf_useperiod = false;
\r
1524 if (empty($desc)) {
\r
1525 $desc = array('');
\r
1527 foreach ($desc as $i => $line) {
\r
1528 $line = trim($line);
\r
1529 if (!isset($this->_pv_periodline) &&
\r
1530 substr($line, strlen($line) - 1) == '.'
\r
1532 $this->_pv_periodline = $i;
\r
1533 $this->_pf_useperiod = true;
\r
1536 if (!isset($this->_pv_periodline)) {
\r
1537 $this->_pv_periodline = 0;
\r
1540 $dtype = $this->_pv_dtype;
\r
1541 if ($dtype == '_pv_docblock') {
\r
1543 // strip leading <p>
\r
1544 if (strpos($desc[0], '<p>') === 0) {
\r
1545 $desc[0] = substr($desc[0], 3);
\r
1547 $sdesc = new parserDesc;
\r
1549 for ($i = 0; ($i <= $this->_pv_periodline) && ($i < count($desc)); $i++
\r
1551 if (strpos($desc[$i], '.') !== false) {
\r
1552 $desci .= substr($desc[$i], 0, strpos($desc[$i], '.') + 1);
\r
1554 $desci .= $desc[$i];
\r
1558 $sdesc->add($this->getInlineTags($desci));
\r
1561 $my_desc = new parserDesc;
\r
1562 if (isset($this->_pv_dtemplate)) {
\r
1563 // copy template values if not overridden
\r
1564 if (!$this->_pv_docblock->getExplicitPackage()) {
\r
1565 if ($p = $this->_pv_dtemplate->getKeyword('package')) {
\r
1566 $this->_pv_docblock->addKeyword('package', $p);
\r
1567 $this->_pv_docblock->setExplicitPackage();
\r
1569 if ($p = $this->_pv_dtemplate->getKeyword('category')) {
\r
1570 $this->_pv_docblock->addKeyword('category', $p);
\r
1571 $this->_pv_docblock->setExplicitCategory();
\r
1573 if ($p = $this->_pv_dtemplate->getKeyword('subpackage')) {
\r
1574 $this->_pv_docblock->addKeyword('subpackage', $p);
\r
1577 $tags = $this->_pv_dtemplate->listTags();
\r
1578 foreach ($tags as $tag) {
\r
1579 $this->_pv_docblock->addTag($tag);
\r
1581 if (!count($this->_pv_docblock->params)) {
\r
1582 $this->_pv_docblock->params = $this->_pv_dtemplate->params;
\r
1584 $my_desc->add($this->_pv_dtemplate->desc);
\r
1586 //echo "i = ".$this->_pv_periodline."; i < " . count($desc) . "\n";
\r
1588 for ($i = 0; $i < count($desc); $i++) {
\r
1589 // the line will not be set if it doesn't start with a *
\r
1590 if (isset($desc[$i])) {
\r
1591 $desci .= $desc[$i] . "\n";
\r
1594 $my_desc->add($this->getInlineTags($desci));
\r
1596 $sdesc = new parserDesc;
\r
1598 // strip leading <p>
\r
1599 if (strpos($desc[0], '<p>') === 0) {
\r
1600 $desc[0] = substr($desc[0], 3);
\r
1603 for ($i = 0; ($i <= $this->_pv_periodline) && ($i < count($desc)); $i++
\r
1605 if (strpos($desc[$i], '.') !== false) {
\r
1606 $desci .= substr($desc[$i], 0, strpos($desc[$i], '.') + 1);
\r
1608 $desci .= $desc[$i];
\r
1612 $sdesc->add($this->getInlineTags($desci));
\r
1615 $my_desc = new parserDesc;
\r
1617 for ($i=0; $i < count($desc); $i++) {
\r
1618 if (isset($desc[$i])) {
\r
1619 $desci .= $desci[$i] . "\n";
\r
1622 $my_desc->add($this->getInlineTags($desci));
\r
1625 if ($this->_pf_internal) {
\r
1626 addError(PDERROR_INTERNAL_NOT_CLOSED);
\r
1627 $this->_pf_internal = false;
\r
1629 $this->$dtype->setShortDesc($sdesc);
\r
1630 $this->$dtype->setDesc($my_desc);
\r
1632 //var_dump($this->$dtype);
\r
1637 * Process the Long Description of a DocBlock
\r
1639 * @param array $desc array of lines containing the description
\r
1640 * with leading asterisk "*" stripped off.
\r
1645 function handleDesc($desc)
\r
1647 unset($this->_pv_periodline);
\r
1648 $this->_pf_useperiod = false;
\r
1649 foreach ($desc as $i => $line) {
\r
1650 $line = trim($line);
\r
1651 if (!isset($this->_pv_periodline) &&
\r
1652 substr($line, strlen($line) - 1) == '.'
\r
1654 $this->_pv_periodline = $i;
\r
1655 $this->_pf_useperiod = true;
\r
1658 if (!isset($this->_pv_periodline)) {
\r
1659 $this->_pv_periodline = 0;
\r
1661 if ($this->_pv_periodline > 3) {
\r
1662 $this->_pf_useperiod = false;
\r
1664 for ($i = 0; $i < $this->_pv_periodline; $i++) {
\r
1665 if (strlen($desc[$i]) == 0 && isset($desc[$i - 1]) &&
\r
1666 strlen($desc[$i - 1])
\r
1668 $this->_pv_periodline = $i;
\r
1672 for ($i=0;$i <= $this->_pv_periodline && $i < count($desc);$i++) {
\r
1673 if (!strlen(trim($desc[$i]))) {
\r
1674 $this->_pf_useperiod = false;
\r
1677 // figure out the shortdesc
\r
1678 if ($this->_pf_useperiod === false) {
\r
1679 // use the first non blank line for short desc
\r
1680 for ($i = 0; $i < count($desc); $i++) {
\r
1681 if (strlen($desc[$i]) > 0) {
\r
1682 $this->_pv_periodline = $i;
\r
1683 $i = count($desc);
\r
1687 // check to see if we are going to use a blank line to end the shortdesc
\r
1688 // this can only be in the first 4 lines
\r
1689 if (count($desc) > 4) {
\r
1692 $max = count($desc);
\r
1695 for ($i = $this->_pv_periodline; $i < $max; $i++) {
\r
1696 if (strlen(trim($desc[$i])) == 0) {
\r
1697 $this->_pv_periodline = $i;
\r
1703 $dtype = $this->_pv_dtype;
\r
1704 if ($dtype == '_pv_docblock') {
\r
1705 $sdesc = new parserDesc;
\r
1707 for ($i = 0; ($i <= $this->_pv_periodline) && ($i < count($desc)); $i++
\r
1709 $desci .= $desc[$i] . "\n";
\r
1711 $sdesc->add($this->getInlineTags($desci));
\r
1712 $this->_pv_periodline++;
\r
1714 $my_desc = new parserDesc;
\r
1715 if (isset($this->_pv_dtemplate)) {
\r
1716 // copy template values if not overridden
\r
1717 if (!$this->_pv_docblock->getExplicitPackage()) {
\r
1718 if ($p = $this->_pv_dtemplate->getKeyword('package')) {
\r
1719 $this->_pv_docblock->addKeyword('package', $p);
\r
1720 $this->_pv_docblock->setExplicitPackage();
\r
1722 if ($p = $this->_pv_dtemplate->getKeyword('category')) {
\r
1723 $this->_pv_docblock->addKeyword('category', $p);
\r
1724 $this->_pv_docblock->setExplicitCategory();
\r
1726 if ($p = $this->_pv_dtemplate->getKeyword('subpackage')) {
\r
1727 $this->_pv_docblock->addKeyword('subpackage', $p);
\r
1730 $tags = $this->_pv_dtemplate->listTags();
\r
1731 foreach ($tags as $tag) {
\r
1732 $this->_pv_docblock->addTag($tag);
\r
1734 if (!count($this->_pv_docblock->params)) {
\r
1735 $this->_pv_docblock->params = $this->_pv_dtemplate->params;
\r
1737 if (!$this->_pv_docblock->return) {
\r
1738 $this->_pv_docblock->return = $this->_pv_dtemplate->return;
\r
1740 if (!$this->_pv_docblock->var) {
\r
1741 $this->_pv_docblock->var = $this->_pv_dtemplate->var;
\r
1743 $my_desc->add($this->_pv_dtemplate->sdesc);
\r
1744 $my_desc->add($this->_pv_dtemplate->desc);
\r
1746 //echo "i = ".$this->_pv_periodline."; i < " . count($desc) . "\n";
\r
1748 for ($i = $this->_pv_periodline; $i < count($desc); $i++) {
\r
1749 // the line will not be set if it doesn't start with a *
\r
1750 if (isset($desc[$i])) {
\r
1751 $desci .= $desc[$i] . "\n";
\r
1754 $my_desc->add($this->getInlineTags($desci));
\r
1756 // this is a docblock template
\r
1757 $sdesc = new parserDesc;
\r
1759 for ($i = 0; ($i <= $this->_pv_periodline) && ($i < count($desc)); $i++
\r
1761 if (isset($desc[$i])) {
\r
1762 $desci .= $desc[$i] . "\n";
\r
1765 $sdesc->add($this->getInlineTags($desci));
\r
1766 $this->_pv_periodline++;
\r
1768 $my_desc = new parserDesc;
\r
1770 for ($i=$this->_pv_periodline; $i < count($desc); $i++) {
\r
1771 if (isset($desc[$i])) {
\r
1772 $desci .= $desc[$i] . "\n";
\r
1775 $my_desc->add($this->getInlineTags($desci));
\r
1777 if ($this->_pf_internal) {
\r
1778 addError(PDERROR_INTERNAL_NOT_CLOSED);
\r
1779 $this->_pf_internal = false;
\r
1781 $this->$dtype->setShortDesc($sdesc);
\r
1782 $this->$dtype->setDesc($my_desc);
\r
1784 //var_dump($this->$dtype);
\r
1789 * Process the tags of a DocBlock
\r
1791 * @param array $tags array of lines that contain all @tags
\r
1796 function handleTags($tags)
\r
1798 $newtags = array();
\r
1800 for ($i=0; $i < count($tags); $i++) {
\r
1801 if (strpos(trim($tags[$i]), '@') === 0) {
\r
1802 $tags[$i] = ltrim($tags[$i]);
\r
1804 if (substr($tags[$i], 0, 1) == '@' && substr($tags[$i], 0, 2) != '@ '
\r
1806 // start a new tag
\r
1807 if (!empty($curtag)) {
\r
1808 $newtags[] = $curtag;
\r
1810 $curtag = $tags[$i];
\r
1812 $curtag .= "\n" . $tags[$i];
\r
1815 if (!empty($curtag)) {
\r
1816 $newtags[] = $curtag;
\r
1818 foreach ($newtags as $tag) {
\r
1819 $x = explode(' ', str_replace("\t", ' ', $tag));
\r
1820 $tagname = trim(substr(array_shift($x), 1));
\r
1822 if (isset($this->tagHandlers[$tagname])) {
\r
1823 $handle = $this->tagHandlers[$tagname];
\r
1825 $handle = $this->tagHandlers['*'];
\r
1827 $this->$handle($tagname, $restoftag);
\r
1832 * Process all inline tags in text, and convert them to their abstract
\r
1833 * object representations.
\r
1835 * @param string|array $value complete code to search for inline tags,
\r
1836 * if an array, it's an array of strings
\r
1838 * @return parserStringWithInlineTags
\r
1841 function getInlineTags($value)
\r
1843 if (is_array($value)) {
\r
1844 $value = join("\n", $value);
\r
1846 global $_phpDocumentor_setting;
\r
1847 $priv = (isset($_phpDocumentor_setting['parseprivate']) &&
\r
1848 $_phpDocumentor_setting['parseprivate'] == 'on');
\r
1849 $a = new parserStringWithInlineTags();
\r
1850 if (!$priv && $this->_pf_internal) {
\r
1851 if ($x = strpos($value, '}}')) {
\r
1852 $x = strrpos($value, '}}');
\r
1853 $value = substr($value, $x + 1);
\r
1854 $this->_pf_internal = false;
\r
1858 } elseif ($this->_pf_internal) {
\r
1859 if ($x = strpos($value, '}}')) {
\r
1860 $x = strrpos($value, '}}');
\r
1861 $value = substr($value, 0, $x) . substr($value, $x+2);
\r
1865 $value = explode('{@', $value);
\r
1866 $newval = array();
\r
1867 if ($priv || (!$priv && !$this->_pf_internal)) {
\r
1868 // ignore anything between {@internal and }}
\r
1869 $a->add($value[0]);
\r
1871 for ($i=1; $i < count($value); $i++) {
\r
1872 if (substr($value[$i], 0, 1) == '}') {
\r
1873 if ($priv || (!$priv && !$this->_pf_internal)) {
\r
1874 // ignore anything between {@internal and }}
\r
1875 $a->add('{@' . substr($value[$i], 1));
\r
1877 } elseif (substr($value[$i], 0, 2) == '*}') {
\r
1878 // used for inserting */ in code examples
\r
1879 if ($priv || (!$priv && !$this->_pf_internal)) {
\r
1880 // ignore anything between {@internal and }}
\r
1881 $a->add('*/' . substr($value[$i], 2));
\r
1884 $save = $value[$i];
\r
1885 $value[$i] = split("[\t ]", str_replace("\t", ' ', $value[$i]));
\r
1886 $word = trim(array_shift($value[$i]));
\r
1887 $val = join(' ', $value[$i]);
\r
1888 if (trim($word) == 'internal') {
\r
1889 if ($this->_pf_internal) {
\r
1890 addErrorDie(PDERROR_NESTED_INTERNAL);
\r
1892 $this->_pf_internal = true;
\r
1893 $value[$i] = substr($save, strlen('internal') + 1);
\r
1894 if (!$value[$i]) {
\r
1895 // substr can set this to false
\r
1898 if (strpos($value[$i], '}}') !== false) {
\r
1899 $x = strrpos($value[$i], '}}');
\r
1900 // strip internal and cycle as if it were normal text.
\r
1901 $startval = substr($value[$i], 0, $x);
\r
1903 $a->add($startval);
\r
1905 $value[$i] = substr($value[$i], $x + 2);
\r
1906 if (!$value[$i]) {
\r
1909 $this->_pf_internal = false;
\r
1910 $a->add($value[$i]);
\r
1912 } elseif ($priv) {
\r
1913 $a->add($value[$i]);
\r
1917 if (in_array(str_replace('}', '', trim($word)),
\r
1918 $this->allowableInlineTags)
\r
1920 if (strpos($word, '}')) {
\r
1921 $res = substr($word, strpos($word, '}'));
\r
1922 $word = str_replace('}', '', trim($word));
\r
1923 $val = $res . $val;
\r
1925 if ($priv || (!$priv && !$this->_pf_internal)) {
\r
1926 // ignore anything between {@internal and }}
\r
1927 if ($word == 'source') {
\r
1928 $this->_pf_get_source = true;
\r
1931 $val = explode('}', $val);
\r
1932 if (count($val) == 1) {
\r
1933 addError(PDERROR_UNTERMINATED_INLINE_TAG,
\r
1934 $word, '', $save);
\r
1937 $val = array_shift($rest);
\r
1938 $rest = join('}', $rest);
\r
1939 if (isset($this->inlineTagHandlers[$word])) {
\r
1940 $handle = $this->inlineTagHandlers[$word];
\r
1942 $handle = $this->inlineTagHandlers['*'];
\r
1944 $val = $this->$handle($word, $val);
\r
1945 if ($priv || (!$priv && !$this->_pf_internal)) {
\r
1946 // ignore anything between {@internal and }}
\r
1949 if ($this->_pf_internal) {
\r
1950 if (($x = strpos($rest, '}}')) !== false) {
\r
1951 $value[$i] = $rest;
\r
1952 $startval = substr($value[$i], 0, $x);
\r
1953 if ((false !== $startval) && $priv) {
\r
1954 $a->add($startval);
\r
1956 $value[$i] = substr($value[$i], $x + 2);
\r
1957 if (!$value[$i]) {
\r
1960 $this->_pf_internal = false;
\r
1961 $a->add($value[$i]);
\r
1963 $rest = explode('}}', $rest);
\r
1965 $a->add(array_shift($rest));
\r
1967 $this->_pf_internal = false;
\r
1968 // try this line again without internal
\r
1969 $value[$i--] = join('}}', $rest);
\r
1976 $val = $word . ' ' . $val;
\r
1977 if ($priv || (!$priv && !$this->_pf_internal)) {
\r
1978 // ignore anything between {@internal and }}
\r
1979 $a->add('{@' . $val);
\r
1988 * @param string $name name of the tag
\r
1989 * @param string $value any parameters passed to the inline tag
\r
1993 * Most inline tags require no special processing
\r
1995 * @return mixed some type of parser_*_InlineTag object
\r
1997 function handleDefaultInlineTag($name, $value)
\r
1999 $tag = 'parser' . ucfirst($name) . 'InlineTag';
\r
2000 return new $tag($value, $value);
\r
2004 * Handle the inline {@}link} tag
\r
2006 * @return parserLinkInlineTag
\r
2007 * @tutorial tags.inlinelink.pkg
\r
2009 function handleLinkInlineTag($name, $value)
\r
2011 // support hyperlinks of any protocol
\r
2012 if (is_numeric(strpos($value, '://')) ||
\r
2013 (strpos(trim($value), 'mailto:') === 0)
\r
2015 $value = str_replace('\\,', '###commanana####', $value);
\r
2016 if (strpos($value, ',')) {
\r
2017 $val = new parserLinkInlineTag($value, $value);
\r
2018 } elseif (strpos(trim($value), ' ')) {
\r
2019 // if there is more than 1 parameter,
\r
2020 // the stuff after the space is the hyperlink text
\r
2021 $i1 = strpos(trim($value), ' ') + 1;
\r
2022 $link = substr(trim($value), 0, $i1 - 1);
\r
2023 $text = substr(trim($value), $i1);
\r
2024 $val = new parserLinkInlineTag($link, $text);
\r
2026 $val = new parserLinkInlineTag($value, $value);
\r
2029 $value = str_replace('\\,', '###commanana####', $value);
\r
2030 if (!strpos($value, ',')) {
\r
2031 $testp = explode('#', $value);
\r
2032 if (count($testp) - 1) {
\r
2033 $val = new parserLinkInlineTag($value, $testp[1]);
\r
2035 $val = new parserLinkInlineTag($value, $value);
\r
2038 $val = new parserLinkInlineTag($value, $value);
\r
2047 * @param string $name name of tag
\r
2048 * @param array $value all words in the tag that were separated by a space ' '
\r
2052 * Most tags only need the value as a string
\r
2054 * @uses getInlineTags() all tag handlers check their values for inline tags
\r
2055 * @uses parserDocBlock::addKeyword()
\r
2057 function defaultTagHandler($name, $value)
\r
2059 $dtype = $this->_pv_dtype;
\r
2060 $this->$dtype->addKeyword($name, $this->getInlineTags(join(' ', $value)));
\r
2064 * handles the @example tag
\r
2066 * @tutorial tags.example.pkg
\r
2067 * @uses parserDocBlock::addExample()
\r
2069 function exampleTagHandler($name, $value)
\r
2071 $dtype = $this->_pv_dtype;
\r
2072 $this->$dtype->addExample($this->getInlineTags(join(' ', $value)),
\r
2077 * handles the @filesource tag
\r
2079 * @tutorial tags.filesource.pkg
\r
2080 * @uses phpDocumentorTWordParser::getFileSource() retrieves the source for
\r
2081 * use in the @filesource tag
\r
2082 * @uses parserDocBlock::addFileSource()
\r
2084 function filesourceTagHandler($name, $value)
\r
2086 $dtype = $this->_pv_dtype;
\r
2087 $this->$dtype->addFileSource($this->_path, $this->_wp->getFileSource());
\r
2091 * handles the @uses tag
\r
2093 * @tutorial tags.uses.pkg
\r
2094 * @uses parserDocBlock::addUses()
\r
2096 function usesTagHandler($name, $value)
\r
2098 $dtype = $this->_pv_dtype;
\r
2100 while ($seel == '' && count($value)) {
\r
2101 $seel = array_shift($value);
\r
2103 $this->$dtype->addUses($this->getInlineTags($seel),
\r
2104 $this->getInlineTags(join(' ', $value)));
\r
2108 * handles the @author tag
\r
2110 * @tutorial tags.author.pkg
\r
2111 * @uses parserDocBlock::addKeyword()
\r
2113 function authorTagHandler($name, $value)
\r
2115 $dtype = $this->_pv_dtype;
\r
2116 $value = join(' ', $value);
\r
2117 if ((strpos($value, '<') !== false) && (strpos($value, '>') !== false)) {
\r
2118 $email = substr($value,
\r
2119 strpos($value, '<') + 1,
\r
2120 strpos($value, '>') - strpos($value, '<') - 1);
\r
2121 $value = str_replace('<' . $email . '>',
\r
2122 '<{@link mailto:' . $email . ' ' . $email . '}>',
\r
2125 $this->$dtype->addKeyword('author', $this->getInlineTags($value));
\r
2129 * handles the @package tag
\r
2131 * @tutorial tags.package.pkg
\r
2132 * @uses parserDocBlock::setExplicitPackage()
\r
2134 function packageTagHandler($name, $value)
\r
2136 if (count($value) && empty($value[0])) {
\r
2138 // CRB - I believe this loop is correct in not having a body...
\r
2139 // I think it is only to determine the $i value needed
\r
2140 // by the one array_splice() call...
\r
2141 for ($i=0; $i < count($value) && !strlen($value[$i]); $i++);
\r
2142 array_splice($value, 0, $i);
\r
2144 $this->defaultTagHandler($name, $value);
\r
2145 $dtype = $this->_pv_dtype;
\r
2146 $this->$dtype->setExplicitPackage();
\r
2150 * handles the @category tag
\r
2152 * @tutorial tags.category.pkg
\r
2153 * @uses parserDocBlock::setExplicitCategory()
\r
2155 function categoryTagHandler($name, $value)
\r
2157 if (count($value) && empty($value[0])) {
\r
2159 // CRB - I believe this loop is correct in not having a body...
\r
2160 // I think it is only to determine the $i value needed
\r
2161 // by the one array_splice() call...
\r
2162 for ($i=0; $i < count($value) && !strlen($value[$i]); $i++);
\r
2163 array_splice($value, 0, $i);
\r
2165 $this->defaultTagHandler($name, $value);
\r
2166 $dtype = $this->_pv_dtype;
\r
2167 $this->$dtype->setExplicitCategory();
\r
2171 * handles the @global tag
\r
2173 * @tutorial tags.global.pkg
\r
2174 * @uses parserDocBlock::addFuncGlobal()
\r
2176 function globalTagHandler($name, $value)
\r
2178 $info = $this->retrieveType($value, true);
\r
2180 addError(PDERROR_MALFORMED_TAG, '@global');
\r
2182 $type = $info['type'];
\r
2183 $var = $info['var'];
\r
2184 $desc = $info['desc'];
\r
2185 $dtype = $this->_pv_dtype;
\r
2186 if (!$var && empty($desc)) {
\r
2187 if ($type{0} == '$') {
\r
2188 addError(PDERROR_MALFORMED_GLOBAL_TAG);
\r
2190 return $this->$dtype->addFuncGlobal($type,
\r
2191 new parserStringWithInlineTags);
\r
2195 $this->_pv_global_type = $type;
\r
2196 if (!empty($desc)) {
\r
2197 $var .= ' '.$desc;
\r
2199 $this->findGlobal(trim($var));
\r
2200 } elseif (!empty($desc)) {
\r
2201 // function global
\r
2202 if ($type{0} == '$') {
\r
2203 addError(PDERROR_MALFORMED_GLOBAL_TAG);
\r
2205 $this->$dtype->addFuncGlobal($type, $this->getInlineTags($desc));
\r
2207 addError(PDERROR_MALFORMED_GLOBAL_TAG);
\r
2212 * handles the @staticvar tag
\r
2214 * @tutorial tags.staticvar.pkg
\r
2215 * @uses parserDocBlock::addStaticVar()
\r
2217 function staticvarTagHandler($name, $value)
\r
2219 $info = $this->retrieveType($value, true);
\r
2221 addError(PDERROR_MALFORMED_TAG, '@staticvar');
\r
2223 $type = $info['type'];
\r
2224 $var = $info['var'];
\r
2225 $desc = $info['desc'];
\r
2226 $dtype = $this->_pv_dtype;
\r
2227 if (!$var && empty($desc)) {
\r
2228 $this->$dtype->addStaticVar(null, $type,
\r
2229 new parserStringWithInlineTags);
\r
2232 $this->$dtype->addStaticVar($var, $type,
\r
2233 $this->getInlineTags($desc));
\r
2235 $this->$dtype->addStaticVar(null, $type,
\r
2236 $this->getInlineTags($desc));
\r
2242 * handles the @param tag
\r
2244 * @tutorial tags.param.pkg
\r
2245 * @uses parserDocBlock::addParam()
\r
2247 function paramTagHandler($name, $value)
\r
2249 $info = $this->retrieveType($value, true);
\r
2251 addError(PDERROR_MALFORMED_TAG, '@param');
\r
2254 $type = $info['type'];
\r
2255 $var = $info['var'];
\r
2256 $desc = $info['desc'];
\r
2257 $dtype = $this->_pv_dtype;
\r
2258 if (!$var && empty($desc)) {
\r
2259 $this->$dtype->addParam(null, $type, new parserStringWithInlineTags);
\r
2262 $this->$dtype->addParam($var, $type, $this->getInlineTags($desc));
\r
2264 $this->$dtype->addParam(null, $type, $this->getInlineTags($desc));
\r
2270 * handles the @return tag
\r
2272 * @tutorial tags.return.pkg
\r
2273 * @uses parserDocBlock::addReturn()
\r
2275 function returnTagHandler($name, $value)
\r
2277 $info = $this->retrieveType($value, true);
\r
2279 addError(PDERROR_MALFORMED_TAG, '@return');
\r
2282 $type = $info['type'];
\r
2283 $desc = $info['desc'];
\r
2284 $dtype = $this->_pv_dtype;
\r
2285 $this->$dtype->addReturn($type, $this->getInlineTags($desc));
\r
2289 * handles the @var tag
\r
2291 * @tutorial tags.var.pkg
\r
2292 * @uses parserDocBlock::addVar()
\r
2294 function varTagHandler($name, $value)
\r
2296 $info = $this->retrieveType($value, true);
\r
2298 addError(PDERROR_MALFORMED_TAG, '@var');
\r
2300 $type = $info['type'];
\r
2301 $desc = $info['desc'];
\r
2302 $dtype = $this->_pv_dtype;
\r
2303 $this->$dtype->addVar($type, $this->getInlineTags($desc));
\r
2307 * Handles @property(-read or -write) and @method magic tags
\r
2309 * @tutorial tags.method.pkg
\r
2310 * @tutorial tags.property.pkg
\r
2311 * @uses parserDocBlock::addProperty()
\r
2313 function propertyTagHandler($name, $value)
\r
2315 $info = $this->retrieveType($value, true);
\r
2317 addError(PDERROR_MALFORMED_TAG, '@' . $name);
\r
2319 $type = $info['type'];
\r
2320 $var = $info['var'];
\r
2321 $desc = $info['desc'];
\r
2322 $dtype = $this->_pv_dtype;
\r
2323 $this->$dtype->addProperty($name, $var, $type, $this->getInlineTags($desc));
\r
2332 * Retrieve the type portion of a @tag type description
\r
2334 * Tags like @param, @return and @var all have a PHP type portion in their
\r
2335 * description. Since the type may contain the expression "object blah"
\r
2336 * where blah is a classname, it makes parsing out the type field complex.
\r
2338 * Even more complicated is the case where a tag variable can contain
\r
2339 * multiple types, such as object blah|object blah2|false, and so this
\r
2340 * method handles these cases.
\r
2342 * @param array $value array of words that were separated by spaces
\r
2343 * @param bool $checkforvar flag to determine whether to check for the end of a
\r
2344 * type is defined by a $varname
\r
2346 * @return bool|array FALSE if there is no value,
\r
2347 * or an array of Format:
\r
2350 * 'type' => string,
\r
2351 * 'var' => false|string variable name,
\r
2352 * 'desc' => rest of the tag
\r
2356 function retrieveType($value, $checkforvar = false)
\r
2358 if (!count($value)) {
\r
2361 $result = array();
\r
2363 // remove empty entries resulting from extra spaces between @tag and type
\r
2364 $this->_removeWhiteSpace($value, 0);
\r
2366 if (trim($value[0]) == 'object') {
\r
2367 $types .= array_shift($value) . ' ';
\r
2368 $this->_removeWhiteSpace($value, 0);
\r
2369 if (!count($value)) {
\r
2370 // was just passed "object"
\r
2371 $result = array('type' => rtrim($types), 'desc' => '');
\r
2372 if ($checkforvar) {
\r
2373 $result['var'] = false;
\r
2377 if ($value[0]{0} == '$' || substr($value[0], 0, 2) == '&$') {
\r
2378 // was just passed "object" and the next thing is a variable name
\r
2379 $result['var'] = trim($value[0]);
\r
2380 $result['type'] = 'object';
\r
2381 array_shift($value);
\r
2382 $result['desc'] = join(' ', $value);
\r
2388 // this loop checks for type|type|type
\r
2389 // and for type|object classname|type|object classname2
\r
2390 if (strpos($value[0], '|')) {
\r
2391 $temptypes = explode('|', $value[0]);
\r
2392 while (count($temptypes)) {
\r
2393 $type = array_shift($temptypes);
\r
2395 if (count($temptypes)) {
\r
2399 if (trim($type) == 'object') {
\r
2401 $this->_removeWhiteSpace($value, 0);
\r
2405 array_shift($value);
\r
2406 if (isset ($value[0]) && strlen($value[0]) && ($value[0]{0} == '$' ||
\r
2407 substr($value[0], 0, 2) == '&$')
\r
2409 // was just passed "object" and the next thing is a variable name
\r
2410 $result['var'] = trim($value[0]);
\r
2411 $result['type'] = $types;
\r
2412 array_shift($value);
\r
2413 $result['desc'] = join(' ', $value);
\r
2417 $types .= $value[0];
\r
2418 array_shift($value);
\r
2421 } while (!$done && count($value));
\r
2422 $result['type'] = rtrim($types);
\r
2423 $this->_removeWhiteSpace($value, 0);
\r
2424 if ($checkforvar) {
\r
2425 if (!count($value)) {
\r
2426 $result['var'] = false;
\r
2430 * variable name ($)
\r
2431 * var passed by reference (&$)
\r
2432 * method name (only used by magic method)
\r
2434 if (substr($value[0], 0, 1) == '$' ||
\r
2435 substr($value[0], 0, 2) == '&$' ||
\r
2436 substr($value[0], -2, 2) == '()'
\r
2438 $result['var'] = trim($value[0]);
\r
2439 array_shift($value);
\r
2441 $result['var'] = false;
\r
2445 $result['desc'] = join(' ', $value);
\r
2450 * remove whitespace from a value
\r
2452 * @param array &$value array of string
\r
2453 * @param integer $index index to seek non-whitespace to
\r
2457 function _removeWhiteSpace(&$value, $index)
\r
2459 if (count($value) > $index && empty($value[$index])) {
\r
2461 // CRB - I believe this loop is correct in not having a body...
\r
2462 // I think it is only to determine the $i value needed
\r
2463 // by the one array_splice() call...
\r
2464 for ($i=$index; $i < count($value) && !strlen($value[$i]); $i++);
\r
2465 array_splice($value, $index, $i - $index);
\r
2470 * Retrieve all the tokens that represent the definition of the global variable
\r
2474 * @param string $name the global variable to find
\r
2478 function findGlobal($name)
\r
2480 $tokens = token_get_all('<?php ' . $name);
\r
2481 $tokens = array_slice($tokens, 1);
\r
2482 $this->_wp->findGlobal($tokens);
\r
2483 $this->_pv_findglobal = $name;
\r
2487 * this function checks whether parameter $word
\r
2488 * is a token for pushing a new event onto the Event Stack.
\r
2490 * @param string $word the word to check
\r
2491 * @param int $pevent the event to push
\r
2493 * @return mixed returns false, or the event number
\r
2495 function checkEventPush($word, $pevent)
\r
2497 if (is_array($word) && $word[0] == T_STRING) {
\r
2500 if (is_array($word)) {
\r
2501 $pushEvent = &$this->tokenpushEvent;
\r
2504 $pushEvent = &$this->wordpushEvent;
\r
2505 $word = strtolower($word);
\r
2508 if (isset($pushEvent[$pevent])) {
\r
2509 if (isset($pushEvent[$pevent][$word])) {
\r
2510 $e = $pushEvent[$pevent][$word];
\r
2514 $this->_event_stack->pushEvent($e);
\r
2522 * this function checks whether parameter $word
\r
2523 * is a token for popping the current event off of the Event Stack.
\r
2525 * @param string $word the word to check
\r
2526 * @param int $pevent the event to pop
\r
2528 * @return mixed returns false, or the event number popped off of the stack
\r
2530 function checkEventPop($word, $pevent)
\r
2532 if (is_array($word) && $word[0] == T_STRING) {
\r
2535 if (is_array($word)) {
\r
2536 $popEvent = &$this->tokenpopEvent;
\r
2539 $popEvent = &$this->wordpopEvent;
\r
2540 $word = strtolower($word);
\r
2542 if (!isset($popEvent[$pevent])) {
\r
2545 if (in_array($word, $popEvent[$pevent])) {
\r
2546 return $this->_event_stack->popEvent();
\r
2553 * returns the token from the $word array
\r
2555 * @param mixed $word the token array
\r
2557 * @return mixed the token from the array,
\r
2558 * or FALSE if it's not an array
\r
2560 function getToken($word)
\r
2562 if (is_array($word)) {
\r
2569 * setup the parser tokens, and the pushEvent/popEvent arrays
\r
2572 * @see $tokens, $pushEvent, $popEvent
\r
2574 function setupStates()
\r
2576 unset($this->_wp);
\r
2577 $this->_wp = new phpDocumentorTWordParser;
\r
2578 $this->_pv_class = null;
\r
2579 $this->_pv_cur_class = null;
\r
2580 $this->_pv_define = null;
\r
2581 $this->_pv_define_name = null;
\r
2582 $this->_pv_define_value = null;
\r
2583 $this->_pv_define_params_data = null;
\r
2584 $this->_pv_dtype = null;
\r
2585 $this->_pv_docblock = null;
\r
2586 $this->_pv_dtemplate = null;
\r
2587 $this->_pv_func = null;
\r
2588 $this->_pv_findglobal = null;
\r
2589 $this->_pv_global_name = null;
\r
2590 $this->_pv_global_val = null;
\r
2591 $this->_pv_globals = null;
\r
2592 $this->_pv_global_count = null;
\r
2593 $this->_pv_include_params_data = null;
\r
2594 $this->_pv_include_name = null;
\r
2595 $this->_pv_include_value = null;
\r
2596 $this->_pv_linenum = null;
\r
2597 $this->_pv_periodline = null;
\r
2598 $this->_pv_paren_count = 0;
\r
2599 $this->_pv_statics = null;
\r
2600 $this->_pv_static_count = null;
\r
2601 $this->_pv_static_val = null;
\r
2602 $this->_pv_quote_data = null;
\r
2603 $this->_pv_function_data = null;
\r
2604 $this->_pv_var = null;
\r
2605 $this->_pv_varname = null;
\r
2606 $this->_pv_const = null;
\r
2607 $this->_pv_constname = null;
\r
2608 $this->_pv_function_param_type = null;
\r
2609 $this->_pf_definename_isset = false;
\r
2610 $this->_pf_includename_isset = false;
\r
2611 $this->_pf_get_source = false;
\r
2612 $this->_pf_getting_source = false;
\r
2613 $this->_pf_in_class = false;
\r
2614 $this->_pf_in_define = false;
\r
2615 $this->_pf_in_global = false;
\r
2616 $this->_pf_in_include = false;
\r
2617 $this->_pf_in_var = false;
\r
2618 $this->_pf_in_const = false;
\r
2619 $this->_pf_funcparam_val = false;
\r
2620 $this->_pf_quote_active = false;
\r
2621 $this->_pf_reset_quote_data = true;
\r
2622 $this->_pf_useperiod = false;
\r
2623 $this->_pf_var_equals = false;
\r
2624 $this->_pf_const_equals = false;
\r
2625 $this->_event_stack = new EventStack;
\r
2629 * Creates the state arrays
\r
2633 function setupEventStates()
\r
2635 if (!defined('T_DOC_COMMENT')) {
\r
2636 define('T_DOC_COMMENT', T_DOC_COMMENT);
\r
2638 /**************************************************************/
\r
2640 $this->wordpushEvent[PARSER_EVENT_LOGICBLOCK] =
\r
2642 "{" => PARSER_EVENT_LOGICBLOCK,
\r
2643 '"' => PARSER_EVENT_QUOTE,
\r
2645 $this->tokenpushEvent[PARSER_EVENT_LOGICBLOCK] =
\r
2647 T_GLOBAL => PARSER_EVENT_FUNC_GLOBAL,
\r
2648 T_STATIC => PARSER_EVENT_STATIC_VAR,
\r
2649 T_START_HEREDOC => PARSER_EVENT_EOFQUOTE,
\r
2650 T_CURLY_OPEN => PARSER_EVENT_LOGICBLOCK,
\r
2651 T_DOLLAR_OPEN_CURLY_BRACES => PARSER_EVENT_LOGICBLOCK,
\r
2654 $this->wordpopEvent[PARSER_EVENT_LOGICBLOCK] = array("}");
\r
2655 $this->tokenpopEvent[PARSER_EVENT_LOGICBLOCK] = array(T_CURLY_OPEN);
\r
2656 /**************************************************************/
\r
2658 $this->tokenpushEvent[PARSER_EVENT_NOEVENTS] =
\r
2660 T_OPEN_TAG => PARSER_EVENT_PHPCODE,
\r
2663 /**************************************************************/
\r
2665 $this->tokenpopEvent[PARSER_EVENT_EOFQUOTE] = array(T_END_HEREDOC);
\r
2666 /**************************************************************/
\r
2668 $this->tokenpushEvent[PARSER_EVENT_PHPCODE] =
\r
2670 T_FUNCTION => PARSER_EVENT_FUNCTION,
\r
2671 T_ABSTRACT => PARSER_EVENT_ACCESS_MODIFIER,
\r
2672 T_CLASS => PARSER_EVENT_CLASS,
\r
2673 T_INTERFACE => PARSER_EVENT_CLASS,
\r
2674 T_INCLUDE_ONCE => PARSER_EVENT_INCLUDE,
\r
2675 T_INCLUDE => PARSER_EVENT_INCLUDE,
\r
2676 T_REQUIRE => PARSER_EVENT_INCLUDE,
\r
2677 T_REQUIRE_ONCE => PARSER_EVENT_INCLUDE,
\r
2678 T_COMMENT => PARSER_EVENT_DOCBLOCK,
\r
2679 T_DOC_COMMENT => PARSER_EVENT_DOCBLOCK,
\r
2680 //"/**#@+" => PARSER_EVENT_DOCBLOCK_TEMPLATE,
\r
2681 //"/**#@-*/" => PARSER_EVENT_END_DOCBLOCK_TEMPLATE,
\r
2682 T_CLOSE_TAG => PARSER_EVENT_OUTPHP,
\r
2684 $this->wordpushEvent[PARSER_EVENT_PHPCODE] =
\r
2686 "define" => PARSER_EVENT_DEFINE,
\r
2688 /**************************************************************/
\r
2690 $this->tokenpopEvent[PARSER_EVENT_OUTPHP] = array(T_OPEN_TAG);
\r
2691 /**************************************************************/
\r
2693 $this->wordpushEvent[PARSER_EVENT_FUNCTION] =
\r
2695 '{' => PARSER_EVENT_LOGICBLOCK,
\r
2696 '(' => PARSER_EVENT_FUNCTION_PARAMS,
\r
2698 $this->tokenpushEvent[PARSER_EVENT_FUNCTION] =
\r
2700 T_COMMENT => PARSER_EVENT_COMMENT,
\r
2701 T_DOC_COMMENT => PARSER_EVENT_COMMENT,
\r
2704 $this->wordpopEvent[PARSER_EVENT_FUNCTION] = array("}",';');
\r
2705 /**************************************************************/
\r
2707 $this->wordpopEvent[PARSER_EVENT_QUOTE] = array('"');
\r
2708 /**************************************************************/
\r
2710 $this->tokenpushEvent[PARSER_EVENT_FUNCTION_PARAMS] =
\r
2712 T_VARIABLE => PARSER_EVENT_FUNCTION_PARAM_VAR,
\r
2713 T_COMMENT => PARSER_EVENT_COMMENT,
\r
2714 T_DOC_COMMENT => PARSER_EVENT_COMMENT,
\r
2716 $this->wordpopEvent[PARSER_EVENT_FUNCTION_PARAMS] = array(")");
\r
2717 /**************************************************************/
\r
2719 $this->tokenpushEvent[PARSER_EVENT_FUNCTION_PARAM_VAR] =
\r
2721 T_CONSTANT_ENCAPSED_STRING => PARSER_EVENT_QUOTE,
\r
2722 T_COMMENT => PARSER_EVENT_COMMENT,
\r
2723 T_DOC_COMMENT => PARSER_EVENT_COMMENT,
\r
2724 T_ARRAY => PARSER_EVENT_ARRAY,
\r
2726 $this->wordpushEvent[PARSER_EVENT_FUNCTION_PARAM_VAR] =
\r
2728 '"' => PARSER_EVENT_QUOTE,
\r
2729 "'" => PARSER_EVENT_QUOTE,
\r
2731 $this->wordpopEvent[PARSER_EVENT_FUNCTION_PARAM_VAR] = array(",", ")");
\r
2732 /**************************************************************/
\r
2734 $this->tokenpushEvent[PARSER_EVENT_ARRAY] =
\r
2736 T_COMMENT => PARSER_EVENT_COMMENT,
\r
2737 T_DOC_COMMENT => PARSER_EVENT_COMMENT,
\r
2739 $this->wordpopEvent[PARSER_EVENT_ARRAY] = array(")");
\r
2740 /**************************************************************/
\r
2742 $this->tokenpushEvent[PARSER_EVENT_VAR_ARRAY] =
\r
2744 T_COMMENT => PARSER_EVENT_VAR_ARRAY_COMMENT,
\r
2745 T_DOC_COMMENT => PARSER_EVENT_VAR_ARRAY_COMMENT,
\r
2747 $this->wordpopEvent[PARSER_EVENT_VAR_ARRAY] = array(")");
\r
2748 /**************************************************************/
\r
2750 $this->tokenpushEvent[PARSER_EVENT_FUNC_GLOBAL] =
\r
2752 T_COMMENT => PARSER_EVENT_COMMENT,
\r
2753 T_DOC_COMMENT => PARSER_EVENT_COMMENT,
\r
2755 $this->wordpopEvent[PARSER_EVENT_FUNC_GLOBAL] = array(";");
\r
2756 /**************************************************************/
\r
2758 $this->tokenpushEvent[PARSER_EVENT_STATIC_VAR] =
\r
2760 T_CONSTANT_ENCAPSED_STRING => PARSER_EVENT_QUOTE,
\r
2761 T_COMMENT => PARSER_EVENT_COMMENT,
\r
2762 T_DOC_COMMENT => PARSER_EVENT_COMMENT,
\r
2764 $this->wordpushEvent[PARSER_EVENT_STATIC_VAR] =
\r
2766 "=" => PARSER_EVENT_STATIC_VAR_VALUE,
\r
2768 $this->wordpopEvent[PARSER_EVENT_STATIC_VAR] = array(";");
\r
2769 /**************************************************************/
\r
2771 $this->tokenpushEvent[PARSER_EVENT_STATIC_VAR_VALUE] =
\r
2773 T_CONSTANT_ENCAPSED_STRING => PARSER_EVENT_QUOTE,
\r
2774 T_COMMENT => PARSER_EVENT_COMMENT,
\r
2775 T_DOC_COMMENT => PARSER_EVENT_COMMENT,
\r
2776 T_ARRAY => PARSER_EVENT_ARRAY,
\r
2778 $this->wordpushEvent[PARSER_EVENT_STATIC_VAR_VALUE] =
\r
2780 '"' => PARSER_EVENT_QUOTE,
\r
2781 "'" => PARSER_EVENT_QUOTE,
\r
2783 $this->wordpopEvent[PARSER_EVENT_STATIC_VAR_VALUE] = array(";",",");
\r
2784 /**************************************************************/
\r
2786 $this->tokenpushEvent[PARSER_EVENT_DEFINE] =
\r
2788 T_COMMENT => PARSER_EVENT_COMMENT,
\r
2789 T_DOC_COMMENT => PARSER_EVENT_COMMENT,
\r
2790 T_CONSTANT_ENCAPSED_STRING => PARSER_EVENT_QUOTE,
\r
2792 $this->wordpushEvent[PARSER_EVENT_DEFINE] =
\r
2794 "(" => PARSER_EVENT_DEFINE_PARAMS,
\r
2796 $this->wordpopEvent[PARSER_EVENT_DEFINE] = array(";");
\r
2797 /**************************************************************/
\r
2799 $this->tokenpushEvent[PARSER_EVENT_INCLUDE] =
\r
2801 T_COMMENT => PARSER_EVENT_COMMENT,
\r
2802 T_DOC_COMMENT => PARSER_EVENT_COMMENT,
\r
2804 $this->wordpushEvent[PARSER_EVENT_INCLUDE] =
\r
2806 "(" => PARSER_EVENT_INCLUDE_PARAMS,
\r
2808 $this->wordpopEvent[PARSER_EVENT_INCLUDE] = array(";");
\r
2809 /**************************************************************/
\r
2811 $this->tokenpushEvent[PARSER_EVENT_DEFINE_PARAMS] =
\r
2813 T_COMMENT => PARSER_EVENT_COMMENT,
\r
2814 T_DOC_COMMENT => PARSER_EVENT_COMMENT,
\r
2815 T_START_HEREDOC => PARSER_EVENT_EOFQUOTE,
\r
2817 $this->wordpushEvent[PARSER_EVENT_DEFINE_PARAMS] =
\r
2819 "(" => PARSER_EVENT_DEFINE_PARAMS_PARENTHESIS,
\r
2820 '"' => PARSER_EVENT_QUOTE,
\r
2821 "'" => PARSER_EVENT_QUOTE,
\r
2823 $this->wordpopEvent[PARSER_EVENT_DEFINE_PARAMS] = array(")");
\r
2824 /**************************************************************/
\r
2826 $this->tokenpushEvent[PARSER_EVENT_INCLUDE_PARAMS] =
\r
2828 T_COMMENT => PARSER_EVENT_COMMENT,
\r
2829 T_DOC_COMMENT => PARSER_EVENT_COMMENT,
\r
2831 $this->wordpushEvent[PARSER_EVENT_INCLUDE_PARAMS] =
\r
2833 "(" => PARSER_EVENT_INCLUDE_PARAMS_PARENTHESIS,
\r
2835 $this->wordpopEvent[PARSER_EVENT_INCLUDE_PARAMS] = array(")");
\r
2836 /**************************************************************/
\r
2838 $this->tokenpushEvent[PARSER_EVENT_DEFINE_PARAMS_PARENTHESIS] =
\r
2840 T_COMMENT => PARSER_EVENT_COMMENT,
\r
2841 T_DOC_COMMENT => PARSER_EVENT_COMMENT,
\r
2843 $this->wordpushEvent[PARSER_EVENT_DEFINE_PARAMS_PARENTHESIS] =
\r
2845 "(" => PARSER_EVENT_DEFINE_PARAMS_PARENTHESIS,
\r
2846 '"' => PARSER_EVENT_QUOTE,
\r
2847 "'" => PARSER_EVENT_QUOTE,
\r
2849 $this->wordpopEvent[PARSER_EVENT_DEFINE_PARAMS_PARENTHESIS] = array(")");
\r
2850 /**************************************************************/
\r
2852 $this->tokenpushEvent[PARSER_EVENT_INCLUDE_PARAMS_PARENTHESIS] =
\r
2854 T_COMMENT => PARSER_EVENT_COMMENT,
\r
2855 T_DOC_COMMENT => PARSER_EVENT_COMMENT,
\r
2857 $this->wordpushEvent[PARSER_EVENT_INCLUDE_PARAMS_PARENTHESIS] =
\r
2859 "(" => PARSER_EVENT_INCLUDE_PARAMS_PARENTHESIS,
\r
2861 $this->wordpopEvent[PARSER_EVENT_INCLUDE_PARAMS_PARENTHESIS] = array(")");
\r
2862 /**************************************************************/
\r
2864 $this->tokenpushEvent[PARSER_EVENT_VAR] =
\r
2866 T_COMMENT => PARSER_EVENT_COMMENT,
\r
2867 T_DOC_COMMENT => PARSER_EVENT_COMMENT,
\r
2868 T_ARRAY => PARSER_EVENT_VAR_ARRAY,
\r
2870 $this->wordpopEvent[PARSER_EVENT_VAR] = array(";");
\r
2871 /**************************************************************/
\r
2873 $this->tokenpushEvent[PARSER_EVENT_CLASS_CONSTANT] =
\r
2875 T_COMMENT => PARSER_EVENT_COMMENT,
\r
2876 T_DOC_COMMENT => PARSER_EVENT_COMMENT,
\r
2877 T_ARRAY => PARSER_EVENT_VAR_ARRAY,
\r
2879 $this->wordpopEvent[PARSER_EVENT_CLASS_CONSTANT] = array(";");
\r
2880 /**************************************************************/
\r
2882 $this->wordpopEvent[PARSER_EVENT_IMPLEMENTS] = array('{');
\r
2883 /**************************************************************/
\r
2885 $this->tokenpushEvent[PARSER_EVENT_CLASS] =
\r
2887 T_ABSTRACT => PARSER_EVENT_ACCESS_MODIFIER,
\r
2888 T_PUBLIC => PARSER_EVENT_ACCESS_MODIFIER,
\r
2889 T_PRIVATE => PARSER_EVENT_ACCESS_MODIFIER,
\r
2890 T_PROTECTED => PARSER_EVENT_ACCESS_MODIFIER,
\r
2891 T_STATIC => PARSER_EVENT_ACCESS_MODIFIER,
\r
2892 T_IMPLEMENTS => PARSER_EVENT_IMPLEMENTS,
\r
2893 T_CONST => PARSER_EVENT_CLASS_CONSTANT,
\r
2894 T_FUNCTION => PARSER_EVENT_FUNCTION,
\r
2895 T_VAR => PARSER_EVENT_VAR,
\r
2896 T_COMMENT => PARSER_EVENT_DOCBLOCK,
\r
2897 T_DOC_COMMENT => PARSER_EVENT_DOCBLOCK,
\r
2898 T_CLOSE_TAG => PARSER_EVENT_OUTPHP,
\r
2900 $this->wordpopEvent[PARSER_EVENT_CLASS] = array("}");
\r
2901 /**************************************************************/
\r
2903 $this->tokenpushEvent[PARSER_EVENT_DEFINE_GLOBAL] =
\r
2905 T_COMMENT => PARSER_EVENT_COMMENT,
\r
2906 T_DOC_COMMENT => PARSER_EVENT_COMMENT,
\r
2908 $this->wordpushEvent[PARSER_EVENT_DEFINE_GLOBAL] =
\r
2910 "=" => PARSER_EVENT_GLOBAL_VALUE,
\r
2912 $this->wordpopEvent[PARSER_EVENT_DEFINE_GLOBAL] = array(";");
\r
2913 /**************************************************************/
\r
2915 $this->tokenpushEvent[PARSER_EVENT_GLOBAL_VALUE] =
\r
2917 T_ARRAY => PARSER_EVENT_ARRAY,
\r
2918 T_COMMENT => PARSER_EVENT_COMMENT,
\r
2919 T_DOC_COMMENT => PARSER_EVENT_COMMENT,
\r
2920 T_START_HEREDOC => PARSER_EVENT_EOFQUOTE,
\r
2922 $this->wordpushEvent[PARSER_EVENT_GLOBAL_VALUE] =
\r
2924 '"' => PARSER_EVENT_QUOTE,
\r
2925 "'" => PARSER_EVENT_QUOTE,
\r
2927 $this->wordpopEvent[PARSER_EVENT_GLOBAL_VALUE] = array(";");
\r
2931 * initializes all the setup
\r
2933 * @param mixed &$data the data parser (?)
\r
2937 function configWordParser(&$data)
\r
2939 $this->_wp->setup($data);
\r
2940 $this->_wp->setWhitespace(false);
\r