+++ /dev/null
-<?php\r
-/**\r
- * Base parser for all parsers\r
- * \r
- * phpDocumentor :: automatic documentation generator\r
- * \r
- * PHP versions 4 and 5\r
- *\r
- * Copyright (c) 2000-2006 Joshua Eichorn, Gregory Beaver\r
- * \r
- * LICENSE:\r
- * \r
- * This library is free software; you can redistribute it\r
- * and/or modify it under the terms of the GNU Lesser General\r
- * Public License as published by the Free Software Foundation;\r
- * either version 2.1 of the License, or (at your option) any\r
- * later version.\r
- * \r
- * This library is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- * \r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with this library; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
- *\r
- * @package phpDocumentor\r
- * @subpackage Parsers\r
- * @author Joshua Eichorn <jeichorn@phpdoc.org>\r
- * @author Gregory Beaver <cellog@php.net>\r
- * @copyright 2000-2006 Joshua Eichorn, Gregory Beaver\r
- * @license http://www.opensource.org/licenses/lgpl-license.php LGPL\r
- * @version CVS: $Id: Parser.inc,v 1.9 2007/06/22 14:58:30 ashnazg Exp $\r
- * @link http://www.phpdoc.org\r
- * @link http://pear.php.net/PhpDocumentor\r
- * @since 0.1\r
- */\r
-/** used when a backslash is encountered in parsing a string or other escapable entity */ \r
-define("PARSER_EVENT_ESCAPE" , 900);\r
-/** used when a backslash is encountered in parsing a string or other escapable entity */ \r
-define("STATE_ESCAPE" , 1000);\r
-\r
-/** Class published to IntermediateParser with this event */\r
-define("PHPDOCUMENTOR_EVENT_CLASS" , 800);\r
-/** DocBlock published to IntermediateParser with this event */\r
-define("PHPDOCUMENTOR_EVENT_DOCBLOCK" , 801);\r
-/** Function published to IntermediateParser with this event */\r
-define("PHPDOCUMENTOR_EVENT_FUNCTION" , 802);\r
-/** Class Variable published to IntermediateParser with this event */\r
-define("PHPDOCUMENTOR_EVENT_VAR" , 803);\r
-/** New File (page) published to IntermediateParser with this event */\r
-define("PHPDOCUMENTOR_EVENT_PAGE" , 804);\r
-/** Constant (define) published to IntermediateParser with this event */\r
-define("PHPDOCUMENTOR_EVENT_DEFINE" , 805);\r
-/** Class Constant published to IntermediateParser with this event */\r
-define("PHPDOCUMENTOR_EVENT_CONST" , 806);\r
-/** @deprecated */\r
-define("PHPDOCUMENTOR_EVENT_MESSAGE" , 807);\r
-/** use to inform IntermediateParser of a new element being parsed */\r
-define("PHPDOCUMENTOR_EVENT_NEWSTATE" , 808);\r
-/**\r
- * used to inform phpDocumentor_IntermediateParser that the current file has been completely parsed.\r
- * Render then flushes all buffers for functions/classes/defines/includes on the current page\r
- * @see phpDocumentor_IntermediateParser::HandleEvent()\r
- */\r
-define("PHPDOCUMENTOR_EVENT_END_PAGE" , 808);\r
-/** Package-level page published to IntermediateParser with this event */\r
-define("PHPDOCUMENTOR_EVENT_PACKAGEPAGE" , 809);\r
-/** Include (include/require/include_once/include_once) published to IntermediateParser with this event */\r
-define("PHPDOCUMENTOR_EVENT_INCLUDE" , 810);\r
-/** Tutorial published to IntermediateParser with this event */\r
-define("PHPDOCUMENTOR_EVENT_TUTORIAL" , 811);\r
-/** Contents of README/INSTALL/CHANGELOG files published to IntermediateParser with this event */\r
-define("PHPDOCUMENTOR_EVENT_README_INSTALL_CHANGELOG" , 812);\r
-\r
-/** use to inform ErrorTracker of a new file being parsed */\r
-define("PHPDOCUMENTOR_EVENT_NEWFILE" , 811);\r
-/** use to inform ErrorTracker of the next line number being parsed */\r
-define("PHPDOCUMENTOR_EVENT_NEWLINENUM" , 812);\r
-/** used when a global variable definition is encountered in the source */\r
-define("PHPDOCUMENTOR_EVENT_GLOBAL" , 813);\r
-/** used when a docblock template is encountered in the source */\r
-define("PHPDOCUMENTOR_EVENT_DOCBLOCK_TEMPLATE" , 814);\r
-/** used when a docblock template is encountered in the source */\r
-define("PHPDOCUMENTOR_EVENT_END_DOCBLOCK_TEMPLATE" , 815);\r
-/** used when double quotation mark (") encountered in parsing */\r
-define("PARSER_EVENT_QUOTE" , 101);\r
-/** currently parsing a quote */\r
-define("STATE_QUOTE" , 201);\r
-\r
-/** { encountered in parsing a function or php code */\r
-define("PARSER_EVENT_LOGICBLOCK" , 102);\r
-/** currently parsing a { } block */\r
-define("STATE_LOGICBLOCK" , 202);\r
-\r
-/** used for the beginning of parsing, before first < ? php encountered */\r
-define("PARSER_EVENT_NOEVENTS" , 103);\r
-/** out of < ? php tag */\r
-define("STATE_NOEVENTS" , 203);\r
-\r
-/** used when long comment /x x/ where x is an asterisk is encountered in parsing */\r
-define("PARSER_EVENT_COMMENTBLOCK" , 104);\r
-/** currently parsing a long comment /x x/ where x is an asterisk */\r
-define("STATE_COMMENTBLOCK" , 204);\r
-\r
-/** used when short comment // is encountered in parsing */\r
-define("PARSER_EVENT_COMMENT" , 105);\r
-/** currently parsing a short comment // */\r
-define("STATE_COMMENT" , 205);\r
-\r
-/** used when php code processor instruction (< ? php) is encountered in parsing */\r
-define("PARSER_EVENT_PHPCODE" , 106);\r
-/** currently parsing php code */\r
-define("STATE_PHPCODE" , 206);\r
-\r
-/** used when a define statement is encountered in parsing */\r
-define("PARSER_EVENT_DEFINE" , 107);\r
-/** currently parsing a define statement */\r
-define("STATE_DEFINE" , 207);\r
-\r
-/** used when a define statement opening parenthesis is encountered in parsing */\r
-define("PARSER_EVENT_DEFINE_PARAMS" , 108);\r
-/** currently parsing the stuff in ( ) of a define statement */\r
-define("STATE_DEFINE_PARAMS" , 208);\r
-\r
-/** used when a function statement opening parenthesis is encountered in parsing */\r
-define("PARSER_EVENT_FUNCTION_PARAMS" , 109);\r
-/** currently parsing the stuff in ( ) of a function definition */\r
-define("STATE_FUNCTION_PARAMS" , 209);\r
-\r
-/** used when a single quote (') is encountered in parsing */\r
-define("PARSER_EVENT_SINGLEQUOTE" , 110);\r
-/** currently parsing a string enclosed in single quotes (') */\r
-define("STATE_SINGLEQUOTE" , 210);\r
-\r
-/** used when a class definition is encountered in parsing */\r
-define("PARSER_EVENT_CLASS" , 111);\r
-/** currently parsing a class definition */\r
-define("STATE_CLASS" , 211);\r
-/** used to tell Render that a class has been completely parsed, and to flush buffers */\r
-define("STATE_END_CLASS" , 311);\r
-\r
-/** used when a DocBlock is encountered in parsing */\r
-define("PARSER_EVENT_DOCBLOCK" , 112);\r
-/** currently parsing a DocBlock */\r
-define("STATE_DOCBLOCK" , 212);\r
-\r
-/** used when a @tag is encountered in DocBlock parsing */\r
-define("PARSER_EVENT_DOCKEYWORD" , 113);\r
-/** currently parsing a @tag in a DocBlock */\r
-define("STATE_DOCKEYWORD" , 213);\r
-\r
-/** used when a <email@address> is encountered in parsing an @author tag*/\r
-define("PARSER_EVENT_DOCKEYWORD_EMAIL" , 114);\r
-/** currently parsing an email in brackets in an @author tag of a DocBlock */\r
-define("STATE_DOCKEYWORD_EMAIL" , 214);\r
-\r
-/** used when an array definition is encountered in parsing */\r
-define("PARSER_EVENT_ARRAY" , 115);\r
-/** currently parsing an array */\r
-define("STATE_ARRAY" , 215);\r
-\r
-/** used when a var statement is encountered in parsing a class definition */\r
-define("PARSER_EVENT_VAR" , 116);\r
-/** currently parsing a Class variable */\r
-define("STATE_VAR" , 216);\r
-\r
-/** used when a function definition is encountered in parsing */\r
-define("PARSER_EVENT_FUNCTION" , 117);\r
-/** currently parsing a Function or Method */\r
-define("STATE_FUNCTION" , 217);\r
-\r
-/** used when a ? > (with no space) is encountered in parsing */\r
-define("PARSER_EVENT_OUTPHP" , 118);\r
-/** currently out of php code */\r
-define("STATE_OUTPHP" , 218);\r
-\r
-/** used when an inline {@tag} is encountered in parsing a DocBlock */\r
-define("PARSER_EVENT_INLINE_DOCKEYWORD" , 119);\r
-/** currently parsing an inline tag like { @link} in a DocBlock */\r
-define("STATE_INLINE_DOCKEYWORD" , 219);\r
-\r
-/** used when a define statement's opening parenthesis is encountered in parsing */\r
-define("PARSER_EVENT_DEFINE_PARAMS_PARENTHESIS" , 120);\r
-/** currently parsing an inner parenthetical statement of a define( ) */\r
-define("STATE_DEFINE_PARAMS_PARENTHESIS" , 220);\r
-\r
-define("PARSER_EVENT_END_STATEMENT", 121);\r
-\r
-/** used when a <<< is encountered in parsing */\r
-define("PARSER_EVENT_EOFQUOTE" , 122);\r
-/** currently parsing a string defined using Perl <<< */\r
-define("STATE_EOFQUOTE" , 222);\r
-\r
-/** used when an include/require/include_once/include_once statement is encountered in parsing */\r
-define("PARSER_EVENT_INCLUDE" , 123);\r
-/** currently parsing an include/require/include_once/include_once */\r
-define("STATE_INCLUDE" , 223);\r
-\r
-/** used when an opening parenthesis of an include/require/include_once/include_once statement is encountered in parsing */\r
-define("PARSER_EVENT_INCLUDE_PARAMS" , 124);\r
-/** currently parsing the stuff in ( ) of a define statement */\r
-define("STATE_INCLUDE_PARAMS" , 224);\r
-\r
-/** used when an inner ( ) is encountered while parsing an include/require/include_once/include_once statement */\r
-define("PARSER_EVENT_INCLUDE_PARAMS_PARENTHESIS" , 125);\r
-/** currently parsing an inner parenthetical statement of an include/includeonce/require/requireonce( ) */\r
-define("STATE_INCLUDE_PARAMS_PARENTHESIS" , 225);\r
-\r
-/** used when parsing the desc part of a docblock */\r
-define("PARSER_EVENT_DESC" , 126);\r
-/** currently parsing the desc part of a docblock */\r
-define("STATE_DESC" , 226);\r
-\r
-/** used when parsing the @tag block of a docblock */\r
-define("PARSER_EVENT_TAGS" , 127);\r
-/** currently parsing the @tag block of a docblock */\r
-define("STATE_TAGS" , 227);\r
-\r
-/** used when parsing a global variable declaration */\r
-define("PARSER_EVENT_DEFINE_GLOBAL" , 128);\r
-/** currently parsing a global variable declaration */\r
-define("STATE_GLOBAL" , 228);\r
-\r
-/** used when parsing the default value in a global variable declaration */\r
-define("PARSER_EVENT_GLOBAL_VALUE" , 129);\r
-/** currently parsing the default value in a global variable declaration */\r
-define("STATE_GLOBAL_VALUE" , 229);\r
-\r
-/** used when parsing a "global $var1, $var2;" declaration in a function */\r
-define("PARSER_EVENT_FUNC_GLOBAL" , 130);\r
-/** currently parsing a "global $var1, $var2;" declaration in a function */\r
-define("STATE_FUNC_GLOBAL" , 230);\r
-\r
-/** used when parsing a "static $var1, $var2;" declaration in a function */\r
-define("PARSER_EVENT_STATIC_VAR" , 131);\r
-/** currently parsing a "static $var1, $var2;" declaration in a function */\r
-define("STATE_STATIC_VAR" , 231);\r
-\r
-/** used when parsing the value in a "static $var1 = x" declaration in a function */\r
-define("PARSER_EVENT_STATIC_VAR_VALUE" , 132);\r
-/** currently parsing the value in a "static $var1 = x" declaration in a function */\r
-define("STATE_STATIC_VAR_VALUE" , 232);\r
-\r
-/** used when encountering a /**#@+ comment marking a new docblock template */\r
-define("PARSER_EVENT_DOCBLOCK_TEMPLATE" , 133);\r
-/** currently parsing the value in a "static $var1 = x" declaration in a function */\r
-define("STATE_DOCBLOCK_TEMPLATE" , 233);\r
-\r
-/** used when encountering a /**#@-* / comment (no space) marking the end of using a docblock template */\r
-define("PARSER_EVENT_END_DOCBLOCK_TEMPLATE" , 134);\r
-/** currently parsing the value in a "static $var1 = x" declaration in a function */\r
-define("STATE_END_DOCBLOCK_TEMPLATE" , 234);\r
-\r
-/** used by the {@link HighlightParser} only, when a method starts */\r
-define("PARSER_EVENT_METHOD" , 135);\r
-/** currently parsing a method using the {@link HighlightParser} */\r
-define("STATE_METHOD" , 235);\r
-\r
-/** used by the {@link HighlightParser} only, when a method body is parsed */\r
-define("PARSER_EVENT_METHOD_LOGICBLOCK" , 136);\r
-/** currently parsing the method body using the {@link HighlightParser} */\r
-define("STATE_METHOD_LOGICBLOCK" , 236);\r
-\r
-/** used by the {@link HighlightParser} only, when ->var or ->function() is encountered in a method */\r
-define("PARSER_EVENT_CLASS_MEMBER" , 137);\r
-/** currently parsing a class member using the {@link HighlightParser} */\r
-define("STATE_CLASS_MEMBER" , 237);\r
-\r
-/** used by the {@link HighlightParser} only, when {$var} is encountered in a string */\r
-define("PARSER_EVENT_QUOTE_VAR" , 138);\r
-/** currently parsing a {$encapsed_var} using the {@link HighlightParser} */\r
-define("STATE_QUOTE_VAR" , 238);\r
-\r
-/** used when parsing an access modifier */\r
-define("PARSER_EVENT_ACCESS_MODIFIER" , 139);\r
-/** currently parsing an access modifier */\r
-define("STATE_ACCESS_MODIFIER" , 239);\r
-\r
-/** used when a class implements interfaces */\r
-define("PARSER_EVENT_IMPLEMENTS" , 140);\r
-/** currently parsing an implements clause */\r
-define("STATE_IMPLEMENTS" , 240);\r
-\r
-/** used when a class implements interfaces */\r
-define("PARSER_EVENT_CLASS_CONSTANT" , 141);\r
-/** currently parsing a class constant */\r
-define("STATE_CLASS_CONSTANT" , 241);\r
-\r
-/** used when a variable value is an array */\r
-define("PARSER_EVENT_VAR_ARRAY" , 142);\r
-/** currently parsing a variable value is an array */\r
-define("STATE_VAR_ARRAY" , 242);\r
-\r
-/** used when a comment is found in a variable array value */\r
-define("PARSER_EVENT_VAR_ARRAY_COMMENT" , 143);\r
-/** currently parsing a comment in a variable array value */\r
-define("STATE_VAR_ARRAY_COMMENT" , 243);\r
-\r
-/** used when a $param is encountered in a function definition */\r
-define("PARSER_EVENT_FUNCTION_PARAM_VAR", 144);\r
-/** currently parsing a $param in a function definition */\r
-define("STATE_FUNCTION_PARAM_VAR", 244);\r
-\r
-if (!defined('T_INTERFACE'))\r
-{\r
- define('T_INTERFACE', 'foo');\r
- if (!defined('T_CONST')) {\r
- define('T_CONST', 'foo');\r
- }\r
- define('T_ABSTRACT', 'foo');\r
- define('T_PRIVATE', 'foo');\r
- define('T_PUBLIC', 'foo');\r
- define('T_PROTECTED', 'foo');\r
- define('T_FINAL', 'foo');\r
- define('T_IMPLEMENTS', 'foo');\r
-}\r
-if (!defined('T_ML_COMMENT'))\r
-{\r
- define('T_ML_COMMENT', T_COMMENT);\r
-}\r
-if (!defined('T_DOC_COMMENT'))\r
-{\r
- define('T_DOC_COMMENT', T_ML_COMMENT);\r
-}\r
-/**\r
- * PHP Parser for PHP 4.2.3-\r
- *\r
- * This parser is slower than the tokenizer-based parser, and is deprecated.\r
- * @author Joshua Eichorn <jeichorn@phpdoc.org>\r
- * @author Gregory Beaver <cellog@php.net>\r
- * @version $Id: Parser.inc,v 1.9 2007/06/22 14:58:30 ashnazg Exp $\r
- * @package phpDocumentor\r
- * @subpackage Parsers\r
- * @deprecated in favor of {@link phpDocumentorTParser}\r
- */\r
-class Parser extends Publisher\r
-{\r
- /**#@+\r
- * @access private\r
- */\r
- /**\r
- * Word parser\r
- * @see WordParser\r
- */\r
- var $wp;\r
- \r
- /**\r
- * temporary parser variables\r
- */\r
- var $p_vars = array('func' => false, 'function_data' => '', 'quote_data' => '', 'event_stack' => false, 'last_pevent' => 0,\r
- 'two_words_ago' => '', 'temp_word' => '', 'docblock' => false, 'line' => array(), 'linecount' => 0, 'startword' => '',\r
- 'periodline' => 0, 'shortdesc' => '', 'docblock_desc' => '', 'class' => false, 'source_location' => '',\r
- 'define_params_data' => '', 'define' => false, 'define_name' => '', 'define_value' => '', 'var' => false,\r
- 'oldtoken' => false, 'comment_data' => '', 'function_param' => NULL, 'inline_dockeyword_type' => false,\r
- 'inline_dockeyword_data' => false, 'dockeyword_type' => false, 'dockeyword_data' =>false, 'param_var' => false,\r
- 'include_name' => '', 'include_value' => '','include' => false, 'return_type' => '', 'cur_class' => '', 'property_name' => false,\r
- 'function_data' => false, 'varname' => '', 'returntype' => false, 'vartype' => false, 'paramtype' => false,\r
- 'tagname' => '', 'find_global' => '', 'global_type' => '', 'paramname' => false, 'statics' => array(),\r
- 'static_count' => 0, 'static_val' => array(), 'docblock_type' => 'docblock', 'seelement' => false);\r
- \r
- /**\r
- * parser flags, for states that don't warrant a new event (like new line in a docblock)\r
- */\r
- var $p_flags = array('docblocknewline' => false, 'docblockintags' => false, 'useperiod' => false,\r
- 'definename_isset' => false, 'define_parens' => false, 'reset_quote_data' => false,\r
- 'in_desc' => true, 'in_tag' => false, 'newline' => true, 'tempnewline' => false,\r
- 'start_docblock' => false, 'includename_isset' => false, 'return_isset' => false,\r
- 'is_return' => false, 'in_class' => false, 'asterisk' => false, 'var_equals' => false,\r
- 'arrayinvarname' => false, 'valid_newline' => true, 'startline' => false,\r
- 'function_global' => false, 'define_global' => false, 'static_value' => false,'funcparam_val' => false,\r
- 'get_source' => false, 'getting_source' => false);\r
-\r
- /**\r
- * lookup table for event handler methods\r
- * @see Parser::parse()\r
- */\r
- var $eventHandlers = array(\r
- 'handleArray' => PARSER_EVENT_ARRAY,\r
- 'handleClass' => PARSER_EVENT_CLASS,\r
- 'handleComment' => PARSER_EVENT_COMMENT,\r
- 'handleDocBlockTemplate' => PARSER_EVENT_DOCBLOCK_TEMPLATE,\r
- 'handleEndDocBlockTemplate' => PARSER_EVENT_END_DOCBLOCK_TEMPLATE,\r
- 'handleEscape' => PARSER_EVENT_ESCAPE,\r
- 'handleLogicBlock' => PARSER_EVENT_LOGICBLOCK,\r
- 'defaultHandler' => PARSER_EVENT_NOEVENTS,\r
-// 'defaultHandler' => PARSER_EVENT_COMMENTBLOCK, (set in constructor below)\r
-// 'defaultHandler' => PARSER_EVENT_OUTPHP,\r
- 'handleDefine' => PARSER_EVENT_DEFINE,\r
- 'handleDefineParams' => PARSER_EVENT_DEFINE_PARAMS,\r
- 'handleDefineParamsParenthesis' => PARSER_EVENT_DEFINE_PARAMS_PARENTHESIS,\r
- 'handleIncludeParamsParenthesis' => PARSER_EVENT_INCLUDE_PARAMS_PARENTHESIS,\r
-// 'handleDocBlock' => PARSER_EVENT_DOCBLOCK,\r
- 'BetterhandleDocBlock' => PARSER_EVENT_DOCBLOCK,\r
- 'handleTags' => PARSER_EVENT_TAGS,\r
- 'handleDesc' => PARSER_EVENT_DESC,\r
-// 'handleDockeyword' => PARSER_EVENT_DOCKEYWORD,\r
- 'handleTag' => PARSER_EVENT_DOCKEYWORD,\r
- 'handleDockeywordEmail' => PARSER_EVENT_DOCKEYWORD_EMAIL,\r
- 'handleEOFQuote' => PARSER_EVENT_EOFQUOTE,\r
- 'handleFunction' => PARSER_EVENT_FUNCTION,\r
- 'handleFunctionParams' => PARSER_EVENT_FUNCTION_PARAMS,\r
- 'handleFuncGlobal' => PARSER_EVENT_FUNC_GLOBAL,\r
- 'handleGlobal' => PARSER_EVENT_DEFINE_GLOBAL,\r
- 'handleGlobalValue' => PARSER_EVENT_GLOBAL_VALUE,\r
- 'handleInlineDockeyword' => PARSER_EVENT_INLINE_DOCKEYWORD,\r
- 'handleInclude' => PARSER_EVENT_INCLUDE,\r
- 'handleIncludeParams' => PARSER_EVENT_INCLUDE_PARAMS,\r
- 'handleQuote' => PARSER_EVENT_QUOTE,\r
- 'handlePhpCode' => PARSER_EVENT_PHPCODE,\r
- 'handleSingleQuote' => PARSER_EVENT_SINGLEQUOTE,\r
- 'handleStaticVar' => PARSER_EVENT_STATIC_VAR,\r
- 'handleStaticValue' => PARSER_EVENT_STATIC_VAR_VALUE,\r
- 'handleVar' => PARSER_EVENT_VAR,\r
- );\r
- \r
- /**\r
- * event handlers for @tags\r
- * @tutorial tags.pkg\r
- */\r
- var $tagHandlers = array(\r
- '*' => 'defaultTagHandler',\r
- 'category' => 'categoryTagHandler',\r
- 'example' => 'exampleTagHandler',\r
- 'filesource' => 'invalidTagHandler',\r
- 'return' => 'returnTagHandler',\r
- 'returns' => 'returnTagHandler',\r
- 'var' => 'varTagHandler',\r
- 'package' => 'packageTagHandler',\r
- 'param' => 'paramTagHandler',\r
- 'parameter' => 'paramTagHandler',\r
- 'global' => 'globalTagHandler',\r
- 'staticvar' => 'staticvarTagHandler',\r
- 'uses' => 'usesTagHandler',\r
- 'property' => 'propertyTagHandler',\r
- 'property-read' => 'propertyTagHandler',\r
- 'property-write' => 'propertyTagHandler',\r
- 'method' => 'propertyTagHandler'\r
- );\r
-\r
- var $laststart = false;\r
-\r
- /**\r
- * An array of allowable @tags\r
- */\r
- var $allowableTags;\r
-\r
-\r
- /**\r
- * An array of allowed inline @tags\r
- */\r
- var $allowableInlineTags;\r
- \r
- /**\r
- * Sets the states up, and creates a new WordParser\r
- */\r
- \r
- /**\r
- * an array of parsing tokens organized by event number.\r
- * A token is defined as the smallest group of characters that separates or\r
- * defines a new parser element. In English, a space or punctuation are\r
- * tokens that separate words. in PHP, tokens may be //, or even "\r
- * Format: array(eventnum =>array(token1, token2, token3, ...),...)\r
- * @var array\r
- */\r
- var $tokens;\r
- \r
- /**\r
- * array of events that are raised, organized by the tokens that raise them.\r
- * Format: array(eventnum => array(token => neweventnum, token2 => neweventnum2,...),...)\r
- * @var array\r
- */\r
- var $pushEvent;\r
- \r
- /**\r
- * array of tokens that end an event, organized by event\r
- * Format: array(eventnum => array(token => neweventnum, token2 => neweventnum2,...),...)\r
- * @var array\r
- */\r
- var $popEvent;\r
- /**#@-*/\r
- \r
- /**\r
- * Set up invariant parsing variables\r
- */\r
- function Parser()\r
- {\r
- $this->allowableTags = $GLOBALS['_phpDocumentor_tags_allowed'];\r
- $this->allowableInlineTags = $GLOBALS['_phpDocumentor_inline_doc_tags_allowed'];\r
- $this->wp = new WordParser;\r
- // strange PHP 4.0.6 behavior: it converts constants to strings without warning if it's an array index\r
- $this->eventHandlers = array_flip($this->eventHandlers);\r
- $this->eventHandlers[PARSER_EVENT_COMMENTBLOCK] = 'defaultHandler';\r
- $this->eventHandlers[PARSER_EVENT_OUTPHP] = 'defaultHandler';\r
- $this->subscribe(PHPDOCUMENTOR_EVENT_NEWLINENUM,$GLOBALS['phpDocumentor_errors']);\r
- $this->subscribe(PHPDOCUMENTOR_EVENT_NEWFILE,$GLOBALS['phpDocumentor_errors']);\r
- }\r
-\r
- /**\r
- * Parse a new file\r
- *\r
- * @param string $parse_data\r
- * @param string $path\r
- * @param int $base number of directories to drop off the bottom when creating names using path\r
- * @staticvar integer used for recursion limiting if a handler for an event is not found\r
- * @return bool\r
- */\r
- function parse (&$parse_data, $path, $base = 0, $packages = false)\r
- {\r
- global $_phpDocumentor_options;\r
- static $endrecur = 0;\r
- $this->p_vars = array('func' => false, 'function_data' => '', 'quote_data' => '', 'event_stack' => false, 'last_pevent' => 0,\r
- 'two_words_ago' => '', 'temp_word' => '', 'docblock' => false, 'line' => array(), 'linecount' => 0, 'startword' => '',\r
- 'periodline' => 0, 'shortdesc' => '', 'docblock_desc' => '', 'class' => false, 'source_location' => '',\r
- 'define_params_data' => '', 'define' => false, 'define_name' => '', 'define_value' => '', 'var' => false,\r
- 'oldtoken' => false, 'comment_data' => '', 'function_param' => NULL, 'inline_dockeyword_type' => false,\r
- 'inline_dockeyword_data' => false, 'dockeyword_type' => false, 'dockeyword_data' =>false, 'param_var' => false,\r
- 'include_name' => '', 'include_value' => '','include' => false, 'return_type' => '', 'cur_class' => '', 'property_name' => false,\r
- 'function_data' => false, 'varname' => '', 'returntype' => false, 'vartype' => false, 'paramtype' => false,\r
- 'tagname' => '', 'find_global' => '', 'global_type' => '', 'paramname' => false, 'statics' => array(),\r
- 'static_count' => 0, 'static_val' => array(), 'docblock_type' => 'docblock', 'linenum' => false,\r
- 'seelement' => false);\r
- \r
- $this->p_flags = array('docblocknewline' => false, 'docblockintags' => false, 'useperiod' => false,\r
- 'definename_isset' => false, 'define_parens' => false, 'reset_quote_data' => false,\r
- 'in_desc' => true, 'in_tag' => false, 'newline' => true, 'tempnewline' => false,\r
- 'start_docblock' => false, 'includename_isset' => false, 'return_isset' => false,\r
- 'is_return' => false, 'in_class' => false, 'asterisk' => false, 'var_equals' => false,\r
- 'arrayinvarname' => false, 'valid_newline' => true, 'startline' => false,\r
- 'function_global' => false, 'define_global' => false, 'static_value' => false,'funcparam_val' => false,\r
- 'get_source' => false, 'getting_source' => false, 'in_define' => false, 'in_include' => false,\r
- 'in_var' => false, 'in_global' => false);\r
- $this->p_vars['parsepath'] = $path;\r
- $this->setupStates();\r
- if (strlen($parse_data) == 0)\r
- {\r
- return false;\r
- }\r
-\r
- // initialize variables so E_ALL error_reporting doesn't complain\r
- $pevent = 0;\r
- $word = 0;\r
- $this->p_vars['event_stack'] = new EventStack;\r
-\r
- $this->wp->setup($parse_data);\r
- \r
-\r
- $page = new ParserPage;\r
- $page->setPath($path);\r
- $page->setPackageOutput($packages);\r
- $page->setFile(basename($path));\r
- $this->publishEvent(PHPDOCUMENTOR_EVENT_NEWFILE,basename($path));\r
- //$name = str_replace("/","_",dirname($path)) . "_" . array_shift(explode(".",$page->getFile()));\r
- // fc@fc.clever-soft.com 11/29/2001\r
- $name = str_replace( ':', '', dirname($path) . PATH_DELIMITER . $page->getFile() );\r
- $tmp = explode( PATH_DELIMITER, $name );\r
- $name = implode( "---", array_slice( $tmp, $base ) );\r
- // if base is '', drive letter is present in windows\r
-\r
- $page->setName($name);\r
- $temploc = $_phpDocumentor_options['Program_Root'] . PATH_DELIMITER. implode(PATH_DELIMITER,\r
- array_slice(explode(PATH_DELIMITER,$path),$base));\r
- \r
- if ($temploc == $_phpDocumentor_options['Program_Root'] . PATH_DELIMITER) $temploc .= $path;\r
- \r
- $this->p_vars['source_location'] = $source_location = $temploc;\r
- $page->setSourceLocation($source_location);\r
-\r
- $this->publishEvent(PHPDOCUMENTOR_EVENT_PAGE,$page);\r
- unset($page);\r
- $this->p_flags['reset_quote_data'] = true;\r
-\r
- do\r
- {\r
- $lpevent = $pevent;\r
- $pevent = $this->p_vars['event_stack']->getEvent();\r
- if ($lpevent != $pevent)\r
- {\r
- $this->p_vars['last_pevent'] = $lpevent;\r
- }\r
-\r
- if ($this->p_vars['last_pevent'] != $pevent)\r
- {\r
- // its a new event so the word parser needs to be reconfigured \r
- $this->configWordParser($pevent);\r
- }\r
- \r
- $this->publishEvent(PHPDOCUMENTOR_EVENT_NEWSTATE,($pevent + 100));\r
-\r
- if ($pevent == PARSER_EVENT_GLOBAL_VALUE || $pevent == PARSER_EVENT_DOCBLOCK || $pevent == PARSER_EVENT_DOCBLOCK_TEMPLATE)\r
- {\r
- $this->wp->setWhitespace(true);\r
- }\r
-\r
- $this->p_vars['last_word'] = $word;\r
- $word = $this->wp->getWord();\r
- // in wordparser, have to keep track of lines\r
- $this->publishEvent(PHPDOCUMENTOR_EVENT_NEWLINENUM, $this->wp->linenum);\r
-\r
- if (PHPDOCUMENTOR_DEBUG == true)\r
- {\r
- echo "\nLAST: |" . $this->p_vars['last_word'] . "|\n";\r
- echo "PEVENT: " . $this->getParserEventName($pevent) . "\n";\r
- echo "LASTPEVENT: " . $this->getParserEventName($this->p_vars['last_pevent']) . "\n";\r
- echo $this->wp->getPos() . ": |$word|\n--------------------------\n\n";\r
- }\r
- if ($this->p_flags['get_source'])\r
- {\r
- if ($pevent == PARSER_EVENT_FUNCTION)\r
- {\r
- $this->wp->retrievesource("function $word");\r
- $this->p_flags['get_source'] = false;\r
- $this->p_flags['getting_source'] = true;\r
- }\r
- }\r
- if (false)//$this->p_flags['getting_source'] && ($pevent == PARSER_EVENT_DOCBLOCK) || ($pevent == PARSER_EVENT_NOEVENTS))\r
- {\r
- addError(PDERROR_SOURCE_TAG_FUNCTION_NOT_FOUND);\r
- // throw away source\r
- $this->wp->getSource();\r
- }\r
- if (isset($this->eventHandlers[$pevent]))\r
- {\r
- $handle = $this->eventHandlers[$pevent];\r
- $this->$handle($word, $pevent);\r
- } else\r
- {\r
- debug('WARNING: possible error, no handler for event number '.$pevent);\r
- if ($endrecur++ == 25)\r
- {\r
- die("FATAL ERROR, recursion limit reached");\r
- }\r
- }\r
- } while (!($word === false));\r
- $this->publishEvent(PHPDOCUMENTOR_EVENT_NEWSTATE,PHPDOCUMENTOR_EVENT_END_PAGE);\r
- }\r
- \r
- /**#@+\r
- * @access private\r
- * @param string token parsed from source\r
- * @param integer parser constant from {@link Parser.inc}\r
- */\r
- /**\r
- * handler for NOEVENTS, OUTPHP, COMMENTBLOCK\r
- */\r
- \r
- function defaultHandler($word, $pevent)\r
- {\r
- $this->checkEventPush( $word, $pevent);\r
- $this->checkEventPop($word,$pevent);\r
- }\r
- \r
- /**\r
- * handler for LOGICBLOCK\r
- *\r
- * Logic Blocks are the stuff between { and } in a function/method. A\r
- * logic block can clearly contain other logic blocks, as in:\r
- *\r
- * <code>\r
- * function test($a)\r
- * {\r
- * if (testcondition)\r
- * { // nested logic block\r
- * }\r
- * }\r
- * </code>\r
- *\r
- * So, the exit portion of the logic block handler must check to see if the\r
- * logic block being exited is the top-level, and it does this by retrieving\r
- * the last event from the stack. If it is a function (and not a logic block)\r
- * then it backs up the word parser so that the function will exit properly.\r
- *\r
- * {@source 11}\r
- */\r
- \r
- function handleLogicBlock($word, $pevent)\r
- {\r
- $a = $this->checkEventPush( $word, $pevent);\r
- if ($a == PARSER_EVENT_FUNC_GLOBAL || $a == PARSER_EVENT_STATIC_VAR)\r
- {\r
- if (substr($this->p_vars['last_word'],strlen($this->p_vars['last_word']) - 1,1) != ' ' && substr($this->p_vars['last_word'],strlen($this->p_vars['last_word']) - 1,1) != "\t" && substr($this->p_vars['last_word'],strlen($this->p_vars['last_word']) - 1,1) != "\n" && substr($this->p_vars['last_word'],strlen($this->p_vars['last_word']) - 1,1) != ";" && substr($this->p_vars['last_word'],strlen($this->p_vars['last_word']) - 1,1) != "}" && substr($this->p_vars['last_word'],strlen($this->p_vars['last_word']) - 1,1) != "{")\r
- {\r
- $this->p_vars['event_stack']->popEvent();\r
- }\r
- }\r
- if ($this->checkEventPop($word,$pevent))\r
- {\r
- $e = $this->p_vars['event_stack']->popEvent();\r
- $this->p_vars['event_stack']->pushEvent($e);\r
- if ($e == PARSER_EVENT_FUNCTION)\r
- {\r
- $this->wp->backupPos($word); \r
- }\r
- }\r
- }\r
- \r
- /**\r
- * handler for ESCAPE.\r
- * this event handler parses <code>"this string \"with its escape backslashes\""</code> and returns:\r
- * <code>this string "with its escape backslashes"</code>\r
- * to make it human-readable\r
- */\r
- \r
- function handleEscape($word, $pevent)\r
- {\r
- $this->p_vars['event_stack']->popEvent();\r
- }\r
- \r
- /**\r
- * handler for COMMENT.\r
- * this event handler parses single-line comments like:\r
- * // this one\r
- */\r
- \r
- function handleComment($word, $pevent)\r
- {\r
- $this->checkEventPush( $word, $pevent);\r
- \r
- if (!isset($this->p_vars['comment_data'])) $this->p_vars['comment_data'] = '';\r
- $this->p_vars['comment_data'] .= $word;\r
- \r
- $this->checkEventPop($word,$pevent);\r
- }\r
-\r
- /**\r
- * handler for ARRAY.\r
- * this event handler parses arrays in default values of function and var definitions\r
- */\r
- \r
- function handleArray($word, $pevent)\r
- {\r
- $e = $this->checkEventPush( $word, $pevent); \r
- if (($e == PARSER_EVENT_COMMENTBLOCK) ||\r
- ($e == PARSER_EVENT_COMMENT)) return;\r
-\r
- if (!isset($this->p_vars['function_data']) || (isset($this->p_vars['function_data']) && empty($this->p_vars['function_data'])))\r
- {\r
- $this->p_vars['function_data'] = "array";\r
- }\r
-\r
- if ( ($this->p_vars['last_word'] == "'"))\r
- {\r
- $this->p_vars['function_data'] .= $this->p_vars['quote_data']."'";\r
- }\r
- if ( ($this->p_vars['last_word'] == "\""))\r
- {\r
- $this->p_vars['function_data'] .= $this->p_vars['quote_data']."\"";\r
- }\r
-\r
- $this->p_vars['function_data'] .= $word;\r
- //echo "function_data = |$this->p_vars['function_data']|\n";\r
-\r
- if ($this->checkEventPop($word,$pevent))\r
- {\r
- }\r
- }\r
-\r
- /**\r
- * handler for DEFINE.\r
- * handles define(constant, value); statements\r
- */\r
- \r
- function handleDefine($word, $pevent)\r
- {\r
- if (!$this->p_flags['in_define'])\r
- {\r
- $this->p_vars['linenum'] = $this->wp->linenum;\r
- }\r
- $this->p_flags['in_define'] = true;\r
- $this->checkEventPush( $word, $pevent);\r
-\r
- $this->p_flags['definename_isset'] = false;\r
- $this->p_vars['define_params_data'] = '';\r
- unset($this->p_vars['quote_data']);\r
- if ($this->checkEventPop($word,$pevent))\r
- {\r
- $this->p_flags['in_define'] = false;\r
- $this->p_vars['define'] = new parserDefine;\r
- $this->p_vars['define']->setLineNumber($this->p_vars['linenum']);\r
- $this->p_vars['define']->setName($this->p_vars['define_name']);\r
- $this->p_vars['define']->setValue($this->p_vars['define_value']);\r
- $this->publishEvent(PHPDOCUMENTOR_EVENT_DEFINE,$this->p_vars['define']);\r
- $this->p_flags['definename_isset'] = false;\r
- unset($this->p_vars['define']);\r
- unset($this->p_vars['define_name']);\r
- unset($this->p_vars['define_value']);\r
- $this->p_flags['in_define'] = false;\r
- $this->p_vars['define_params_data'] = '';\r
- }\r
- }\r
- \r
- /**\r
- * handler for DEFINE_PARAMS.\r
- * handles the parsing of constant and value in define(constant, value);\r
- */\r
- \r
- function handleDefineParams($word, $pevent)\r
- {\r
- if ($this->checkEventPush( $word, $pevent))\r
- {\r
- if ($word == '(')\r
- {\r
- $this->p_vars['define_params_data'] .= $word;\r
- }\r
- return;\r
- }\r
- \r
- $this->p_flags['define_parens'] = true;\r
- if(!isset($this->p_vars['define_params_data'])) $this->p_vars['define_params_data'] = '';\r
- \r
- if ($this->checkEventPop($word,$pevent))\r
- {\r
- if (!empty($this->p_vars['quote_data']))\r
- {\r
- $this->p_vars['define_params_data'] .= $this->p_vars['quote_data'];\r
- }\r
- if (!empty($this->p_vars['define_params_data']))\r
- {\r
- //echo $this->p_vars['define_params_data']."\n";\r
- $this->p_vars['define_value'] = $this->p_vars['define_params_data'];\r
- }\r
- else\r
- {\r
- if ( $this->p_vars['last_word'] != "/*" && \r
- $this->p_vars['last_word'] != "//" && $this->p_vars['last_word'] != "#")\r
- {\r
- $this->p_vars['define_value'] = trim($this->p_vars['last_word']);\r
- }\r
- else\r
- {\r
- $this->p_vars['define_value'] = "";\r
- }\r
- }\r
- }\r
- if ($this->p_flags['definename_isset'])\r
- {\r
- if (isset($this->p_vars['quote_data']))\r
- {\r
- $this->p_vars['define_params_data'] .= '"'.$this->p_vars['quote_data'].'"';\r
- unset($this->p_vars['quote_data']);\r
- }\r
- $this->p_vars['define_params_data'] .= $word;\r
- } else\r
- {\r
- if ($word != ",")\r
- {\r
- if (isset($this->p_vars['quote_data']))\r
- {\r
- $this->p_vars['define_params_data'] .= $this->p_vars['quote_data'];\r
- unset($this->p_vars['quote_data']);\r
- }\r
- $this->p_vars['define_params_data'] .= $word;\r
- } else\r
- {\r
- if (isset($this->p_vars['quote_data']) && !$this->p_flags['definename_isset'])\r
- {\r
- $this->p_vars['define_params_data'] .= $this->p_vars['quote_data'];\r
- unset($this->p_vars['quote_data']);\r
- }\r
- $this->p_flags['definename_isset'] = true;\r
- $this->p_vars['define_name'] = $this->p_vars['define_params_data'];\r
- unset($this->p_vars['quote_data']);\r
- $this->p_vars['define_params_data'] = '';\r
- }\r
- }\r
- }\r
- \r
- /**\r
- * handler for DEFINE_PARAMS_PARENTHESIS.\r
- * this handler takes all parenthetical statements within constant or value in:\r
- * define(constant, value) of a define statement, and handles them properly\r
- */\r
- \r
- function handleDefineParamsParenthesis($word, $pevent)\r
- {\r
- if (isset($this->p_vars['quote_data']))\r
- {\r
- $this->p_vars['define_params_data'] .= '"'.$this->p_vars['quote_data'].'"';\r
- unset($this->p_vars['quote_data']);\r
- }\r
- $this->p_vars['define_params_data'] .= $word;\r
- $this->checkEventPush( $word, $pevent);\r
- $this->checkEventPop( $word, $pevent);\r
- }\r
-\r
- /**\r
- * handler for CLASS.\r
- * this handler parses a class statement\r
- */\r
- \r
- function handleClass($word, $pevent)\r
- {\r
- $this->p_flags['in_class'] = true;\r
- $a = $this->checkEventPush( $word, $pevent);\r
- if ($a == PARSER_EVENT_DOCBLOCK || $a == PARSER_EVENT_DOCBLOCK_TEMPLATE)\r
- {\r
- $this->wp->setWhitespace(true);\r
- }\r
-\r
- if (!isset($this->p_vars['class'])) $this->p_vars['class'] = false;\r
- if (!is_subclass_of($this->p_vars['class'],"parserBase"))\r
- {\r
- $this->p_vars['class'] = new parserClass;\r
- $this->p_vars['class']->setLineNumber($this->wp->linenum);\r
- $this->p_vars['class']->setname($word);\r
- $this->p_vars['cur_class'] = $word;\r
- $this->p_vars['class']->setSourceLocation($this->p_vars['source_location']);\r
- }\r
-\r
- if (strtolower($this->p_vars['last_word']) == "extends")\r
- {\r
- $this->p_vars['class']->setExtends($word);\r
- }\r
-\r
- if ($word == "{")\r
- {\r
- $this->publishEvent(PHPDOCUMENTOR_EVENT_CLASS,$this->p_vars['class']);\r
- }\r
- //echo $this->wp->getPos() . ": |$word|\n";\r
- if ($this->checkEventPop($word,$pevent))\r
- {\r
- $this->p_flags['in_class'] = false;\r
- // throw an event when class is done\r
- $this->publishEvent(PHPDOCUMENTOR_EVENT_NEWSTATE,STATE_END_CLASS);\r
- $this->p_vars['class'] = false;\r
- }\r
- }\r
-\r
- /**\r
- * handler for VAR.\r
- * handle a var $varname = default_value; or var $varname; statement in a class definition\r
- */\r
- \r
- function handleVar($word, $pevent)\r
- {\r
- if (!$this->p_flags['in_var'])\r
- {\r
- $this->p_vars['linenum'] = $this->wp->linenum;\r
- }\r
- $this->p_flags['in_var'] = true;\r
- //echo $word."\n";\r
- $e = $this->checkEventPush( $word, $pevent);\r
- \r
- if (!isset($this->p_vars['var'])) $this->p_vars['var'] = false;\r
- if ($word == '=' || $word == ';') $this->p_flags['var_equals'] = true;\r
- if (!$this->p_flags['var_equals'])\r
- {\r
- // if we haven't parsed the = yet, no arrays are possible!\r
- if ($e == PARSER_EVENT_ARRAY)\r
- {\r
- $this->p_flags['arrayinvarname'] = true;\r
- $this->p_vars['event_stack']->popEvent();\r
- }\r
- if (!$e || ($e == PARSER_EVENT_ARRAY))\r
- $this->p_vars['varname'] .= $word;\r
- }\r
-\r
- if (!$this->p_flags['var_equals'])\r
- {\r
- if ($word != "/*" && $word != "//" && $word != "#")\r
- {\r
- $this->p_vars['var'] = new parserVar($this->p_vars['cur_class']);\r
- $this->p_vars['var']->setName($this->p_vars['varname']);\r
- }\r
- }\r
- if ($this->p_vars['last_word'] == "=")\r
- {\r
- if ($word != "/*" && $word != "//" && $word != "#")\r
- {\r
- $this->p_vars['var']->setValue($word);\r
- }\r
- }\r
- // fix 1202772\r
- if (isset($this->p_vars['quote_data']) && ($this->p_vars['last_pevent'] == PARSER_EVENT_QUOTE || $this->p_vars['last_pevent'] == PARSER_EVENT_SINGLEQUOTE))\r
- {\r
- $this->p_vars['var']->setValue($this->p_vars['quote_data']);\r
- unset($this->p_vars['quote_data']);\r
- }\r
- if ($this->p_vars['last_pevent'] == PARSER_EVENT_ARRAY)\r
- {\r
- $this->p_vars['var']->setValue($this->p_vars['function_data']);\r
- $this->p_vars['function_data'] = false;\r
- }\r
- \r
- if ($this->checkEventPop($word,$pevent))\r
- {\r
- $this->p_vars['var']->setLineNumber($this->p_vars['linenum']);\r
- $this->publishEvent(PHPDOCUMENTOR_EVENT_VAR,$this->p_vars['var']);\r
- unset($this->p_vars['var']);\r
- $this->p_flags['in_var'] = false;\r
- $this->p_flags['var_equals'] = false;\r
- $this->p_flags['arrayinvarname'] = false;\r
- $this->p_vars['varname'] = '';\r
- }\r
- }\r
-\r
- /**\r
- * handler for QUOTE.\r
- * this handler recognizes strings defined with double quotation marks (") and handles them correctly\r
- * in any place that they legally appear in php code\r
- */\r
- \r
- function handleQuote($word, $pevent)\r
- {\r
- if ($this->p_flags['reset_quote_data'] === true)\r
- {\r
- $this->p_flags['reset_quote_data'] = false;\r
- $this->p_vars['quote_data'] = "";\r
- }\r
- $this->checkEventPush( $word, $pevent);\r
- if ($word != "\"")\r
- {\r
- $this->p_vars['quote_data'] .= $word;\r
- }\r
- if ($this->checkEventPop($word,$pevent))\r
- {\r
- $this->p_flags['reset_quote_data'] = true;\r
- }\r
- }\r
- \r
- /**\r
- * handler for SINGLEQUOTE.\r
- * this handler recognizes strings defined with single quotation marks (') and handles them correctly\r
- * in any place that they legally appear in php code\r
- */\r
- \r
- function handleSingleQuote($word, $pevent)\r
- {\r
- $this->checkEventPush( $word, $pevent);\r
- if ($this->checkEventPop($word,$pevent))\r
- {\r
- if ($this->p_vars['last_word'] != "'")\r
- {\r
- $this->p_vars['quote_data'] = $this->p_vars['last_word'];\r
- } else {\r
- $this->p_vars['quote_data'] = "";\r
- }\r
- }\r
- }\r
-\r
- /**\r
- * handler for EOFQUOTE.\r
- * this handler recognizes strings defined with perl-style <<< EOF quotes, and handles them correctly\r
- * in any place that they legally appear in php code\r
- *\r
- * an example:\r
- * <code>$var <<< EOF\r
- * blah blah blah\r
- * EOF;</code>\r
- */\r
- \r
- function handleEOFQuote($word, $pevent)\r
- {\r
- // echo $this->wp->getPos() . ": word=|$word|\t\t\tlastword=|$this->p_vars['last_word']|\n";\r
- if (trim($this->p_vars['last_word']) == "<<<")\r
- {\r
- // ok we found the keyword\r
- //echo "Keyword == $word\n";\r
- $this->p_vars['oldtoken'] = $this->tokens[STATE_EOFQUOTE];\r
- $this->tokens[STATE_EOFQUOTE] = array($word);\r
- } \r
- else if ($this->p_vars['last_pevent'] || PARSER_EVENT_EOFQUOTE) \r
- {\r
- // i don't think anything will ever use this so were not going to set it\r
- //$this->p_vars['quote_data'] = $this->p_vars['last_word']; \r
- $this->p_vars['event_stack']->popEvent();\r
- $this->tokens[STATE_EOFQUOTE] = $this->p_vars['oldtoken'];\r
- }\r
- }\r
- /**#@-*/\r
-\r
- /**\r
- * Tells the parser to search for a global variable definition as\r
- * defined by a @global type $name tag.\r
- *\r
- * The parser is fooled into looking for the entire global variable as a\r
- * single token by amending the {@link $tokens} array.\r
- *\r
- * {@source}\r
- * @access private\r
- * @param string name of global variable as it appears in the source code\r
- */\r
- function findGlobal($name)\r
- {\r
- if (!isset($this->p_vars['globaltofind']))\r
- {\r
- $this->p_vars['globaltofind'] = $name;\r
- $this->pushEvent[PARSER_EVENT_PHPCODE][strtolower($name)] = PARSER_EVENT_DEFINE_GLOBAL;\r
- $this->tokens[STATE_PHPCODE][] = $name;\r
- } else\r
- {\r
- addError(PDERROR_MULTIPLE_GLOBAL_TAGS,$this->p_vars['globaltofind'],$name);\r
- }\r
- }\r
- \r
- /**#@+\r
- * @access private\r
- * @param string token parsed from source\r
- * @param integer parser constant from {@link Parser.inc}\r
- */\r
- /**\r
- * handler for PHPCODE.\r
- * this handler recognizes the <code><?</code> php processor directive, and begins parsing php code\r
- */\r
- \r
- function handlePhpCode($word, $pevent)\r
- {\r
- $e = $this->checkEventPush( $word, $pevent);\r
- if ($e == PARSER_EVENT_DOCBLOCK || $e == PARSER_EVENT_DOCBLOCK_TEMPLATE)\r
- {\r
- $this->wp->setWhitespace(true);\r
- }\r
- if (isset($this->p_vars['globaltofind']) && $e)\r
- {\r
- if ($e != PARSER_EVENT_DEFINE_GLOBAL && $e != PARSER_EVENT_ARRAY && $e != PARSER_EVENT_QUOTE && $e != PARSER_EVENT_SINGLEQUOTE && $e != PARSER_EVENT_COMMENT && $e != PARSER_EVENT_COMMENTBLOCK)\r
- {\r
- addError(PDERROR_GLOBAL_NOT_FOUND,$this->p_vars['globaltofind']);\r
- unset($this->pushEvent[PARSER_EVENT_PHPCODE][strtolower($this->p_vars['globaltofind'])]);\r
- foreach($this->tokens[STATE_PHPCODE] as $i => $notme)\r
- if ($this->tokens[STATE_PHPCODE][$i] == $this->p_vars['globaltofind'])\r
- unset($this->tokens[STATE_PHPCODE][$i]);\r
- unset($this->p_vars['globaltofind']);\r
- }\r
- }\r
- }\r
- \r
- /**\r
- * handler for global variables\r
- */\r
- function handleGlobal($word, $pevent)\r
- {\r
- if (!$this->p_flags['in_global'])\r
- {\r
- $this->p_vars['linenum'] = $this->wp->linenum;\r
- }\r
- $this->p_flags['in_global'] = true;\r
- $e = $this->checkEventPush($word, $pevent);\r
- if ($this->checkEventPop($word, $pevent))\r
- {\r
- $this->p_flags['in_global'] = false;\r
- $a = new parserGlobal;\r
- $a->setDataType($this->p_vars['global_type']);\r
- $this->p_vars['global_type'] = '';\r
- $a->setLineNumber($this->p_vars['linenum']);\r
- $a->setName($this->p_vars['globaltofind']);\r
- if (isset($this->p_vars['global_val']))\r
- $a->setValue(trim($this->p_vars['global_val']));\r
- unset($this->p_vars['global_val']);\r
- $this->publishEvent(PHPDOCUMENTOR_EVENT_GLOBAL,$a);\r
- unset($this->pushEvent[PARSER_EVENT_PHPCODE][strtolower($this->p_vars['globaltofind'])]);\r
- foreach($this->tokens[STATE_PHPCODE] as $i => $notme)\r
- if ($this->tokens[STATE_PHPCODE][$i] == $this->p_vars['globaltofind'])\r
- unset($this->tokens[STATE_PHPCODE][$i]);\r
- unset($this->p_vars['globaltofind']);\r
- }\r
- }\r
- \r
- /**\r
- * Handles the stuff after the = in <code>$globalvar = value</code>\r
- */\r
- function handleGlobalValue($word, $pevent)\r
- {\r
- if ($this->checkEventPush($word, $pevent))\r
- {\r
- $this->wp->setWhitespace(false);\r
- return;\r
- }\r
- if (!isset($this->p_vars['global_val'])) $this->p_vars['global_val'] = '';\r
- if ($this->p_vars['last_pevent'] == PARSER_EVENT_QUOTE || $this->p_vars['last_pevent'] == PARSER_EVENT_SINGLEQUOTE)\r
- {\r
- if (!isset($this->p_vars['quote_data'])) $this->p_vars['quote_data'] = '';\r
- $this->p_vars['global_val'] .= '"'.$this->p_vars['quote_data'].'"';\r
- unset($this->p_vars['quote_data']);\r
- $this->p_vars['last_pevent'] = PARSER_EVENT_GLOBAL_VALUE;\r
- }\r
- if ($this->p_vars['last_pevent'] == PARSER_EVENT_ARRAY)\r
- {\r
- $this->p_vars['global_val'] .= $this->p_vars['function_data'];\r
- $this->p_vars['function_data'] = false;\r
- }\r
- if ($word != ';')\r
- $this->p_vars['global_val'] .= $word;\r
- if ($this->checkEventPop($word, $pevent))\r
- {\r
- $this->wp->setWhitespace(false);\r
- $this->wp->backupPos($word);\r
- }\r
- }\r
- \r
- /**\r
- * handler for FUNC_GLOBAL.\r
- * this handler recognizes "global $var1, $var2" declarations in a function, and parses them\r
- */\r
- \r
- function handleFuncGlobal($word, $pevent)\r
- {\r
- if ((substr(trim($word),0,1) != '$') && ($word != ',') && ($word != ';'))\r
- { // not a global declaration, using a variable named "$global"\r
- $this->p_vars['event_stack']->popEvent();\r
- return;\r
- }\r
- if ($this->checkEventPop($word, $pevent))\r
- {\r
- return;\r
- }\r
- if (!$this->checkEventPush($word, $pevent))\r
- {\r
- if ($word == ',')\r
- { // another variable\r
- $this->p_vars['global_count']++;\r
- } else\r
- {\r
- if (!isset($this->p_vars['globals'][$this->p_vars['global_count']]))\r
- $this->p_vars['globals'][$this->p_vars['global_count']] = '';\r
- if (!empty($this->p_vars['globals'][$this->p_vars['global_count']])) $this->p_vars['global_count']++;\r
- $this->p_vars['globals'][$this->p_vars['global_count']] = trim($word);\r
- }\r
- }\r
- }\r
- \r
- /**\r
- * handler for STATIC_VAR.\r
- * this handler recognizes "static $var1, $var2 = 6" declarations in a function, and parses them\r
- */\r
- \r
- function handleStaticVar($word, $pevent)\r
- {\r
- if ($this->checkEventPop($word, $pevent))\r
- {\r
- $this->p_vars['static_count']++;\r
- return;\r
- }\r
- if (!$this->checkEventPush($word, $pevent))\r
- {\r
- if ($word == ',')\r
- {\r
- $this->p_vars['static_count']++;\r
- return;\r
- }\r
- if (!isset($this->p_vars['statics'][$this->p_vars['static_count']]))\r
- $this->p_vars['statics'][$this->p_vars['static_count']] = '';\r
- if (!empty($this->p_vars['statics'][$this->p_vars['static_count']])) $this->p_vars['static_count']++;\r
- $this->p_vars['statics'][$this->p_vars['static_count']] = trim($word);\r
- }\r
- }\r
- \r
- /**\r
- * handler for STATIC_VAR_VALUE.\r
- * this handler parses the 6 in "static $var1, $var2 = 6"\r
- */\r
- \r
- function handleStaticValue($word, $pevent)\r
- {\r
- if ($this->checkEventPush($word, $pevent))\r
- {\r
- return;\r
- }\r
- if (!isset($this->p_vars['static_val'][$this->p_vars['static_count']])) $this->p_vars['static_val'][$this->p_vars['static_count']] = '';\r
- if ($this->p_vars['last_pevent'] == PARSER_EVENT_QUOTE || $this->p_vars['last_pevent'] == PARSER_EVENT_SINGLEQUOTE)\r
- {\r
- $this->p_vars['static_val'][$this->p_vars['static_count']] .= '"'.$this->p_vars['quote_data'].'"';\r
- unset($this->p_vars['quote_data']);\r
- }\r
- if ($this->p_vars['last_pevent'] == PARSER_EVENT_ARRAY)\r
- {\r
- $this->p_vars['static_val'][$this->p_vars['static_count']] .= $this->p_vars['function_data'];\r
- $this->p_vars['function_data'] = false;\r
- }\r
- if ($this->checkEventPop($word, $pevent))\r
- {\r
- $this->p_vars['static_val'][$this->p_vars['static_count']] = trim($this->p_vars['static_val'][$this->p_vars['static_count']]);\r
- $this->wp->backupPos($word);\r
- return;\r
- } else $this->p_vars['static_val'][$this->p_vars['static_count']] .= $word;\r
- }\r
- \r
- /**\r
- * handler for FUNCTION.\r
- * this handler recognizes function declarations, and parses them. The body\r
- * of the function is parsed by handleLogicBlock()\r
- * @see handleLogicBlock()\r
- */\r
- \r
- function handleFunction($word, $pevent)\r
- {\r
- if ($e = $this->checkEventPush( $word, $pevent))\r
- {\r
- if ($e == PARSER_EVENT_COMMENT || $e == PARSER_EVENT_COMMENTBLOCK) return;\r
- }\r
- \r
- if (!isset($this->p_vars['func'])) $this->p_vars['func'] = false;\r
- if (! is_subclass_of($this->p_vars['func'],"parserBase")) \r
- {\r
- $this->p_vars['globals'] = array();\r
- $this->p_vars['global_count'] = 0;\r
- if ($this->p_flags['in_class'])\r
- $this->p_vars['func'] = new parserMethod($this->p_vars['cur_class']); \r
- else\r
- $this->p_vars['func'] = new parserFunction;\r
- $this->p_vars['func']->setLineNumber($this->wp->linenum);\r
- if (trim($word) != '&')\r
- $this->p_vars['func']->setName(trim($word));\r
- else\r
- $this->p_vars['func']->setReturnsReference();\r
- } else\r
- {\r
- if ($this->p_vars['func']->getReturnsReference())\r
- {\r
- if ($this->p_vars['last_word'] == '&')\r
- {\r
- $this->p_vars['func']->setName(trim($word));\r
- }\r
- }\r
- }\r
- if ($this->checkEventPop($word,$pevent)) \r
- { \r
- $this->p_vars['func']->addGlobals($this->p_vars['globals']);\r
- $this->p_vars['func']->addStatics($this->p_vars['statics'],$this->p_vars['static_val']);\r
- $this->p_vars['globals'] = array();\r
- $this->p_vars['global_count'] = 0;\r
- if ($this->p_flags['getting_source'])\r
- {\r
- $x = $this->wp->getSource();\r
- $this->p_vars['func']->addSource($x);\r
- $this->p_flags['get_source'] = false;\r
- $this->p_flags['getting_source'] = false;\r
- }\r
- $this->publishEvent(PHPDOCUMENTOR_EVENT_FUNCTION,$this->p_vars['func']); \r
- $this->p_vars['func'] = false; \r
- } \r
- }\r
-\r
- /**#@-*/\r
- /**\r
- * Helper function for {@link handleFunctionParams()}\r
- *\r
- * This function adds a new parameter to the parameter list\r
- * @access private\r
- * @param string\r
- */\r
- function endFunctionParam($word)\r
- {\r
- if (isset($this->p_vars['quote_data']) && ($this->p_vars['last_pevent'] == PARSER_EVENT_SINGLEQUOTE))\r
- {\r
- $this->p_vars['function_data'] .= "'".$this->p_vars['quote_data']."'";\r
- unset($this->p_vars['quote_data']);\r
- }\r
- if (isset($this->p_vars['quote_data']) && ($this->p_vars['quote_data'] != '') && ($this->p_vars['last_pevent'] == PARSER_EVENT_QUOTE))\r
- {\r
- $this->p_vars['function_data'] .= '"'.$this->p_vars['quote_data'].'"';\r
- unset($this->p_vars['quote_data']);\r
- }\r
- if (isset($this->p_vars['function_param']))\r
- {\r
- $this->p_vars['func']->addParam($this->p_vars['function_param'],$this->p_vars['function_data'], $this->p_flags['funcparam_val']);\r
- unset($this->p_vars['function_param']);\r
- $this->p_vars['function_data'] = '';\r
- $this->p_flags['funcparam_val'] = false;\r
- }\r
- }\r
- /**#@+\r
- * @access private\r
- * @param string token parsed from source\r
- * @param integer parser constant from {@link Parser.inc}\r
- */\r
- /**\r
- * handler for FUNCTION_PARAMS.\r
- * this handler recognizes the parameters of a function within parentheses like function(param, param = default_value)\r
- * and parses them\r
- * @see endFunctionParam()\r
- */\r
- \r
- function handleFunctionParams($word, $pevent)\r
- {\r
- //echo $this->wp->getPos() . ": word=|$word|\t\t\tlastword=|".$this->p_vars['last_word']."|\n";\r
- //echo "function_param = '".$this->p_vars['function_param']."'\n";\r
- //echo "function_data = '".$this->p_vars['function_data']."'\n";\r
- $e1 = $this->checkEventPush( $word, $pevent); \r
-\r
- if (!$e1)\r
- {\r
- if ($word == ',' || $this->checkEventPop($word,$pevent))\r
- {\r
- $this->endFunctionParam($word);\r
- } elseif ($word == '=')\r
- {\r
- $this->p_flags['funcparam_val'] = true;\r
- } else\r
- {\r
- if ($this->p_flags['funcparam_val'])\r
- {\r
- if (isset($this->p_vars['quote_data']) && ($this->p_vars['last_pevent'] == PARSER_EVENT_SINGLEQUOTE))\r
- {\r
- $this->p_vars['function_data'] .= "'".$this->p_vars['quote_data']."'";\r
- unset($this->p_vars['quote_data']);\r
- }\r
- if (isset($this->p_vars['quote_data']) && ($this->p_vars['last_pevent'] == PARSER_EVENT_QUOTE))\r
- {\r
- $this->p_vars['function_data'] .= '"'.$this->p_vars['quote_data'].'"';\r
- unset($this->p_vars['quote_data']);\r
- }\r
- $this->p_vars['function_data'] .= $word;\r
- } else\r
- {\r
- $this->p_vars['function_param'] = $word;\r
- }\r
- }\r
- }\r
- }\r
-\r
- \r
- /**\r
- * javadoc-desc-compliant handler for DOCBLOCK.\r
- * this handler recognizes @tags in DocBlocks and parses them for display.\r
- * It also parses out unknown tags into their own array for use by the docblock\r
- */\r
- \r
- function JavaDochandleDocblock($word, $pevent)\r
- {\r
- $e1 = $this->checkEventPush( $word, $pevent);\r
- if (!isset($this->p_vars[$this->p_vars['docblock_type']]) || !$this->p_vars[$this->p_vars['docblock_type']])\r
- {\r
- $this->p_vars[$this->p_vars['docblock_type']] = new parserDocBlock();\r
- $this->p_vars['returntype'] = false;\r
- $this->p_vars['vartype'] = false;\r
- $this->p_flags['startdocblock'] = true;\r
- $this->p_flags['valid_newline'] = true;\r
- $this->p_flags['startline'] = true;\r
- $this->p_flags['newline'] = true;\r
- $this->p_flags['in_desc'] = true;\r
- $this->p_flags['in_tag'] = false;\r
- $this->p_flags['useperiod'] = false;\r
- $this->p_vars['line'] = array();\r
- $this->p_vars['linecount'] = 0;\r
- }\r
- $e = $this->checkEventPop( $word, $pevent);\r
- if (!$e1 && !$e)\r
- {\r
- if ($this->p_flags['in_desc']) $this->JavaDochandleDesc($word, $pevent);\r
- else $this->handleTags($word, $pevent);\r
- }\r
- if ($e)\r
- {\r
- if (!isset($this->p_vars['periodline'])) $this->p_vars['periodline'] = 0;\r
- if ($this->p_vars['periodline'] > 3)\r
- {\r
- $this->p_flags['useperiod'] = false;\r
- }\r
-\r
- $this->p_vars['docblock_desc'] = new parserDesc;\r
-// echo "i = ".$this->p_vars['periodline']."; i < " . count($this->p_vars['line']) . "\n";\r
- if ($this->p_vars['docblock_type'] == 'docblock')\r
- {\r
- if (isset($this->p_vars['docblock_template']))\r
- {\r
- // copy template values if not overridden\r
- if (!$this->p_vars['docblock']->getExplicitPackage())\r
- {\r
- if ($p = $this->p_vars['docblock_template']->getKeyword('package'))\r
- {\r
- $this->p_vars['docblock']->addKeyword('package',$p);\r
- $this->p_vars['docblock']->setExplicitPackage();\r
- }\r
- if ($p = $this->p_vars['docblock_template']->getKeyword('category'))\r
- {\r
- $this->p_vars['docblock']->addKeyword('category',$p);\r
- $this->p_vars['docblock']->setExplicitCategory();\r
- }\r
- if ($p = $this->p_vars['docblock_template']->getKeyword('subpackage'))\r
- {\r
- $this->p_vars['docblock']->addKeyword('subpackage',$p);\r
- }\r
- }\r
- $tags = $this->p_vars['docblock_template']->listTags();\r
- foreach($tags as $tag)\r
- {\r
- $this->p_vars['docblock']->addKeyword($tag->keyword,$tag->value);\r
- }\r
- $this->p_vars['docblock_desc']->add($this->p_vars['docblock_template']->desc);\r
- if (!count($this->p_vars['docblock']->params)) $this->p_vars['docblock']->params = $this->p_vars['docblock_template']->params;\r
- }\r
- if ($a = strpos(trim($this->p_vars['shortdesc']),'<p>') === 0)\r
- $this->p_vars['shortdesc'] = substr($this->p_vars['shortdesc'],strpos($this->p_vars['shortdesc'],'<p>') + 4);\r
- $this->p_vars[$this->p_vars['docblock_type']]->setShortDesc($this->p_vars['shortdesc']);\r
- }\r
- for($i = 0; $i < count($this->p_vars['line']); $i++)\r
- {\r
- // the line will not be set if it doesn't start with a *\r
- if (isset($this->p_vars['line'][$i]))\r
- $this->p_vars['docblock_desc']->add($this->p_vars['line'][$i]);\r
- }\r
-\r
-\r
- $this->p_vars[$this->p_vars['docblock_type']]->setDesc($this->p_vars['docblock_desc']);\r
- unset($this->p_vars['docblock_desc']);\r
-// var_dump($this->p_vars[$this->p_vars['docblock_type']]);\r
-// exit;\r
- if ($this->p_vars['docblock_type'] == 'docblock')\r
- {\r
- $this->publishEvent(PHPDOCUMENTOR_EVENT_DOCBLOCK,$this->p_vars[$this->p_vars['docblock_type']]);\r
- unset($this->p_vars[$this->p_vars['docblock_type']]);\r
- $this->p_vars[$this->p_vars['docblock_type']] = new parserDocBlock();\r
- }\r
- $this->p_flags['in_desc'] = true;\r
- $this->p_flags['in_tag'] = false;\r
- $this->p_flags['useperiod'] = false;\r
- $this->p_vars['line'] = array();\r
- $this->p_vars['linecount'] = 0;\r
- $this->p_flags['start_docblock'] = true;\r
- $this->p_flags['valid_newline'] = true;\r
- $this->wp->setWhitespace(false);\r
- }\r
- }\r
-\r
- /**\r
- * handler for DOCKEYWORD_DESC.\r
- * this handler parses the short and long description of a dockeyword\r
- */\r
- \r
- function JavaDochandleDesc($word, $pevent)\r
- {\r
- if ($this->p_flags['valid_newline'])\r
- {\r
- if ($word == '@' && $this->p_flags['startline'])\r
- {\r
- return $this->handleTag($word, $pevent);\r
- }\r
- if (!isset($this->p_vars['line'][$this->p_vars['linecount']]))\r
- {\r
- $this->p_vars['line'][$this->p_vars['linecount']] = new parserStringWithInlineTags;\r
- }\r
- if ($this->p_vars['last_word'] == "." && $this->p_flags['useperiod'] == false)\r
- {\r
- $this->p_vars['periodline'] = $this->p_vars['linecount'];\r
- $this->p_vars['shortdesc'] = new parserDesc;\r
- for($i = 0; ($i <= $this->p_vars['periodline']) && ($i < count($this->p_vars['line'])); $i++)\r
- {\r
- if (isset($this->p_vars['line'][$i]))\r
- $this->p_vars['shortdesc']->add($this->p_vars['line'][$i]);\r
- }\r
- $this->p_flags['useperiod'] = true;\r
- }\r
- $this->p_vars['line'][$this->p_vars['linecount']]->add($word);\r
-// debug("DESC $word");\r
- }\r
- $this->handleCR($word);\r
- }\r
- \r
- /**\r
- * handler for DOCBLOCK.\r
- * this handler recognizes @tags in DocBlocks and parses them for display.\r
- * It also parses out unknown tags into their own array for use by the docblock\r
- */\r
- \r
- function BetterhandleDocblock($word, $pevent)\r
- {\r
- $e1 = $this->checkEventPush( $word, $pevent);\r
- if (!$this->wp->returnWhiteSpace)\r
- {\r
- addErrorDie(PDERROR_NEED_WHITESPACE);\r
- }\r
- if (!isset($this->p_vars[$this->p_vars['docblock_type']]) || !$this->p_vars[$this->p_vars['docblock_type']])\r
- {\r
- $this->p_vars[$this->p_vars['docblock_type']] = new parserDocBlock();\r
- $this->p_vars['returntype'] = false;\r
- $this->p_vars['vartype'] = false;\r
- $this->p_flags['startdocblock'] = true;\r
- $this->p_flags['valid_newline'] = true;\r
- $this->p_flags['startline'] = true;\r
- $this->p_flags['newline'] = true;\r
- $this->p_flags['in_desc'] = true;\r
- $this->p_flags['in_tag'] = false;\r
- $this->p_flags['useperiod'] = false;\r
- $this->p_vars['line'] = array();\r
- $this->p_vars['linecount'] = 0;\r
- }\r
- $e = $this->checkEventPop( $word, $pevent);\r
- if (!$e1 && !$e)\r
- {\r
- if ($this->p_flags['in_desc']) $this->handleDesc($word, $pevent);\r
- else $this->handleTags($word, $pevent);\r
- }\r
- if ($e)\r
- {\r
- if (!isset($this->p_vars['periodline'])) $this->p_vars['periodline'] = 0;\r
- if ($this->p_vars['periodline'] > 3)\r
- {\r
- $this->p_flags['useperiod'] = false;\r
- } else\r
- {\r
- for($i = 0; $i < $this->p_vars['periodline']; $i++)\r
- {\r
- if (isset($this->p_vars['line'][$i]))\r
- {\r
- if ($this->p_vars['line'][$i]->trimmedStrlen() == 0 && isset($this->p_vars['line'][$i - 1]) && $this->p_vars['line'][$i - 1]->trimmedStrlen())\r
- {\r
- $this->p_vars['periodline'] = $i;\r
- }\r
- }\r
- }\r
- }\r
- // figure out the shortdesc\r
- if ($this->p_flags['useperiod'] === false)\r
- {\r
- // use the first non blank line for short desc\r
- for($i = 0; $i < count($this->p_vars['line']); $i++)\r
- {\r
- if (!isset($this->p_vars['line'][$i]))\r
- $this->p_vars['line'][$i] = new parserStringWithInlineTags;\r
- if ($this->p_vars['line'][$i]->trimmedStrlen() > 0)\r
- {\r
- $this->p_vars['periodline'] = $i;\r
- $i = count($this->p_vars['line']);\r
- }\r
- }\r
- \r
- // check to see if we are going to use a blank line to end the shortdesc\r
- // this can only be in the first 4 lines\r
- if (count($this->p_vars['line']) > 4)\r
- {\r
- $max = 4;\r
- } else {\r
- $max = count($this->p_vars['line']);\r
- }\r
-\r
- for($i = $this->p_vars['periodline']; $i < $max; $i++)\r
- {\r
- if (isset($this->p_vars['line'][$i]))\r
- if ($this->p_vars['line'][$i]->trimmedStrlen() == 0)\r
- {\r
- $this->p_vars['periodline'] = $i;\r
- $i = $max;\r
- }\r
- }\r
- }\r
-\r
- if ($this->p_vars['docblock_type'] == 'docblock')\r
- {\r
- $this->p_vars['shortdesc'] = new parserDesc;\r
- for($i = 0; ($i <= $this->p_vars['periodline']) && ($i < count($this->p_vars['line'])); $i++)\r
- {\r
- if (isset($this->p_vars['line'][$i]))\r
- $this->p_vars['shortdesc']->add($this->p_vars['line'][$i]);\r
- }\r
- $this->p_vars['periodline']++;\r
- \r
- $this->p_vars['docblock_desc'] = new parserDesc;\r
- if (isset($this->p_vars['docblock_template']))\r
- {\r
- // copy template values if not overridden\r
- if (!$this->p_vars['docblock']->getExplicitPackage())\r
- {\r
- if ($p = $this->p_vars['docblock_template']->getKeyword('package'))\r
- {\r
- $this->p_vars['docblock']->addKeyword('package',$p);\r
- $this->p_vars['docblock']->setExplicitPackage();\r
- }\r
- if ($p = $this->p_vars['docblock_template']->getKeyword('category'))\r
- {\r
- $this->p_vars['docblock']->addKeyword('category',$p);\r
- $this->p_vars['docblock']->setExplicitCategory();\r
- }\r
- if ($p = $this->p_vars['docblock_template']->getKeyword('subpackage'))\r
- {\r
- $this->p_vars['docblock']->addKeyword('subpackage',$p);\r
- }\r
- }\r
- $tags = $this->p_vars['docblock_template']->listTags();\r
- foreach($tags as $tag)\r
- {\r
- $this->p_vars['docblock']->addKeyword($tag->keyword,$tag->value);\r
- }\r
- if (!count($this->p_vars['docblock']->params)) $this->p_vars['docblock']->params = $this->p_vars['docblock_template']->params;\r
- $this->p_vars['docblock_desc']->add($this->p_vars['docblock_template']->desc);\r
- }\r
- // echo "i = ".$this->p_vars['periodline']."; i < " . count($this->p_vars['line']) . "\n";\r
- for($i = $this->p_vars['periodline']; $i < count($this->p_vars['line']); $i++)\r
- {\r
- // the line will not be set if it doesn't start with a *\r
- if (isset($this->p_vars['line'][$i]))\r
- $this->p_vars['docblock_desc']->add($this->p_vars['line'][$i]);\r
- }\r
- } else\r
- {\r
- $this->p_vars['shortdesc'] = new parserDesc;\r
- for($i = 0; ($i <= $this->p_vars['periodline']) && ($i < count($this->p_vars['line'])); $i++)\r
- {\r
- if (isset($this->p_vars['line'][$i]))\r
- $this->p_vars['shortdesc']->add($this->p_vars['line'][$i]);\r
- }\r
- $this->p_vars['periodline']++;\r
- \r
- $this->p_vars['docblock_desc'] = new parserDesc;\r
- for($i=$this->p_vars['periodline']; $i < count($this->p_vars['line']); $i++)\r
- {\r
- if (isset($this->p_vars['line'][$i]))\r
- $this->p_vars['docblock_desc']->add($this->p_vars['line'][$i]);\r
- }\r
- }\r
-\r
-\r
- $this->p_vars[$this->p_vars['docblock_type']]->setShortDesc($this->p_vars['shortdesc']);\r
- $this->p_vars[$this->p_vars['docblock_type']]->setDesc($this->p_vars['docblock_desc']);\r
- unset($this->p_vars['docblock_desc']);\r
-// var_dump($this->p_vars[$this->p_vars['docblock_type']]);\r
-// exit;\r
- if ($this->p_vars['docblock_type'] == 'docblock')\r
- {\r
- $this->publishEvent(PHPDOCUMENTOR_EVENT_DOCBLOCK,$this->p_vars[$this->p_vars['docblock_type']]);\r
- unset($this->p_vars[$this->p_vars['docblock_type']]);\r
- $this->p_vars[$this->p_vars['docblock_type']] = new parserDocBlock();\r
- } else\r
- {\r
- $this->publishEvent(PHPDOCUMENTOR_EVENT_DOCBLOCK_TEMPLATE,$this->p_vars[$this->p_vars['docblock_type']]);\r
- }\r
- $this->p_flags['in_desc'] = true;\r
- $this->p_flags['in_tag'] = false;\r
- $this->p_flags['useperiod'] = false;\r
- $this->p_vars['line'] = array();\r
- $this->p_vars['linecount'] = 0;\r
- $this->p_flags['start_docblock'] = true;\r
- $this->p_flags['valid_newline'] = true;\r
- $this->wp->setWhitespace(false);\r
- $this->p_vars['docblock_type'] = 'docblock';\r
- }\r
- }\r
- \r
- /**\r
- * Handles docblock templates\r
- * @tutorial phpDocumentor.howto.pkg#basics.docblocktemplate\r
- */\r
- function handleDocBlockTemplate($word, $pevent)\r
- {\r
- $this->p_vars['docblock_type'] = 'docblock_template';\r
- $this->p_vars['event_stack']->popEvent();\r
- $this->p_vars['event_stack']->pushEvent(PARSER_EVENT_DOCBLOCK);\r
- // fool the docblock handler into thinking everything is totally normal\r
- $this->p_vars['last_word'] = '/**';\r
- $pevent = PARSER_EVENT_DOCBLOCK;\r
- $this->BetterhandleDocBlock($word, $pevent);\r
- }\r
- \r
- /**\r
- * Handles closing docblock templates /**#@-* /\r
- * @tutorial phpDocumentor.howto.pkg#basics.docblocktemplate\r
- */\r
- function handleEndDocBlockTemplate($word, $pevent)\r
- {\r
- unset($this->p_vars['docblock_template']);\r
- $this->publishEvent(PHPDOCUMENTOR_EVENT_NEWSTATE,PHPDOCUMENTOR_EVENT_END_DOCBLOCK_TEMPLATE);\r
- $this->p_vars['event_stack']->popEvent();\r
- }\r
- /**#@-*/\r
- /**\r
- * Handles a new line in a DocBlock\r
- * @param string token containing a newline \n\r
- * @access private\r
- */\r
- function handleCR($word)\r
- {\r
- $this->laststart = $this->p_flags['startline'];\r
- if ($word == "\n" || $word == ".\n")\r
- {\r
- $this->p_flags['start_docblock'] = false;\r
- $this->p_flags['newline'] = true;\r
- $this->p_flags['valid_newline'] = false;\r
- if ($this->p_flags['in_desc'] && !$this->p_flags['useperiod'])\r
- {\r
- if ($word == ".\n")\r
- {\r
- $this->p_flags['useperiod'] = true;\r
- $this->p_vars['periodline'] = $this->p_vars['linecount'];\r
- }\r
- }\r
- } else\r
- {\r
- if ($this->p_flags['valid_newline'] && strlen(trim($word)))\r
- {\r
- $this->p_flags['startline'] = false;\r
- }\r
- if ($this->p_flags['newline'] && ($word == '*' || $this->p_flags['start_docblock']))\r
- {\r
- $this->p_flags['newline'] = false;\r
- $this->p_flags['valid_newline'] = true;\r
- if (!$this->p_flags['start_docblock'])\r
- $this->p_vars['linecount']++;\r
- $this->p_flags['startline'] = true;\r
- $justset = true;\r
-// debug('valid newline');\r
- }\r
- }\r
- }\r
- \r
- /**\r
- * handler for DOCKEYWORD_DESC.\r
- * this handler parses the short and long description of a dockeyword\r
- * @access private\r
- */\r
- \r
- function handleDesc($word, $pevent)\r
- {\r
-// echo "|$word|\n";\r
- if ($this->p_flags['valid_newline'])\r
- {\r
- if ($word == '@' && $this->p_flags['startline'])\r
- {\r
- return $this->handleTag($word, $pevent);\r
- }\r
- if ($this->p_vars['last_word'] == ". " || $this->p_vars['last_word'] == ".\t")\r
- {\r
- $this->p_flags['useperiod'] = true;\r
- $this->p_vars['periodline'] = $this->p_vars['linecount'];\r
- $this->p_vars['linecount']++;\r
- }\r
- if (!isset($this->p_vars['line'][$this->p_vars['linecount']]))\r
- {\r
- $this->p_vars['line'][$this->p_vars['linecount']] = new parserStringWithInlineTags;\r
- }\r
- if ($this->p_flags['startline'])\r
- {\r
- if ($word[0] == ' ') $word = substr($word,1);\r
-// $word = ltrim($word," \t");\r
- }\r
- if ($word != '') $this->p_vars['line'][$this->p_vars['linecount']]->add($word);\r
-// debug("DESC $word");\r
- }\r
- $this->handleCR($word);\r
- }\r
- \r
- /**#@+\r
- * @access private\r
- * @param string token parsed from source\r
- * @param integer parser constant from {@link Parser.inc}\r
- */\r
- /**\r
- * handler for DOCKEYWORD_TAGS.\r
- * this handler recognizes @tags in DocBlocks and parses them for display\r
- * I think this may be unused. We'll delete from 1.1 if so\r
- */\r
- function handleTags($word, $pevent)\r
- {\r
- if ($this->p_flags['valid_newline'])\r
- {\r
-// debug("TAGS $word");\r
- }\r
- $this->handleCR($word);\r
- }\r
- \r
- /**\r
- * handler for DOCKEYWORD.\r
- * this handler recognizes @tags in DocBlocks and parses them for display\r
- */\r
- function handleTag($word, $pevent)\r
- {\r
- if ($this->p_flags['in_desc'] && !$this->p_flags['valid_newline'])\r
- {\r
- $this->p_vars['event_stack']->popEvent();\r
- return $this->handleDesc($word, $pevent);\r
- }\r
-// if ($this->p_vars['last_word'] == '@') fancy_debug('here'.$word,$this->p_flags['startline'],$this->p_flags['in_tag']);\r
- if ($this->p_vars['tagname'] == 'author')\r
- {\r
- if ($word == '<')\r
- {\r
- $this->p_vars['event_stack']->pushEvent(PARSER_EVENT_DOCKEYWORD_EMAIL);\r
- return $this->handleDockeywordEmail($word, $pevent);\r
- }\r
- }\r
- if ($this->checkEventPush( $word, $pevent)) return;\r
- if ($this->p_vars['last_word'] == '@' && !$this->p_flags['startline'] && $this->p_flags['in_desc'])\r
- {\r
- // fix 1203445\r
- if (!isset($this->p_vars['line'][$this->p_vars['linecount']]))\r
- {\r
- $this->p_vars['line'][$this->p_vars['linecount']] = new parserStringWithInlineTags;\r
- }\r
- $this->p_vars['event_stack']->popEvent();\r
- $this->p_vars['line'][$this->p_vars['linecount']]->add('@');\r
- return $this->handleDesc($word, $pevent);\r
- } elseif($this->p_vars['last_word'] == '@' && !strlen(trim($word)) && empty($this->p_vars['tagname']) && $this->p_flags['in_desc'])\r
- {\r
- // fix 1203445\r
- if (!isset($this->p_vars['line'][$this->p_vars['linecount']]))\r
- {\r
- $this->p_vars['line'][$this->p_vars['linecount']] = new parserStringWithInlineTags;\r
- }\r
- $pevent = $this->p_vars['event_stack']->popEvent();\r
- $this->p_vars['line'][$this->p_vars['linecount']]->add('@');\r
- return $this->handleDesc($word, $pevent);\r
- }\r
- if ($word == '@' && $this->p_flags['startline'] && $this->p_flags['in_tag'])\r
- {\r
- $this->wp->backupPos($word);\r
- $white = $this->wp->returnWhiteSpace;\r
- $this->wp->setWhitespace(true);\r
- $word1 = $this->wp->getWord();\r
- $this->wp->backupPos($word1);\r
- if (strlen(trim($word1)))\r
- {\r
- $this->endTag();\r
- }\r
- $this->wp->getWord();\r
- $this->wp->setWhitespace($white);\r
- }\r
- $this->p_flags['in_tag'] = true;\r
- $e = $this->checkEventPop($word, $pevent);\r
- if (!$e)\r
- {\r
- if ($this->p_flags['valid_newline'])\r
- {\r
- if (($this->p_flags['startline'] || $this->laststart) && $word != '@')\r
- {\r
- if ($this->p_vars['last_word'] == '@')\r
- {\r
-// debug("TAGSTART $word");\r
- $this->p_flags['in_tag'] = true;\r
- $this->p_vars['tagname'] = $word;\r
- $this->p_flags['startline'] = false;\r
- $this->p_vars['tag_value'] = new parserStringWithInlineTags;\r
- } else\r
- {\r
-// debug("TAG1 $word");\r
- if (isset($this->tagHandlers[$this->p_vars['tagname']]))\r
- $handler = $this->tagHandlers[$this->p_vars['tagname']];\r
- else $handler = $this->tagHandlers['*'];\r
- $this->$handler($word);\r
- }\r
- } else\r
- {\r
- if (empty($this->p_vars['tagname']))\r
- {\r
- if ($this->p_flags['in_desc'])\r
- {\r
- $this->p_flags['in_tag'] = false;\r
- // fix 1203445\r
- if (!isset($this->p_vars['line'][$this->p_vars['linecount']]))\r
- {\r
- $this->p_vars['line'][$this->p_vars['linecount']] =\r
- new parserStringWithInlineTags;\r
- }\r
- $this->p_vars['line'][$this->p_vars['linecount']]->add('@');\r
- $this->p_vars['event_stack']->popEvent();\r
- $this->handleCR($word);\r
- return $this->handleDesc($word, $pevent);\r
- }\r
- }\r
-// debug("TAG2 $word");\r
- if (isset($this->tagHandlers[$this->p_vars['tagname']]))\r
- $handler = $this->tagHandlers[$this->p_vars['tagname']];\r
- else $handler = $this->tagHandlers['*'];\r
- $this->$handler($word);\r
- }\r
- }\r
- $this->handleCR($word);\r
- }\r
- $this->p_flags['in_desc'] = false;\r
- if ($e)\r
- {\r
- $this->endTag();\r
- $this->wp->setWhitespace(false);\r
- // walk back a word\r
- $this->wp->backupPos($word);\r
- $this->wp->setWhitespace(true);\r
- }\r
- }\r
- /**#@-*/\r
- /**\r
- * Called to clean up at the end of parsing a @tag in a docblock\r
- */\r
- function endTag()\r
- {\r
- if (isset($this->tagHandlers[$this->p_vars['tagname']]))\r
- $handler = $this->tagHandlers[$this->p_vars['tagname']];\r
- else $handler = $this->tagHandlers['*'];\r
- $this->$handler(false);\r
- $this->p_vars['tagname'] = '';\r
- $this->p_flags['startline'] = true;\r
-// debug("ENDTAG");\r
- }\r
- \r
- /**#@+\r
- * Tag Handlers\r
- * @param string\r
- */\r
- /**\r
- * Handles all standard tags that only have a description\r
- */\r
- function defaultTagHandler($word)\r
- {\r
- if ($word !== false)\r
- {\r
- $this->p_vars['tag_value']->add($word);\r
- } else\r
- {\r
- $this->p_vars[$this->p_vars['docblock_type']]->addKeyword($this->p_vars['tagname'],$this->p_vars['tag_value']);\r
- }\r
- }\r
- \r
- /**\r
- * Handles tags like '@filesource' that only work in PHP 4.3.0+\r
- */\r
- function invalidTagHandler($word)\r
- {\r
- if ($word === false)\r
- {\r
- addError(PDERROR_TAG_NOT_HANDLED,$this->p_vars['tagname']);\r
- }\r
- }\r
- \r
- /**\r
- * handles @package\r
- * @tutorial tags.package.pkg\r
- */\r
- function packageTagHandler($word)\r
- {\r
- if ($word !== false)\r
- {\r
- $this->p_vars['tag_value']->add($word);\r
- } else\r
- {\r
- $this->p_vars[$this->p_vars['docblock_type']]->addKeyword($this->p_vars['tagname'],$this->p_vars['tag_value']);\r
- $this->p_vars[$this->p_vars['docblock_type']]->setExplicitPackage();\r
- }\r
- }\r
- \r
- /**\r
- * handles @example\r
- * @tutorial tags.example.pkg\r
- */\r
- function exampleTagHandler($word)\r
- {\r
- if ($word !== false)\r
- {\r
- $this->p_vars['tag_value']->add($word);\r
- } else\r
- {\r
- $this->p_vars[$this->p_vars['docblock_type']]->addExample($this->p_vars['tag_value'], $this->p_vars['parsepath']);\r
- }\r
- }\r
- \r
- /**\r
- * handles @category\r
- * @tutorial tags.category.pkg\r
- */\r
- function categoryTagHandler($word)\r
- {\r
- if ($word !== false)\r
- {\r
- $this->p_vars['tag_value']->add($word);\r
- } else\r
- {\r
- $this->p_vars[$this->p_vars['docblock_type']]->addKeyword($this->p_vars['tagname'],$this->p_vars['tag_value']);\r
- $this->p_vars[$this->p_vars['docblock_type']]->setExplicitCategory();\r
- }\r
- }\r
- \r
- /**\r
- * handles @global\r
- * @tutorial tags.global.pkg\r
- */\r
- function globalTagHandler($word)\r
- {\r
- if ($word !== false)\r
- {\r
- // no data yet\r
- $a = trim($this->p_vars['tag_value']->getString());\r
- if (empty($a))\r
- {\r
- // not an empty word\r
- if (trim($word) != '')\r
- {\r
- if (!empty($this->p_vars['global_type']))\r
- {\r
- if (!$this->p_flags['define_global'] && !$this->p_flags['function_global'])\r
- {\r
- // @global type $GLOBALVARNAME ?\r
- if (substr($word,0,1) == '$')\r
- {\r
- $this->p_flags['define_global'] = true;\r
- $this->p_flags['function_global'] = false;\r
- $this->p_vars['find_global'] = $word;\r
- } else\r
- { // function @global type description\r
- $this->p_flags['function_global'] = true;\r
- $this->p_flags['define_global'] = false;\r
- $this->p_vars['tag_value']->add($word);\r
- }\r
- } else\r
- {\r
- if ($this->p_flags['define_global'])\r
- {\r
- $this->p_vars['find_global'] .= $word;\r
- } elseif($this->p_flags['function_global'])\r
- {\r
- // description, to be added to the tag\r
- $this->p_vars['tag_value']->add($word);\r
- }\r
- }\r
- } else\r
- {\r
- $this->p_vars['global_type'] = $word;\r
- } \r
- } else $this->p_vars['tag_value']->add($word); // add whitespace to the tag description\r
- } else\r
- { // tag_value has data, must be a function @global\r
- $this->p_vars['tag_value']->add($word);\r
- }\r
- } else\r
- { // endtag\r
- if ($this->p_flags['define_global'])\r
- {\r
- $this->findGlobal($this->p_vars['find_global']);\r
- }\r
- elseif ($this->p_flags['function_global'])\r
- {\r
- $this->p_vars[$this->p_vars['docblock_type']]->addFuncGlobal($this->p_vars['global_type'],$this->p_vars['tag_value']);\r
- $this->p_vars['global_type'] = '';\r
- }\r
- else\r
- {\r
- addError(PDERROR_MALFORMED_GLOBAL_TAG);\r
- }\r
- $this->p_vars['find_global'] = '';\r
- $this->p_flags['define_global'] = false;\r
- $this->p_flags['function_global'] = false;\r
- }\r
- }\r
- \r
- /**\r
- * handles @staticvar\r
- * @tutorial tags.staticvar.pkg\r
- */\r
- function staticvarTagHandler($word)\r
- {\r
- if ($word !== false)\r
- {\r
- if (!$this->p_vars['returntype']) $this->p_vars['returntype'] = trim($word);\r
- else\r
- {\r
- if (!$this->p_vars['paramname'])\r
- {\r
- if (substr(trim($word),0,1) == "$")\r
- $this->p_vars['paramname'] = trim($word);\r
- else $this->p_vars['tag_value']->add($word);\r
- } else\r
- {\r
- if (0)//strtolower($this->p_vars['paramtype']) == 'object')\r
- {\r
- if (strlen(trim($word)))\r
- $this->p_vars['paramname'] = trim($word);\r
- } else $this->p_vars['tag_value']->add($word);\r
- }\r
- }\r
- } else\r
- {\r
- if (!$this->p_vars['paramname'])\r
- $this->p_vars[$this->p_vars['docblock_type']]->addStaticVar(null,$this->p_vars['returntype'],$this->p_vars['tag_value']);\r
- else\r
- $this->p_vars[$this->p_vars['docblock_type']]->addStaticVar($this->p_vars['paramname'],$this->p_vars['returntype'],$this->p_vars['tag_value']);\r
- $this->p_vars['paramname'] = false;\r
- $this->p_vars['returntype'] = false;\r
- }\r
- }\r
- \r
- /**\r
- * handles @uses\r
- * @tutorial tags.uses.pkg\r
- */\r
- function usesTagHandler($word)\r
- {\r
- if ($word !== false)\r
- {\r
- if (!$this->p_vars['seelement']) $this->p_vars['seelement'] = trim($word);\r
- else\r
- {\r
- $this->p_vars['tag_value']->add($word);\r
- }\r
- } else\r
- {\r
- $see = new parserStringWithInlineTags;\r
- $see->add($this->p_vars['seelement']);\r
- $this->p_vars[$this->p_vars['docblock_type']]->addUses($see,$this->p_vars['tag_value']);\r
- $this->p_vars['seelement'] = false;\r
- }\r
- }\r
- \r
- /**\r
- * handles @param\r
- * @tutorial tags.param.pkg\r
- */\r
- function paramTagHandler($word)\r
- {\r
- if ($word !== false)\r
- {\r
- if (!$this->p_vars['returntype']) $this->p_vars['returntype'] = trim($word);\r
- else\r
- {\r
- if (!$this->p_vars['paramname'])\r
- {\r
- if (substr(trim($word),0,1) == "$" || substr(trim($word),0,2) == "&$")\r
- $this->p_vars['paramname'] = trim($word);\r
- else $this->p_vars['tag_value']->add($word);\r
- } else\r
- {\r
- if (0)//strtolower($this->p_vars['paramtype']) == 'object')\r
- {\r
- if (strlen(trim($word)))\r
- $this->p_vars['paramname'] = trim($word);\r
- } else $this->p_vars['tag_value']->add($word);\r
- }\r
- }\r
- } else\r
- {\r
- if (!$this->p_vars['paramname'])\r
- $this->p_vars[$this->p_vars['docblock_type']]->addParam(null,$this->p_vars['returntype'],$this->p_vars['tag_value']);\r
- else\r
- $this->p_vars[$this->p_vars['docblock_type']]->addParam($this->p_vars['paramname'],$this->p_vars['returntype'],$this->p_vars['tag_value']);\r
- $this->p_vars['paramname'] = false;\r
- $this->p_vars['returntype'] = false;\r
- }\r
- }\r
- \r
- /**\r
- * handles @return\r
- * @tutorial tags.return.pkg\r
- */\r
- function returnTagHandler($word)\r
- {\r
- if ($word !== false)\r
- {\r
- if (!$this->p_vars['returntype']) $this->p_vars['returntype'] = trim($word);\r
- else\r
- {\r
- if (strtolower($this->p_vars['returntype']) == 'object')\r
- {\r
- if (strlen(trim($word)))\r
- $this->p_vars['returntype'] = trim($word);\r
- } else $this->p_vars['tag_value']->add($word);\r
- }\r
- } else\r
- {\r
- $this->p_vars[$this->p_vars['docblock_type']]->addReturn($this->p_vars['returntype'],$this->p_vars['tag_value']);\r
- $this->p_vars['returntype'] = false;\r
- }\r
- }\r
- \r
- /**\r
- * handles @var\r
- * @tutorial tags.var.pkg\r
- */\r
- function varTagHandler($word)\r
- {\r
- if ($word)\r
- {\r
- if (!$this->p_vars['vartype']) $this->p_vars['vartype'] = trim($word);\r
- else\r
- {\r
- if (strtolower($this->p_vars['vartype']) == 'object')\r
- {\r
- if (strlen(trim($word)))\r
- $this->p_vars['vartype'] = trim($word);\r
- }\r
- else $this->p_vars['tag_value']->add($word);\r
- }\r
- } elseif ($word === false)\r
- {\r
- $this->p_vars[$this->p_vars['docblock_type']]->addVar($this->p_vars['vartype'],$this->p_vars['tag_value']);\r
- $this->p_vars['vartype'] = false;\r
- }\r
- }\r
- \r
- /**\r
- * Handles @property(-read or -write) and @method magic tag\r
- */\r
- function propertyTagHandler( $word )\r
- {\r
- if ( $word !== false )\r
- {\r
- if ( !$this->p_vars['returntype'] )\r
- $this->p_vars['returntype'] = trim( $word );\r
- else\r
- {\r
- if ( !$this->p_vars['property_name'] )\r
- {\r
- if ( substr( trim( $word ), 0, 1 ) == "$"\r
- || substr(trim($word), 0, 2) == "&$"\r
- || substr(trim($word), -2, 2) == "()"\r
- )\r
- $this->p_vars['property_name'] = trim( $word );\r
- else\r
- $this->p_vars['tag_value']->add( $word );\r
- }\r
- else\r
- {\r
- $this->p_vars['tag_value']->add( $word );\r
- }\r
- }\r
- }\r
- else\r
- {\r
- $this->p_vars[$this->p_vars['docblock_type']]->addProperty( $this->p_vars['tagname'],\r
- $this->p_vars['property_name'],\r
- $this->p_vars['returntype'],\r
- $this->p_vars['tag_value'] );\r
- $this->p_vars['property_name'] = false;\r
- $this->p_vars['returntype'] = false;\r
- }\r
- }\r
- \r
- /**#@-*/\r
- /** @access private */\r
- function getSource()\r
- {\r
- $this->p_flags['get_source'] = true;\r
- }\r
- /**#@+\r
- * @access private\r
- * @param string token parsed from source\r
- * @param integer parser constant from {@link Parser.inc}\r
- */\r
- /**\r
- * handler for DOCKEYWORD_EMAIL.\r
- * this handler recognizes angle brackets < and > surrounding an email address in an @author tag,\r
- * and returns a mailto: hyperlink\r
- */\r
- \r
- function handleDockeywordEmail($word, $pevent)\r
- {\r
- //echo $this->wp->getPos() . ": |$word|\n";\r
- if (!$this->checkEventPop($word,$pevent) && $word != "<")\r
- {\r
- if (strstr($word,"@"))\r
- {\r
- $this->p_vars['tag_value']->add('<');\r
- $this->p_vars['tag_value']->add(new parserLinkInlineTag("mailto:$word",$word));\r
- $this->p_vars['tag_value']->add('>');\r
- } else {\r
- $this->p_vars['tag_value']->add("<$word>");\r
- }\r
- }\r
- }\r
-\r
- /**\r
- * handler for INLINE_DOCKEYWORD.\r
- * this handler recognizes {@inline tags} like link, and parses them, replacing them directly\r
- * in the text flow with their output.\r
- */\r
- \r
- function handleInlineDockeyword($word, $pevent)\r
- {\r
- // echo $this->wp->getPos() . ": |$word|\n";\r
-\r
- // echo "docktype: $this->p_vars['inline_dockeyword_type']\n";\r
- if (!isset($this->p_vars['inline_dockeyword_type'])) $this->p_vars['inline_dockeyword_type'] = false;\r
- if (!isset($this->p_vars['inline_dockeyword_data'])) $this->p_vars['inline_dockeyword_data'] = '';\r
- if (!$this->p_vars['inline_dockeyword_type'])\r
- {\r
- if (in_array($word,$this->allowableInlineTags))\r
- {\r
- if ($word == '}')\r
- $this->p_vars['inline_dockeyword_type'] = '';\r
- else\r
- $this->p_vars['inline_dockeyword_type'] = strtolower($word);\r
- $this->p_vars['whitesp'] = $this->wp->returnWhiteSpace;\r
- $this->wp->setWhiteSpace(true);\r
- } else {\r
- if ($this->p_flags['in_desc'])\r
- {\r
- // fix 1203445\r
- if (!isset($this->p_vars['line'][$this->p_vars['linecount']]))\r
- {\r
- $this->p_vars['line'][$this->p_vars['linecount']] =\r
- new parserStringWithInlineTags;\r
- }\r
- if ($word == '}')\r
- {\r
- $this->p_vars['line'][$this->p_vars['linecount']]->add('{@');\r
- } else\r
- {\r
- $this->p_vars['line'][$this->p_vars['linecount']]->add('{@'.$word);\r
- }\r
- } elseif($this->p_flags['in_tag'])\r
- {\r
- if ($word == '}')\r
- $this->p_vars['tag_value']->add('{@'.$word);\r
- else\r
- $this->p_vars['tag_value']->add('{@'.$word);\r
- }\r
- $this->p_vars['event_stack']->popEvent();\r
- $this->p_vars['inline_dockeyword_type'] = false;\r
- $this->p_vars['inline_dockeyword_data'] = '';\r
- return;\r
- }\r
- } else\r
- {\r
- if ($word != "}")\r
- {\r
- $this->p_vars['inline_dockeyword_data'] .= $word;\r
- }\r
- }\r
- if ($this->checkEventPop($word,$pevent))\r
- {\r
- $this->wp->setWhiteSpace($this->p_vars['whitesp']);\r
- if ($this->p_vars['inline_dockeyword_type']=='link')\r
- {\r
- // support hyperlinks of any protocol\r
- if (is_numeric(strpos($this->p_vars['inline_dockeyword_data'],'://')) || (strpos(trim($this->p_vars['inline_dockeyword_data']),'mailto:') === 0))\r
- {\r
- // if there is more than 1 parameter, the stuff after the space is the hyperlink text\r
- if (strpos(trim($this->p_vars['inline_dockeyword_data']),' '))\r
- {\r
- $i1 = strpos(trim($this->p_vars['inline_dockeyword_data']),' ') + 1;\r
- $link = substr(trim($this->p_vars['inline_dockeyword_data']),0,$i1 - 1);\r
- $text = substr(trim($this->p_vars['inline_dockeyword_data']),$i1);\r
- $this->p_vars['inline_dockeyword_data'] = new parserLinkInlineTag($link,$text);\r
-// '<a href="'.$link.'">'.$text.'</a>';\r
- }\r
- else\r
- {\r
- $this->p_vars['inline_dockeyword_data'] = new parserLinkInlineTag($this->p_vars['inline_dockeyword_data'],$this->p_vars['inline_dockeyword_data']);\r
- }\r
-// '<a href="'.$this->p_vars['inline_dockeyword_data'].'">'.$this->p_vars['inline_dockeyword_data'].'</a>';\r
- } else\r
- {\r
- if (!strpos($this->p_vars['inline_dockeyword_data'],','))\r
- {\r
- $testp = explode('#',$this->p_vars['inline_dockeyword_data']);\r
- if (count($testp) - 1)\r
- $this->p_vars['inline_dockeyword_data'] = new parserLinkInlineTag($this->p_vars['inline_dockeyword_data'],$testp[1]);\r
- else\r
- $this->p_vars['inline_dockeyword_data'] = new parserLinkInlineTag($this->p_vars['inline_dockeyword_data'],$this->p_vars['inline_dockeyword_data']);\r
- } else\r
- $this->p_vars['inline_dockeyword_data'] = new parserLinkInlineTag($this->p_vars['inline_dockeyword_data'],$this->p_vars['inline_dockeyword_data']);\r
- }\r
- }\r
- if ($this->p_vars['inline_dockeyword_type'] == 'tutorial')\r
- {\r
- $this->p_vars['inline_dockeyword_data'] = new parserTutorialInlineTag($this->p_vars['inline_dockeyword_data'],$this->p_vars['inline_dockeyword_data']);\r
- }\r
- if ($this->p_vars['inline_dockeyword_type'] == 'source')\r
- {\r
- $this->getSource();\r
- $this->p_vars['inline_dockeyword_data'] = new parserSourceInlineTag($this->p_vars['inline_dockeyword_data']);\r
- }\r
- if ($this->p_vars['inline_dockeyword_type'] == 'inheritdoc')\r
- {\r
- $this->p_vars['inline_dockeyword_data'] = new parserInheritdocInlineTag();\r
- }\r
- if ($word == '*/')\r
- {\r
- if (!isset($this->p_vars['inline_dockeyword_type'])) $this->p_vars['inline_dockeyword_type'] = '';\r
- if (!isset($this->p_vars['tagname'])) $this->p_vars['tagname'] = '';\r
- if (!isset($this->p_vars['tag_value']) || !is_object($this->p_vars['tag_value'])) $this->p_vars['tag_value'] = new parserStringWithInlineTags;\r
- addError(PDERROR_UNTERMINATED_INLINE_TAG,$this->p_vars['inline_dockeyword_type'],$this->p_vars['tagname'],'@'.$this->p_vars['tagname'].' '.$this->p_vars['tag_value']->getString());\r
- // when we add the error class, raise error here: we reached the end of the docblock\r
- $this->wp->backupPos($word); \r
- }\r
- if ($this->p_flags['in_desc'])\r
- {\r
- $this->p_vars['line'][$this->p_vars['linecount']]->add($this->p_vars['inline_dockeyword_data']);\r
- $this->p_vars['inline_dockeyword_type'] = false;\r
- $this->p_vars['inline_dockeyword_data'] = '';\r
- }\r
- elseif ($this->p_flags['in_tag'])\r
- {\r
- $this->p_vars['tag_value']->add($this->p_vars['inline_dockeyword_data']);\r
- $this->p_vars['inline_dockeyword_type'] = false;\r
- $this->p_vars['inline_dockeyword_data'] = '';\r
- }\r
- }\r
- }\r
-\r
- /**\r
- * handler for INCLUDE.\r
- * this handler recognizes include/require/include_once/include_once statements, and publishes the\r
- * data to Render\r
- */\r
- \r
- function handleInclude($word, $pevent)\r
- {\r
- if (!$this->p_flags['in_include'])\r
- {\r
- $this->p_vars['linenum'] = $this->wp->linenum;\r
- }\r
- $this->p_flags['in_include'] = true;\r
- $a = $this->checkEventPush( $word, $pevent);\r
- if (!$this->p_flags['includename_isset'])\r
- {\r
- $this->p_flags['includename_isset'] = true;\r
- $this->p_vars['include_name'] = $this->p_vars['last_word'];\r
- if ($a)\r
- $this->p_vars['include_value'] = '';\r
- else\r
- $this->p_vars['include_value'] = $word;\r
- unset($this->p_vars['quote_data']);\r
- } else\r
- {\r
- if (!$a)\r
- {\r
- if (empty($this->p_vars['include_params_data']))\r
- {\r
- if (isset($this->p_vars['quote_data']))\r
- {\r
- $this->p_vars['include_value'] .= '"'.$this->p_vars['quote_data'].'"';\r
- unset($this->p_vars['quote_data']);\r
- }\r
- if ($word != ';')\r
- $this->p_vars['include_value'] .= $word;\r
- }\r
- } else\r
- {\r
- $this->p_vars['include_params_data'] = '';\r
- }\r
- }\r
-\r
- if ($this->checkEventPop($word,$pevent))\r
- {\r
- $this->p_vars['include'] = new parserInclude;\r
- $this->p_vars['include']->setLineNumber($this->p_vars['linenum']);\r
- $this->p_flags['in_include'] = false;\r
- $this->p_vars['include']->setName($this->p_vars['include_name']);\r
- $this->p_vars['include']->setValue($this->p_vars['include_value']);\r
- $this->publishEvent(PHPDOCUMENTOR_EVENT_INCLUDE,$this->p_vars['include']);\r
- $this->p_flags['includename_isset'] = false;\r
- unset($this->p_vars['include']);\r
- unset($this->p_vars['include_name']);\r
- unset($this->p_vars['include_value']);\r
- unset($this->p_vars['include_params_data']);\r
- }\r
- }\r
- \r
- /**\r
- * handler for INCLUDE_PARAMS.\r
- * this handler parses the contents of ( ) in include/require/include_once/include_once statements\r
- */\r
- \r
- function handleIncludeParams($word, $pevent)\r
- {\r
- $this->checkEventPush( $word, $pevent);\r
- \r
- $this->p_flags['include_parens'] = true;\r
- if(!isset($this->p_vars['include_params_data'])) $this->p_vars['include_params_data'] = '';\r
- \r
- if ($this->checkEventPop($word,$pevent))\r
- {\r
- if (isset($this->p_vars['quote_data']))\r
- {\r
- $this->p_vars['include_value'] = $this->p_vars['include_params_data'].'"'.$this->p_vars['quote_data'].'"';\r
- unset($this->p_vars['quote_data']);\r
- } else {\r
- if (!empty($this->p_vars['include_params_data']))\r
- $this->p_vars['include_value'] = $this->p_vars['include_params_data'];\r
- else\r
- $this->p_vars['include_value'] = trim($this->p_vars['last_word']);\r
- }\r
- }\r
- if (isset($this->p_vars['quote_data']))\r
- {\r
- $this->p_vars['include_params_data'] .= '"'.$this->p_vars['quote_data'].'"';\r
- unset($this->p_vars['quote_data']);\r
- }\r
- if (($word != "'") && ($word != '"'))\r
- $this->p_vars['include_params_data'] .= $word;\r
- }\r
- \r
- /**\r
- * handler for INCLUDE_PARAMS_PARENTHESIS.\r
- * this handler takes all parenthetical statements within file in:\r
- * include statement include(file), and handles them properly\r
- */\r
- \r
- function handleIncludeParamsParenthesis($word, $pevent)\r
- {\r
- if (isset($this->p_vars['quote_data']))\r
- {\r
- $this->p_vars['include_params_data'] .= '"'.$this->p_vars['quote_data'].'"';\r
- unset($this->p_vars['quote_data']);\r
- }\r
- $this->p_vars['include_params_data'] .= $word;\r
- $this->checkEventPush( $word, $pevent);\r
- $this->checkEventPop( $word, $pevent);\r
- }\r
- /**#@-*/\r
- /**\r
- * this function checks whether parameter $word is a token for pushing a new event onto the Event Stack.\r
- * @return mixed returns false, or the event number\r
- */\r
- \r
- function checkEventPush($word,$pevent)\r
- {\r
- $e = false;\r
- if (isset($this->pushEvent[$pevent]))\r
- {\r
- if (isset($this->pushEvent[$pevent][strtolower($word)]))\r
- $e = $this->pushEvent[$pevent][strtolower($word)];\r
- }\r
- if ($e)\r
- {\r
- $this->p_vars['event_stack']->pushEvent($e);\r
- return $e;\r
- } else {\r
- return false;\r
- }\r
- }\r
-\r
- /**\r
- * this function checks whether parameter $word is a token for popping the current event off of the Event Stack.\r
- * @return mixed returns false, or the event number popped off of the stack\r
- */\r
- \r
- function checkEventPop($word,$pevent)\r
- {\r
- if (!isset($this->popEvent[$pevent])) return false;\r
- if (in_array(strtolower($word),$this->popEvent[$pevent]))\r
- {\r
- return $this->p_vars['event_stack']->popEvent();\r
- } else {\r
- return false;\r
- }\r
- }\r
-\r
- /**\r
- * setup the parser tokens, and the pushEvent/popEvent arrays\r
- * @see $tokens, $pushEvent, $popEvent\r
- */\r
- \r
- function setupStates()\r
- {\r
- $this->tokens[STATE_PHPCODE] = array(" ", "\t",";","?>","</script>","/**#@+","/**#@-*/","/**", "//","/*","#","\r\n","\n","\r","(",'<<<','"',"'");\r
- $this->tokens[STATE_QUOTE] = array("\\\"","\\\\","\"");\r
- $this->tokens[STATE_LOGICBLOCK] = array("{","}","\"","'","/*","//","#","?>","</script>",'<<<','global','static');\r
- $this->tokens[STATE_FUNC_GLOBAL] = array("\"","'","/*","//","#",";",",");\r
- $this->tokens[STATE_STATIC_VAR] = array("\"","'","/*","//","#",";",",",'=','array');\r
- $this->tokens[STATE_STATIC_VAR_VALUE] = array("/*","//","#"," ","\t",";","=","\"","'","array",",");\r
- $this->tokens[STATE_NOEVENTS] = array("<?php","<?",'<script language="php">');\r
- $this->tokens[STATE_COMMENTBLOCK] = array("*/","\n");\r
- $this->tokens[STATE_COMMENT] = array("\r\n","\r","\n");\r
- $this->tokens[STATE_DEFINE] = array(" ","(",";");\r
- $this->tokens[STATE_DEFINE_PARAMS] = array("/*","//","#",",",")"," ","'","\"","(");\r
- $this->tokens[STATE_DEFINE_PARAMS_PARENTHESIS] = array("(","'","\"",")");\r
- $this->tokens[STATE_FUNCTION_PARAMS] = array("/*","//","#","\"",",",")","="," ","'","(");\r
- $this->tokens[STATE_SINGLEQUOTE] = array("'","\\'","\\\\");\r
- $this->tokens[STATE_CLASS] = array(" ", "\t", "?>", "</script>", ";", "}", "{",\r
- "/**#@+", "/**#@-*/", "/**", "//", "/*", "#",\r
- "\r\n", "\n", "\r","(");\r
- $this->tokens[STATE_DOCBLOCK] = array("*/","*","@","\r\n","\n","\r",". ",".\n",".\t",'{@');\r
- $this->tokens[STATE_DOCBLOCK_TEMPLATE] = array("*/","*","@","\r\n","\n","\r",". ",".\n",".\t",'{@');\r
- $this->tokens[STATE_DOCKEYWORD] = array("@","*/","*","\n","\r\n","\r","\t"," ","<",">",'{@');\r
- $this->tokens[STATE_INLINE_DOCKEYWORD] = array("{@","}","\t"," ","*/");\r
- $this->tokens[STATE_DOCKEYWORD_EMAIL] = array(">","\n","\r\n","\r");\r
- $this->tokens[STATE_VAR] = array("/*","//","#"," ","\t",";","=",",","\"","'","array");\r
- $this->tokens[STATE_GLOBAL] = array("/*","//","#"," ","\t",";","=","\"","'");\r
- $this->tokens[STATE_GLOBAL_VALUE] = array("/*","//","#"," ","\t",";","=","\"","'","array");\r
- $this->tokens[STATE_ARRAY] = array("/*","//","#","(",")","\"","'","array");\r
- $this->tokens[STATE_FUNCTION] = array("(","{","}"," ","\t","&","/*","//","#");\r
- $this->tokens[STATE_OUTPHP] = array("<?php","<?",'<script language="php">');\r
- $this->tokens[STATE_EOFQUOTE] = array(" ","\t","\n");\r
- $this->tokens[STATE_ESCAPE] = false;// this tells the word parser to just cycle\r
- $this->tokens[STATE_INCLUDE] = array(" ","(",";","'",'"');\r
- $this->tokens[STATE_INCLUDE_PARAMS] = array("/*",")"," ","'","\"","(");\r
- $this->tokens[STATE_INCLUDE_PARAMS_PARENTHESIS] = array("(","'","\"",")");\r
-\r
- // For each event word to event mapings\r
- $this->pushEvent[PARSER_EVENT_QUOTE] = \r
- array(\r
- "\\" => PARSER_EVENT_ESCAPE\r
- );\r
- $this->popEvent[PARSER_EVENT_QUOTE] = array("\"");\r
-##########################\r
- \r
- $this->pushEvent[PARSER_EVENT_LOGICBLOCK] = \r
- array(\r
- "\"" => PARSER_EVENT_QUOTE,\r
- "'" => PARSER_EVENT_SINGLEQUOTE,\r
- "//" => PARSER_EVENT_COMMENT,\r
- "#" => PARSER_EVENT_COMMENT,\r
- "global" => PARSER_EVENT_FUNC_GLOBAL,\r
- "static" => PARSER_EVENT_STATIC_VAR,\r
- "/*" => PARSER_EVENT_COMMENTBLOCK,\r
- "{" => PARSER_EVENT_LOGICBLOCK,\r
- "?>" => PARSER_EVENT_OUTPHP,\r
- "</script>" => PARSER_EVENT_OUTPHP,\r
- "<<<" => PARSER_EVENT_EOFQUOTE\r
- );\r
- $this->popEvent[PARSER_EVENT_LOGICBLOCK] = array("}");\r
-##########################\r
-\r
- $this->pushEvent[PARSER_EVENT_FUNC_GLOBAL] =\r
- array(\r
- "\"" => PARSER_EVENT_QUOTE,\r
- "'" => PARSER_EVENT_SINGLEQUOTE,\r
- "//" => PARSER_EVENT_COMMENT,\r
- "#" => PARSER_EVENT_COMMENT,\r
- "/*" => PARSER_EVENT_COMMENTBLOCK,\r
- );\r
- $this->popEvent[PARSER_EVENT_FUNC_GLOBAL] = array(";");\r
-##########################\r
-\r
- $this->pushEvent[PARSER_EVENT_STATIC_VAR] =\r
- array(\r
- "\"" => PARSER_EVENT_QUOTE,\r
- "'" => PARSER_EVENT_SINGLEQUOTE,\r
- "//" => PARSER_EVENT_COMMENT,\r
- "#" => PARSER_EVENT_COMMENT,\r
- "/*" => PARSER_EVENT_COMMENTBLOCK,\r
- "=" => PARSER_EVENT_STATIC_VAR_VALUE,\r
- );\r
- $this->popEvent[PARSER_EVENT_STATIC_VAR] = array(";");\r
-##########################\r
-\r
- $this->pushEvent[PARSER_EVENT_STATIC_VAR_VALUE] = \r
- array(\r
- "\"" => PARSER_EVENT_QUOTE,\r
- "'" => PARSER_EVENT_SINGLEQUOTE,\r
- "array" => PARSER_EVENT_ARRAY,\r
- "/*" => PARSER_EVENT_COMMENTBLOCK,\r
- "//" => PARSER_EVENT_COMMENT,\r
- "#" => PARSER_EVENT_COMMENT\r
- );\r
- $this->popEvent[PARSER_EVENT_STATIC_VAR_VALUE] = array(";",",");\r
-##########################\r
-\r
- $this->pushEvent[PARSER_EVENT_NOEVENTS] = \r
- array(\r
- "<?php" => PARSER_EVENT_PHPCODE,\r
- "<?" => PARSER_EVENT_PHPCODE,\r
- '<script language="php">' => PARSER_EVENT_PHPCODE,\r
- );\r
-##########################\r
-\r
- $this->pushEvent[PARSER_EVENT_PHPCODE] = \r
- array(\r
- "function" => PARSER_EVENT_FUNCTION,\r
- "class" => PARSER_EVENT_CLASS,\r
- "define" => PARSER_EVENT_DEFINE,\r
- "include_once" => PARSER_EVENT_INCLUDE,\r
- "require_once" => PARSER_EVENT_INCLUDE,\r
- "include" => PARSER_EVENT_INCLUDE,\r
- "require" => PARSER_EVENT_INCLUDE,\r
- "//" => PARSER_EVENT_COMMENT,\r
- "#" => PARSER_EVENT_COMMENT,\r
- "/*" => PARSER_EVENT_COMMENTBLOCK,\r
- "/**" => PARSER_EVENT_DOCBLOCK,\r
- "/**#@+" => PARSER_EVENT_DOCBLOCK_TEMPLATE,\r
- "/**#@-*/" => PARSER_EVENT_END_DOCBLOCK_TEMPLATE,\r
- "\"" => PARSER_EVENT_QUOTE,\r
- "'" => PARSER_EVENT_SINGLEQUOTE,\r
- "<<<" => PARSER_EVENT_EOFQUOTE,\r
- "?>" => PARSER_EVENT_OUTPHP,\r
- "</script>" => PARSER_EVENT_OUTPHP,\r
- );\r
-##########################\r
-\r
- $this->pushEvent[PARSER_EVENT_FUNCTION] = \r
- array(\r
- "(" => PARSER_EVENT_FUNCTION_PARAMS,\r
- "//" => PARSER_EVENT_COMMENT,\r
- "#" => PARSER_EVENT_COMMENT,\r
- "/*" => PARSER_EVENT_COMMENTBLOCK,\r
- "{" => PARSER_EVENT_LOGICBLOCK\r
- );\r
- $this->popEvent[PARSER_EVENT_FUNCTION] = array("}");\r
-##########################\r
-\r
- $this->pushEvent[PARSER_EVENT_DOCBLOCK] = \r
- array(\r
- "@" => PARSER_EVENT_DOCKEYWORD,\r
- "{@" => PARSER_EVENT_INLINE_DOCKEYWORD\r
- );\r
- $this->popEvent[PARSER_EVENT_DOCBLOCK] = array("*/");\r
-##########################\r
-\r
- $this->pushEvent[PARSER_EVENT_DOCBLOCK_TEMPLATE] = \r
- array(\r
- "@" => PARSER_EVENT_DOCKEYWORD,\r
- "{@" => PARSER_EVENT_INLINE_DOCKEYWORD\r
- );\r
- $this->popEvent[PARSER_EVENT_DOCBLOCK_TEMPLATE] = array("*/");\r
-##########################\r
-\r
- $this->pushEvent[PARSER_EVENT_CLASS] = \r
- array(\r
- "function" => PARSER_EVENT_FUNCTION,\r
- "var" => PARSER_EVENT_VAR,\r
- "/**" => PARSER_EVENT_DOCBLOCK,\r
- "/**#@+" => PARSER_EVENT_DOCBLOCK_TEMPLATE,\r
- "/**#@-*/" => PARSER_EVENT_END_DOCBLOCK_TEMPLATE,\r
- "//" => PARSER_EVENT_COMMENT,\r
- "/*" => PARSER_EVENT_COMMENTBLOCK,\r
- "#" => PARSER_EVENT_COMMENT,\r
- "?>" => PARSER_EVENT_OUTPHP,\r
- "</script>" => PARSER_EVENT_OUTPHP,\r
- );\r
- $this->popEvent[PARSER_EVENT_CLASS] = array("}");\r
-##########################\r
-\r
- $this->pushEvent[PARSER_EVENT_DEFINE] = \r
- array(\r
- "/*" => PARSER_EVENT_COMMENTBLOCK,\r
- "(" => PARSER_EVENT_DEFINE_PARAMS\r
- );\r
- $this->popEvent[PARSER_EVENT_DEFINE] = array(";");\r
-##########################\r
-\r
- $this->pushEvent[PARSER_EVENT_INCLUDE] = \r
- array(\r
- "/*" => PARSER_EVENT_COMMENTBLOCK,\r
- "(" => PARSER_EVENT_INCLUDE_PARAMS,\r
- "'" => PARSER_EVENT_SINGLEQUOTE,\r
- '"' => PARSER_EVENT_QUOTE,\r
- );\r
- $this->popEvent[PARSER_EVENT_INCLUDE] = array(";");\r
-##########################\r
-\r
- $this->pushEvent[PARSER_EVENT_DEFINE_PARAMS] = \r
- array(\r
- "(" => PARSER_EVENT_DEFINE_PARAMS_PARENTHESIS,\r
- "'" => PARSER_EVENT_SINGLEQUOTE,\r
- '"' => PARSER_EVENT_QUOTE,\r
- "/*" => PARSER_EVENT_COMMENTBLOCK,\r
- "//" => PARSER_EVENT_COMMENT,\r
- "#" => PARSER_EVENT_COMMENT\r
- );\r
- $this->popEvent[PARSER_EVENT_DEFINE_PARAMS] = array(")");\r
-##########################\r
-\r
- $this->pushEvent[PARSER_EVENT_INCLUDE_PARAMS] = \r
- array(\r
- "(" => PARSER_EVENT_INCLUDE_PARAMS_PARENTHESIS,\r
- "'" => PARSER_EVENT_SINGLEQUOTE,\r
- '"' => PARSER_EVENT_QUOTE,\r
- );\r
- $this->popEvent[PARSER_EVENT_INCLUDE_PARAMS] = array(")");\r
-##########################\r
-\r
- $this->pushEvent[PARSER_EVENT_DEFINE_PARAMS_PARENTHESIS] =\r
- array(\r
- "(" => PARSER_EVENT_DEFINE_PARAMS_PARENTHESIS,\r
- "'" => PARSER_EVENT_SINGLEQUOTE,\r
- '"' => PARSER_EVENT_QUOTE,\r
- );\r
- $this->popEvent[PARSER_EVENT_DEFINE_PARAMS_PARENTHESIS] = array(")");\r
-##########################\r
-\r
- $this->pushEvent[PARSER_EVENT_INCLUDE_PARAMS_PARENTHESIS] =\r
- array(\r
- "(" => PARSER_EVENT_INCLUDE_PARAMS_PARENTHESIS,\r
- "'" => PARSER_EVENT_SINGLEQUOTE,\r
- '"' => PARSER_EVENT_QUOTE,\r
- );\r
- $this->popEvent[PARSER_EVENT_INCLUDE_PARAMS_PARENTHESIS] = array(")");\r
-##########################\r
-\r
- $this->pushEvent[PARSER_EVENT_VAR] = \r
- array(\r
- "\"" => PARSER_EVENT_QUOTE,\r
- "'" => PARSER_EVENT_SINGLEQUOTE,\r
- "array" => PARSER_EVENT_ARRAY,\r
- "/*" => PARSER_EVENT_COMMENTBLOCK,\r
- "//" => PARSER_EVENT_COMMENT,\r
- "#" => PARSER_EVENT_COMMENT\r
- );\r
- $this->popEvent[PARSER_EVENT_VAR] = array(";");\r
-##########################\r
-\r
- $this->pushEvent[PARSER_EVENT_DEFINE_GLOBAL] = \r
- array(\r
- "=" => PARSER_EVENT_GLOBAL_VALUE,\r
- "\"" => PARSER_EVENT_QUOTE,\r
- "'" => PARSER_EVENT_SINGLEQUOTE,\r
- "/*" => PARSER_EVENT_COMMENTBLOCK,\r
- "//" => PARSER_EVENT_COMMENT,\r
- "#" => PARSER_EVENT_COMMENT\r
- );\r
- $this->popEvent[PARSER_EVENT_DEFINE_GLOBAL] = array(";");\r
-##########################\r
-\r
- $this->pushEvent[PARSER_EVENT_GLOBAL_VALUE] = \r
- array(\r
- "\"" => PARSER_EVENT_QUOTE,\r
- "'" => PARSER_EVENT_SINGLEQUOTE,\r
- "array" => PARSER_EVENT_ARRAY,\r
- "/*" => PARSER_EVENT_COMMENTBLOCK,\r
- "//" => PARSER_EVENT_COMMENT,\r
- "#" => PARSER_EVENT_COMMENT\r
- );\r
- $this->popEvent[PARSER_EVENT_GLOBAL_VALUE] = array(";");\r
-##########################\r
-\r
- $this->pushEvent[PARSER_EVENT_COMMENT] = \r
- array(\r
- "\\" => PARSER_EVENT_ESCAPE\r
- );\r
- $this->popEvent[PARSER_EVENT_COMMENT] = array("\n");\r
-##########################\r
-\r
- $this->popEvent[PARSER_EVENT_COMMENTBLOCK] = array("*/");\r
-##########################\r
- $this->pushEvent[PARSER_EVENT_SINGLEQUOTE] = \r
- array(\r
- "\\" => PARSER_EVENT_ESCAPE\r
- );\r
-\r
- $this->popEvent[PARSER_EVENT_SINGLEQUOTE] = array("'");\r
-##########################\r
- $this->pushEvent[PARSER_EVENT_FUNCTION_PARAMS] = \r
- array(\r
- "\"" => PARSER_EVENT_QUOTE,\r
- "'" => PARSER_EVENT_SINGLEQUOTE,\r
- "array" => PARSER_EVENT_ARRAY,\r
- "/*" => PARSER_EVENT_COMMENTBLOCK,\r
- "//" => PARSER_EVENT_COMMENT,\r
- "#" => PARSER_EVENT_COMMENT\r
- );\r
- $this->popEvent[PARSER_EVENT_FUNCTION_PARAMS] = array(")");\r
-##########################\r
- $this->pushEvent[PARSER_EVENT_DOCKEYWORD] = \r
- array(\r
-// "<" => PARSER_EVENT_DOCKEYWORD_EMAIL,\r
- "{@" => PARSER_EVENT_INLINE_DOCKEYWORD,\r
- );\r
-\r
- $this->popEvent[PARSER_EVENT_DOCKEYWORD] = array("*/");\r
-##########################\r
-\r
- $this->popEvent[PARSER_EVENT_INLINE_DOCKEYWORD] = array("}","*/");\r
-##########################\r
-\r
- $this->popEvent[PARSER_EVENT_OUTPHP] = array("<?php","<?",'<script language="php">');\r
-##########################\r
-\r
- $this->popEvent[PARSER_EVENT_DOCKEYWORD_EMAIL] = array(">","\n");\r
-\r
-##########################\r
- $this->pushEvent[PARSER_EVENT_ARRAY] = \r
- array(\r
- "\"" => PARSER_EVENT_QUOTE,\r
- "'" => PARSER_EVENT_SINGLEQUOTE,\r
- "array" => PARSER_EVENT_ARRAY,\r
- "/*" => PARSER_EVENT_COMMENTBLOCK,\r
- "//" => PARSER_EVENT_COMMENT,\r
- "#" => PARSER_EVENT_COMMENT\r
- );\r
- $this->popEvent[PARSER_EVENT_ARRAY] = array(")");\r
-##########################\r
- }\r
-\r
- /**\r
- * tell the parser's WordParser {@link $wp} to set up tokens to parse words by.\r
- * tokens are word separators. In English, a space or punctuation are examples of tokens.\r
- * In PHP, a token can be a ;, a parenthesis, or even the word "function"\r
- * @param $value integer an event number\r
- * @see WordParser\r
- */\r
- \r
- function configWordParser($e)\r
- {\r
- $this->wp->setSeperator($this->tokens[($e + 100)]);\r
- }\r
-\r
- /**\r
- * Debugging function, takes an event number and attempts to return its name\r
- * @param $value integer an event number\r
- */\r
- \r
-\r
- function getParserEventName ($value)\r
- { \r
- $lookup = array(\r
- PARSER_EVENT_NOEVENTS => "PARSER_EVENT_NOEVENTS",\r
- PARSER_EVENT_PHPCODE => "PARSER_EVENT_PHPCODE",\r
- PARSER_EVENT_DOCBLOCK => "PARSER_EVENT_DOCBLOCK",\r
- PARSER_EVENT_FUNCTION => "PARSER_EVENT_FUNCTION",\r
- PARSER_EVENT_CLASS => "PARSER_EVENT_CLASS",\r
- PARSER_EVENT_DEFINE => "PARSER_EVENT_DEFINE",\r
- PARSER_EVENT_DEFINE_PARAMS => "PARSER_EVENT_DEFINE_PARAMS",\r
- PARSER_EVENT_COMMENT => "PARSER_EVENT_COMMENT",\r
- PARSER_EVENT_COMMENTBLOCK => "PARSER_EVENT_COMMENTBLOCK",\r
- PARSER_EVENT_ESCAPE => "PARSER_EVENT_ESCAPE",\r
- PARSER_EVENT_QUOTE => "PARSER_EVENT_QUOTE",\r
- PARSER_EVENT_FUNCTION_PARAMS => "PARSER_EVENT_FUNCTION_PARAMS",\r
- PARSER_EVENT_SINGLEQUOTE => "PARSER_EVENT_SINGLEQUOTE",\r
- PARSER_EVENT_VAR => "PARSER_EVENT_VAR",\r
- PARSER_EVENT_LOGICBLOCK => "PARSER_EVENT_LOGICBLOCK",\r
- PARSER_EVENT_OUTPHP => "PARSER_EVENT_OUTPHP",\r
- PARSER_EVENT_DOCKEYWORD => "PARSER_EVENT_DOCKEYWORD",\r
- PARSER_EVENT_DOCKEYWORD_EMAIL => "PARSER_EVENT_DOCKEYWORD_EMAIL",\r
- PARSER_EVENT_ARRAY => "PARSER_EVENT_ARRAY",\r
- PARSER_EVENT_INLINE_DOCKEYWORD => "PARSER_EVENT_INLINE_DOCKEYWORD",\r
- PARSER_EVENT_EOFQUOTE => "PARSER_EVENT_EOFQUOTE",\r
- PARSER_EVENT_INCLUDE => "PARSER_EVENT_INCLUDE",\r
- PARSER_EVENT_INCLUDE_PARAMS => "PARSER_EVENT_INCLUDE_PARAMS",\r
- PARSER_EVENT_INCLUDE_PARAMS_PARENTHESIS => "PARSER_EVENT_INCLUDE_PARAMS_PARENTHESIS",\r
- PARSER_EVENT_DEFINE_PARAMS_PARENTHESIS => "PARSER_EVENT_DEFINE_PARAMS_PARENTHESIS",\r
- PARSER_EVENT_DEFINE_GLOBAL => "PARSER_EVENT_DEFINE_GLOBAL",\r
- PARSER_EVENT_GLOBAL_VALUE => "PARSER_EVENT_GLOBAL_VALUE",\r
- PARSER_EVENT_FUNC_GLOBAL => "PARSER_EVENT_FUNC_GLOBAL",\r
- PARSER_EVENT_STATIC_VAR => "PARSER_EVENT_STATIC_VAR",\r
- PARSER_EVENT_DOCBLOCK_TEMPLATE => "PARSER_EVENT_DOCBLOCK_TEMPLATE",\r
- PARSER_EVENT_END_DOCBLOCK_TEMPLATE => "PARSER_EVENT_END_DOCBLOCK_TEMPLATE",\r
- PARSER_EVENT_METHOD_LOGICBLOCK => 'PARSER_EVENT_METHOD_LOGICBLOCK',\r
- PARSER_EVENT_CLASS_MEMBER => 'PARSER_EVENT_CLASS_MEMBER',\r
- PARSER_EVENT_METHOD => 'PARSER_EVENT_METHOD',\r
- PARSER_EVENT_QUOTE_VAR => 'PARSER_EVENT_QUOTE_VAR',\r
- PARSER_EVENT_ACCESS_MODIFIER => 'PARSER_EVENT_ACCESS_MODIFIER',\r
- PARSER_EVENT_IMPLEMENTS => 'PARSER_EVENT_IMPLEMENTS',\r
- PARSER_EVENT_CLASS_CONSTANT => 'PARSER_EVENT_CLASS_CONSTANT',\r
- PARSER_EVENT_VAR_ARRAY => 'PARSER_EVENT_VAR_ARRAY',\r
- PARSER_EVENT_VAR_ARRAY_COMMENT =>'PARSER_EVENT_VAR_ARRAY_COMMENT',\r
- );\r
- if (isset($lookup[$value]))\r
- return $lookup[$value];\r
- else return $value;\r
- }\r
-}\r
-\r
-/**\r
- * Global package page parser\r
- *\r
- * @deprecated in favor of tutorials\r
- * @tutorial tutorials.pkg\r
- * @package phpDocumentor\r
- * @subpackage Parsers\r
- */\r
-class ppageParser extends Parser\r
-{\r
- /** @var string */\r
- var $package = false;\r
- /** @var string */\r
- var $subpackage = '';\r
- /**\r
- * set up invariant Parser variables\r
- */\r
- function ppageParser()\r
- {\r
- Parser::Parser();\r
- $this->allowableInlineTags = $GLOBALS['_phpDocumentor_inline_tutorial_tags_allowed'];\r
- $this->eventHandlers = array();\r
- $this->eventHandlers[PARSER_EVENT_NOEVENTS] = 'defaultHandler';\r
- $this->eventHandlers[PARSER_EVENT_INLINE_DOCKEYWORD] = 'handleInlineDocKeyword';\r
- }\r
- \r
- /**\r
- * set up invariant Parser variables\r
- */\r
- function setupStates()\r
- {\r
- $this->tokens[STATE_NOEVENTS] = array("{@","}");\r
- $this->tokens[STATE_INLINE_DOCKEYWORD] = array("{@","}","\t"," ");\r
-\r
-##########################\r
-\r
- $this->pushEvent[PARSER_EVENT_NOEVENTS] = \r
- array(\r
- "{@" => PARSER_EVENT_INLINE_DOCKEYWORD\r
- );\r
-##########################\r
-\r
- $this->popEvent[PARSER_EVENT_INLINE_DOCKEYWORD] = array("}");\r
- }\r
- \r
- /**\r
- * Parse a new file\r
- *\r
- * @param string $parse_data\r
- * @param string $package\r
- * @param int $subpackage\r
- * @return mixed false or parsed data\r
- */\r
- function parse (&$parse_data,$xml,$package = 'default',$subpackage = '',$tutorial = '',\r
- $category='default', $path='')\r
- {\r
- $this->setupStates();\r
- $this->p_vars['total'] = new parserPackagePage($package,$xml);\r
- $this->p_vars['tutorial'] = $tutorial;\r
- $this->_path = $path;\r
- $this->category = $category;\r
- $this->package = $package;\r
- if (!isset($subpackage) || !$subpackage) $subpackage = '';\r
- $this->subpackage = $subpackage;\r
- if (strlen($parse_data) == 0)\r
- {\r
- return false;\r
- }\r
-\r
- // initialize variables so E_ALL error_reporting doesn't complain\r
- $pevent = 0;\r
- $word = 0;\r
- $this->p_vars['event_stack'] = new EventStack;\r
- // change this to a new ParserStringWithInlineTags, and change all $total .= blah to $total->add(blah)\r
- // then modify phpDocumentor_IntermediateParser->Convert to convert all package pages (the package page handler in phpDocumentor_IntermediateParser should\r
- // save them all in a variable) to perform the linking. then, remove the legacy code from handleDocBlock\r
- // and handleClass in Render.inc, and do a loop that converts each package page, and passes it to handleEvent\r
- // just like Converter::walk does with the other elements. The only other addition that might be good is a\r
- // new descendant of parserElement parserPackagePage that contains the data and stuff. Hope this helps :)\r
- $total = '';\r
-\r
- $this->wp->setup($parse_data);\r
-\r
- $this->p_flags['reset_quote_data'] = true;\r
-\r
- do\r
- {\r
- $lpevent = $pevent;\r
- $pevent = $this->p_vars['event_stack']->getEvent();\r
- if ($lpevent != $pevent)\r
- {\r
- $this->p_vars['last_pevent'] = $lpevent;\r
- }\r
-\r
- if ($this->p_vars['last_pevent'] != $pevent)\r
- {\r
- // its a new event so the word parser needs to be reconfigured \r
- $this->configWordParser($pevent);\r
- }\r
-\r
- if (!$xml)\r
- $this->publishEvent(PHPDOCUMENTOR_EVENT_NEWSTATE,($pevent + 100));\r
-\r
-\r
- $this->p_vars['last_word'] = $word;\r
- $word = $this->wp->getWord();\r
-\r
- if (PHPDOCUMENTOR_DEBUG == true)\r
- {\r
- echo "LAST: |" . $this->p_vars['last_word'] . "|\n";\r
- echo "PEVENT: " . $this->getParserEventName($pevent) . "\n";\r
- echo $this->wp->getPos() . ": |$word|\n";\r
- }\r
- if (isset($this->eventHandlers[$pevent]))\r
- {\r
- $handle = $this->eventHandlers[$pevent];\r
- $this->$handle($word, $pevent);\r
- }\r
- } while (!($word === false));\r
- if (!$xml)\r
- $this->PublishEvent(PHPDOCUMENTOR_EVENT_PACKAGEPAGE,$this->p_vars['total']);\r
- else\r
- return $this->p_vars['total']->value;\r
- }\r
- \r
- /**\r
- * Handles all non-inline tags\r
- * \r
- * @param string token\r
- * @param integer parser event\r
- */\r
- function defaultHandler($word, $pevent)\r
- {\r
- if (!$this->checkEventPush( $word, $pevent))\r
- {\r
- if ($word) $this->p_vars['total']->add($word);\r
- }\r
- }\r
-\r
- /**\r
- * handler for INLINE_DOCKEYWORD.\r
- * this handler recognizes {@inline tags} like link, and parses them, replacing them directly\r
- * in the text flow with their output.\r
- * @param string token\r
- * @param integer parser event\r
- */\r
- \r
- function handleInlineDockeyword($word, $pevent)\r
- {\r
- // echo $this->wp->getPos() . ": |$word|\n";\r
-\r
- // echo "docktype: $this->p_vars['inline_dockeyword_type']\n";\r
- if (!isset($this->p_vars['inline_dockeyword_type'])) $this->p_vars['inline_dockeyword_type'] = false;\r
- if (!isset($this->p_vars['inline_dockeyword_data'])) $this->p_vars['inline_dockeyword_data'] = '';\r
- if (!$this->p_vars['inline_dockeyword_type'])\r
- {\r
- if (in_array($word,$this->allowableInlineTags))\r
- {\r
- $this->p_vars['inline_dockeyword_type'] = strtolower($word);\r
- $this->p_vars['whitesp'] = $this->wp->returnWhiteSpace;\r
- $this->wp->setWhiteSpace(true);\r
- } else {\r
- if ($word == '}')\r
- $this->p_vars['total']->add('{@');\r
- else\r
- {\r
- $this->p_vars['total']->add('{@'.$word);\r
- $this->p_vars['event_stack']->popEvent();\r
- }\r
- $this->p_vars['inline_dockeyword_type'] = false;\r
- $this->p_vars['inline_dockeyword_data'] = '';\r
- }\r
- } else\r
- {\r
- if ($word != "}")\r
- {\r
- $this->p_vars['inline_dockeyword_data'] .= $word;\r
- }\r
- }\r
- if ($this->checkEventPop($word,$pevent))\r
- {\r
- $this->wp->setWhiteSpace($this->p_vars['whitesp']);\r
- if ($this->p_vars['inline_dockeyword_type']=='link')\r
- {\r
- // support hyperlinks of any protocol\r
- if (is_numeric(strpos($this->p_vars['inline_dockeyword_data'],'://')) || (strpos(trim($this->p_vars['inline_dockeyword_data']),'mailto:') === 0))\r
- {\r
- // if there is more than 1 parameter, the stuff after the space is the hyperlink text\r
- if (strpos(trim($this->p_vars['inline_dockeyword_data']),' '))\r
- {\r
- $i1 = strpos(trim($this->p_vars['inline_dockeyword_data']),' ') + 1;\r
- $link = substr(trim($this->p_vars['inline_dockeyword_data']),0,$i1 - 1);\r
- $text = substr(trim($this->p_vars['inline_dockeyword_data']),$i1);\r
- $this->p_vars['inline_dockeyword_data'] = new parserLinkInlineTag($link,$text);\r
-// '<a href="'.$link.'">'.$text.'</a>';\r
- }\r
- else\r
- {\r
- $this->p_vars['inline_dockeyword_data'] = new parserLinkInlineTag($this->p_vars['inline_dockeyword_data'],$this->p_vars['inline_dockeyword_data']);\r
- }\r
-// '<a href="'.$this->p_vars['inline_dockeyword_data'].'">'.$this->p_vars['inline_dockeyword_data'].'</a>';\r
- } else\r
- {\r
- $testp = explode('#',$this->p_vars['inline_dockeyword_data']);\r
- if (count($testp) - 1) $this->p_vars['inline_dockeyword_data'] = $testp[1];\r
- $this->p_vars['inline_dockeyword_data'] = new parserLinkInlineTag($this->p_vars['inline_dockeyword_data'],$this->p_vars['inline_dockeyword_data']);\r
- }\r
- }\r
- if ($this->p_vars['inline_dockeyword_type']=='id')\r
- {\r
- $this->p_vars['inline_dockeyword_data'] = new parserIdInlineTag($this->category,$this->package,$this->subpackage,$this->p_vars['tutorial'],trim($this->p_vars['inline_dockeyword_data']));\r
- }\r
- if ($this->p_vars['inline_dockeyword_type'] == 'tutorial')\r
- {\r
- $this->p_vars['inline_dockeyword_data'] = new parserTutorialInlineTag($this->p_vars['inline_dockeyword_data'],$this->p_vars['inline_dockeyword_data']);\r
- }\r
- if ($this->p_vars['inline_dockeyword_type'] == 'toc')\r
- {\r
- $this->p_vars['inline_dockeyword_data'] = new parserTocInlineTag();\r
- }\r
- if ($this->p_vars['inline_dockeyword_type'] == 'example')\r
- {\r
- $example =\r
- new parserExampleInlineTag($this->p_vars['inline_dockeyword_data'], $this->_path, true);\r
- $this->p_vars['total']->add($example->getProgramListing());\r
- } else\r
- {\r
- $this->p_vars['total']->add($this->p_vars['inline_dockeyword_data']);\r
- }\r
- $this->p_vars['inline_dockeyword_type'] = false;\r
- $this->p_vars['inline_dockeyword_data'] = '';\r
- }\r
- }\r
-}\r
-?>\r