uw Sun Feb 18 07:19:15 2001 EDT Modified files: /php4/pear/PHPDoc/analyser PhpdocAnalyser.php PhpdocClassAnalyser.php PhpdocModuleAnalyser.php Log: Sorry, whitespace only changes to follow the PEAR Coding conventions. Replaced tabs with spaces.
Index: php4/pear/PHPDoc/analyser/PhpdocAnalyser.php diff -u php4/pear/PHPDoc/analyser/PhpdocAnalyser.php:1.5 php4/pear/PHPDoc/analyser/PhpdocAnalyser.php:1.6 --- php4/pear/PHPDoc/analyser/PhpdocAnalyser.php:1.5 Sun Dec 3 14:37:36 2000 +++ php4/pear/PHPDoc/analyser/PhpdocAnalyser.php Sun Feb 18 07:19:15 2001 @@ -8,354 +8,354 @@ * - inherit elements * - inherit information * -* @version $Id: PhpdocAnalyser.php,v 1.5 2000/12/03 22:37:36 uw Exp $ +* @version $Id: PhpdocAnalyser.php,v 1.6 2001/02/18 15:19:15 uw Exp $ */ class PhpdocAnalyser extends PhpdocObject { - /** - * Flag indicating that getModule/getClass was called. - * - * @var boolean - */ - var $flag_get = false; - - /** - * List of all elements of a certain class/module. - * - * The array is used to look up see references - * - * @var array Format: elementlist[ eltype ][ elname ] = true - * @see buildElementlist() - */ - var $elementlist = array(); - - /** - * Adds a suffix to the number like 1st, 2nd and 3th - * - * @param integer $nr number to format - * @return string - * @author Thomas Weinert <[EMAIL PROTECTED]> - */ - function addNumberSuffix($nr) { - - $last_nr = substr($nr, -1, 1); - - switch ($last_nr) { - case 1: - return ($nr."st"); - break; - - case 2: - return ($nr."nd"); - break; - - default: - return ($nr."th"); - } - - } // end func addNumberSuffix - - /** - * Starts the analysing of the raw parsing data. - * - * @access public - * @abstract - */ - function analyse() { - ; - } // end func analyse - - /** - * Handles brother and sister. - * - * @abstract - * @see updateBrotherSisterElements() - */ - function updateBrothersSisters() { - ; - } // end func updateBrothersSisters - - /** - * Updates certain elements that use brother and sister. - * - * @return boolean $ok - */ - function updateBrotherSisterElements() { - return false; - } // end func updateBrotherSisterElements - - /** - * Copies fields from a brother or sister to the current element. - * - * @param array Data of the target element that has a brother/sister tag - * @param array Data of the element that is referenced by brother/sister - */ - function copyBrotherSisterFields($target, $from) { - - reset($from); - while (list($k, $v) = each($from)) - if (!isset($target[$k]) || "" == $target[$k]) - $target[$k] = $v; - - return $target; - } // end func copyBrotherSisterFields - - /** - * Updates the access and return tag values. - * - * @see updateAccessReturnElements(), updateAccessElements() - * @abstract - */ - function updateAccessReturn() { - ; - } // end func updateAccessReturn - - /** - * Updates access and return for certain elements. - * - * This function should only be used to update functions. - * Functions that have the same name as the class (constructors) - * get return void and access public. Functions without - * access get access public and functions without return get return void. - * - * @return boolean $ok - * @see updateAccessReturn() - * @abstract - */ - function updateAccessReturnElements() { - ; - } // end func updateAccessReturnElements - - /** - * Updates access tags. - * - * @see updateAccessReturnElements() - * @abstract - */ - function updateAccessElements() { - ; - } // end func updateAccessElements - - /** - * Compares the param tags with the function head found. - * - * @abstract - */ - function checkFunctionArgs() { - ; - } // end func checkFunctionArgs - - /** - * Looks for undocumented elements and adds a warning if neccessary. - * - * @abstract - */ - function findUndocumented() { - ; - } // end func findUndocumented - - /** - * Checks all see references in the given classes/modulegroup. - * - * @abstract - */ - function checkSee() { - ; - } // end func checkSee - - /** - * Checks see references in the given elementlist. - * - * @abstract - */ - function checkSeeElement() { - ; - } // end func checkSeeElement - - /** - * Build a list of all elemente (functions, variables,...) of a certain class/module - * - * @abstract - * @see $elementlist - */ - function buildElementlist() { - ; - } // end func buildElementlist - - /** - * Compares the argument list generated from the function head with the param tags found. - * - * PHPDoc is able to recognize these documentation mistakes: - * - too few or too many param tags - * - name does not match or is missing - * - type does not match or is missing - * - trouble with inherited elements - * - * @param array Function arguments found by the parser - * @param array Paramarray - * @param string Functionname - * @param string Filename - * @param boolean Param tags inherited? - * @return array $params Param array - */ - function checkArgDocs($args, $params, $elname, $elfile, $inherited = false) { - - // "param" contains the information from the @param tags. - $num_args = count($args); - $num_params = count($params); - - // no args? return... - if (0 == $num_args && 0 == $num_params) - return array(); - - // no args but @param used - if (0 == $num_args && $num_params > 0) { - - if (!$inherited) { - - $msg = "Function head shows no parameters, remove all @param tags."; - $this->warn->addDocWarning($elfile, "function", $elname, $msg, "mismatch"); - - } else { - - if ("void" != $params[0]["type"]) { - - $msg = "The function inherited some parameter documentation from it's parentclass but PHPDoc could not find - arguments in the function head. Add @param void to the doc comment to avoid confusion."; - $this->warn->addDocWarning($elfile, "function", $elname, $msg, "mismatch"); - - } - - } - - return array(); - - } - - // compare the informations from the parser with the @param tags - reset($args); - while (list($k, $arg) = each($args)) { - - if (isset($params[$k])) { - - if ($arg["optional"]) - $params[$k]["default"] = $arg["default"]; - - if (!$inherited) { - - if ("" != $arg["type"] && "" != $params[$k]["type"] && "mixed" != $params[$k]["type"] && strtolower($arg["type"]) != strtolower($params[$k]["type"])) { - - $type = $arg["type"]; - $msg = sprintf("%s parameter type '%s' does match the the documented type '%s', possible error consider an update to '@param %s %s %s' or '@param %s %s', the variable name is optional.", - $this->addNumberSuffix($k + 1), - $arg["name"], - $params[$k]["type"], - $type, - $arg["name"], - (isset($params[$k]["desc"])) ? $params[$k]["desc"] : "(description)", - $type, - (isset($params[$k]["desc"])) ? $params[$k]["desc"] : "(description)" - ); - - $this->warn->addDocWarning($elfile, "function", $elname, $msg, "mismatch"); - - } else if ("" != $params[$k]["type"]) { - - $type = $params[$k]["type"]; - - } else { - - $msg = sprintf('Type missing for the %s parameter, "mixed" assumed.', $this->addNumberSuffix($k)); - $this->warn->addDocWarning($elfile, "function", $elname, $msg, "missing"); - $type = "mixed"; - - } - - $params[$k]["type"] = $type; - - } else { - - if ("" != $params[$k]["type"] && strtolower($arg["type"]) != strtolower($params[$k]["type"])) { - - $type = (""!=$args["type"]) ? $arg["type"] : $params[$k]["type"]; - $msg = sprintf("Possible documentation error due to inherited information. - The type of the %s parameter '%s' does not match the documented type '%s'. - Override the inherited documentation if neccessary.", - $this->addNumberSuffix($k), - $arg["type"], - $params[$k]["type"] - ); - $this->warn->addDocWarning($elfile, "function", $elname, $msg, "mismatch"); - - } else if ("" != $params[$k]["type"]) { - - $type = $params[$k]["type"]; - - } else { - - $type = "mixed"; - $msg = sprintf('Type missing for the %d parameter, "mixed" assumed. Override the inherited documentation if neccessary.', $k); - $this->warn->addDocWarning($elfile, "function", $elname, $msg, "mismatch"); - - } - - $params[$k]["type"] = $type; - - } - - if ("" != $params[$k]["name"] && $arg["name"] != $params[$k]["name"]) { - - $msg = sprintf("%s parameter '%s' does not match the documented name '%s', update the tag to '@param %s %s %s' or '@param %s %s', the variable name is optional.", - $this->addNumberSuffix($k+1), - $arg["name"], - $params[$k]["name"], - $type, - $arg["name"], - (isset($params[$k]["desc"])) ? $params[$k]["desc"] : "(description)", - $type, - (isset($params[$k]["desc"])) ? $params[$k]["desc"] : "(description)" - ); - - $this->warn->addDocWarning($elfile, "function", $elname, $msg, "mismatch"); - $params[$k]["name"] = $arg["name"]; - - } else if ("" == $params[$k]["name"]) { - - $params[$k]["name"] = $arg["name"]; - - } - - } else { - - $msg = sprintf("%s parameter '%s' is not documented add '@param %s [description]' to the end of the @param[eter] list.", - $this->addNumberSuffix($k+1), - $arg["name"], - ("" == $arg["type"]) ? "(object objectname|type)" : $arg["type"] - ); - - $params[$k]["name"] = $arg["name"]; - $params[$k]["undoc"] = true; - - if ("" != $arg["type"]) - $params[$k]["type"] = $arg["type"]; - - $this->warn->addDocWarning($elfile, "function", $elname, $msg, "missing"); - } - - } - - // more @params specified than variables where found in the function head, delete them - if ($num_params > $num_args) { - - $msg = "The parser found '$num_args' parameter but '$num_params' @param[eter] tags. You should update the @param[eter] list."; - $this->warn->addDocWarning($elfile, "function", $elname, $msg, "mismatch"); - for ($i = $k + 1; $i < $num_params; ++$i) - unset($params[$i]); + /** + * Flag indicating that getModule/getClass was called. + * + * @var boolean + */ + var $flag_get = false; + + /** + * List of all elements of a certain class/module. + * + * The array is used to look up see references + * + * @var array Format: elementlist[ eltype ][ elname ] = true + * @see buildElementlist() + */ + var $elementlist = array(); + + /** + * Adds a suffix to the number like 1st, 2nd and 3th + * + * @param integer $nr number to format + * @return string + * @author Thomas Weinert <[EMAIL PROTECTED]> + */ + function addNumberSuffix($nr) { + + $last_nr = substr($nr, -1, 1); + + switch ($last_nr) { + case 1: + return ($nr . "st"); + break; + + case 2: + return ($nr . "nd"); + break; + + default: + return ($nr . "th"); + } + + } // end func addNumberSuffix + + /** + * Starts the analysing of the raw parsing data. + * + * @access public + * @abstract + */ + function analyse() { + ; + } // end func analyse + + /** + * Handles brother and sister. + * + * @abstract + * @see updateBrotherSisterElements() + */ + function updateBrothersSisters() { + ; + } // end func updateBrothersSisters + + /** + * Updates certain elements that use brother and sister. + * + * @return boolean $ok + */ + function updateBrotherSisterElements() { + return false; + } // end func updateBrotherSisterElements + + /** + * Copies fields from a brother or sister to the current element. + * + * @param array Data of the target element that has a brother/sister tag + * @param array Data of the element that is referenced by brother/sister + */ + function copyBrotherSisterFields($target, $from) { + + reset($from); + while (list($k, $v) = each($from)) + if (!isset($target[$k]) || "" == $target[$k]) + $target[$k] = $v; + + return $target; + } // end func copyBrotherSisterFields + + /** + * Updates the access and return tag values. + * + * @see updateAccessReturnElements(), updateAccessElements() + * @abstract + */ + function updateAccessReturn() { + ; + } // end func updateAccessReturn + + /** + * Updates access and return for certain elements. + * + * This function should only be used to update functions. + * Functions that have the same name as the class (constructors) + * get return void and access public. Functions without + * access get access public and functions without return get return void. + * + * @return boolean $ok + * @see updateAccessReturn() + * @abstract + */ + function updateAccessReturnElements() { + ; + } // end func updateAccessReturnElements + + /** + * Updates access tags. + * + * @see updateAccessReturnElements() + * @abstract + */ + function updateAccessElements() { + ; + } // end func updateAccessElements + + /** + * Compares the param tags with the function head found. + * + * @abstract + */ + function checkFunctionArgs() { + ; + } // end func checkFunctionArgs + + /** + * Looks for undocumented elements and adds a warning if neccessary. + * + * @abstract + */ + function findUndocumented() { + ; + } // end func findUndocumented + + /** + * Checks all see references in the given classes/modulegroup. + * + * @abstract + */ + function checkSee() { + ; + } // end func checkSee + + /** + * Checks see references in the given elementlist. + * + * @abstract + */ + function checkSeeElement() { + ; + } // end func checkSeeElement + + /** + * Build a list of all elemente (functions, variables,...) of a certain +class/module + * + * @abstract + * @see $elementlist + */ + function buildElementlist() { + ; + } // end func buildElementlist + + /** + * Compares the argument list generated from the function head with the param tags +found. + * + * PHPDoc is able to recognize these documentation mistakes: + * - too few or too many param tags + * - name does not match or is missing + * - type does not match or is missing + * - trouble with inherited elements + * + * @param array Function arguments found by the parser + * @param array Paramarray + * @param string Functionname + * @param string Filename + * @param boolean Param tags inherited? + * @return array $params Param array + */ + function checkArgDocs($args, $params, $elname, $elfile, $inherited = false) { + + // "param" contains the information from the @param tags. + $num_args = count($args); + $num_params = count($params); + + // no args? return... + if (0 == $num_args && 0 == $num_params) + return array(); + + // no args but @param used + if (0 == $num_args && $num_params > 0) { + + if (!$inherited) { + + $msg = "Function head shows no parameters, remove all @param tags."; + $this->warn->addDocWarning($elfile, "function", $elname, $msg, +"mismatch"); + + } else { + + if ("void" != $params[0]["type"]) { + + $msg = "The function inherited some parameter documentation from +it's parentclass but PHPDoc could not find + arguments in the function head. Add @param void +to the doc comment to avoid confusion."; + $this->warn->addDocWarning($elfile, "function", $elname, $msg, +"mismatch"); + + } + + } + + return array(); + + } + + // compare the informations from the parser with the @param tags + reset($args); + while (list($k, $arg) = each($args)) { + + if (isset($params[$k])) { + + if ($arg["optional"]) + $params[$k]["default"] = $arg["default"]; + + if (!$inherited) { + + if ("" != $arg["type"] && "" != $params[$k]["type"] && "mixed" != +$params[$k]["type"] && strtolower($arg["type"]) != strtolower($params[$k]["type"])) { + + $type = $arg["type"]; + $msg = sprintf("%s parameter type '%s' does match the the +documented type '%s', possible error consider an update to '@param %s %s %s' or +'@param %s %s', the variable name is optional.", + $this->addNumberSuffix($k + 1), + $arg["name"], + $params[$k]["type"], + $type, + $arg["name"], + (isset($params[$k]["desc"])) ? +$params[$k]["desc"] : "(description)", + $type, + (isset($params[$k]["desc"])) ? +$params[$k]["desc"] : "(description)" + ); + + $this->warn->addDocWarning($elfile, "function", $elname, +$msg, "mismatch"); + + } else if ("" != $params[$k]["type"]) { + + $type = $params[$k]["type"]; + + } else { + + $msg = sprintf('Type missing for the %s parameter, "mixed" +assumed.', $this->addNumberSuffix($k)); + $this->warn->addDocWarning($elfile, "function", $elname, +$msg, "missing"); + $type = "mixed"; + + } + + $params[$k]["type"] = $type; + + } else { + + if ("" != $params[$k]["type"] && strtolower($arg["type"]) != +strtolower($params[$k]["type"])) { + + $type = (""!=$args["type"]) ? $arg["type"] : +$params[$k]["type"]; + $msg = sprintf("Possible documentation error due to inherited +information. + The type of the %s parameter '%s' does not +match the documented type '%s'. + Override the inherited documentation if +neccessary.", + $this->addNumberSuffix($k), + $arg["type"], + $params[$k]["type"] + ); + $this->warn->addDocWarning($elfile, "function", $elname, +$msg, "mismatch"); + + } else if ("" != $params[$k]["type"]) { + + $type = $params[$k]["type"]; + + } else { + + $type = "mixed"; + $msg = sprintf('Type missing for the %d parameter, "mixed" +assumed. Override the inherited documentation if neccessary.', $k); + $this->warn->addDocWarning($elfile, "function", $elname, +$msg, "mismatch"); + + } + + $params[$k]["type"] = $type; + + } + + if ("" != $params[$k]["name"] && $arg["name"] != $params[$k]["name"]) +{ + + $msg = sprintf("%s parameter '%s' does not match the documented +name '%s', update the tag to '@param %s %s %s' or '@param %s %s', the variable name +is optional.", + $this->addNumberSuffix($k+1), + $arg["name"], + $params[$k]["name"], + $type, + $arg["name"], + (isset($params[$k]["desc"])) ? +$params[$k]["desc"] : "(description)", + $type, + (isset($params[$k]["desc"])) ? +$params[$k]["desc"] : "(description)" + ); + + $this->warn->addDocWarning($elfile, "function", $elname, $msg, +"mismatch"); + $params[$k]["name"] = $arg["name"]; + + } else if ("" == $params[$k]["name"]) { + + $params[$k]["name"] = $arg["name"]; + + } + + } else { + + $msg = sprintf("%s parameter '%s' is not documented add '@param %s +[description]' to the end of the @param[eter] list.", + $this->addNumberSuffix($k+1), + $arg["name"], + ("" == $arg["type"]) ? "(object objectname|type)" : +$arg["type"] + ); + + $params[$k]["name"] = $arg["name"]; + $params[$k]["undoc"] = true; + + if ("" != $arg["type"]) + $params[$k]["type"] = $arg["type"]; + + $this->warn->addDocWarning($elfile, "function", $elname, $msg, +"missing"); + } + + } + + // more @params specified than variables where found in the function head, +delete them + if ($num_params > $num_args) { + + $msg = "The parser found '$num_args' parameter but '$num_params' +@param[eter] tags. You should update the @param[eter] list."; + $this->warn->addDocWarning($elfile, "function", $elname, $msg, +"mismatch"); + for ($i = $k + 1; $i < $num_params; ++$i) + unset($params[$i]); - } + } - return $params; - } // end func checkArgDocs + return $params; + } // end func checkArgDocs } // end func PhpdocAnalyser ?> Index: php4/pear/PHPDoc/analyser/PhpdocClassAnalyser.php diff -u php4/pear/PHPDoc/analyser/PhpdocClassAnalyser.php:1.4 php4/pear/PHPDoc/analyser/PhpdocClassAnalyser.php:1.5 --- php4/pear/PHPDoc/analyser/PhpdocClassAnalyser.php:1.4 Sun Dec 3 14:37:36 2000 +++ php4/pear/PHPDoc/analyser/PhpdocClassAnalyser.php Sun Feb 18 07:19:15 2001 @@ -2,552 +2,552 @@ /** * Analyses a class. * -* @version $Id: PhpdocClassAnalyser.php,v 1.4 2000/12/03 22:37:36 uw Exp $ +* @version $Id: PhpdocClassAnalyser.php,v 1.5 2001/02/18 15:19:15 uw Exp $ */ class PhpdocClassAnalyser extends PhpdocAnalyser { - /** - * Class data. - * - * @var array - */ - var $classes = array(); - - /** - * Name of the baseclass of the given classes. - * - * @var string - */ - var $baseclass = ""; - - /** - * Ordered list of all classes. - * - * @var array - */ - var $classlist = array(); - - /** - * List of not inherited elements. - * - * @var array - */ - var $notinherited = array( - "class" => array( - "name" => true, - "extends" => true, - "undoc" => true, - "variables" => true, - "functions" => true, - "consts" => true, - "uses" => true, - "filename" => true, - "subclasses"=> true, - "path" => true, - "baseclass" => true, - "abstract" => true - ), - - "functions" => array( - "name" => true, - "undoc" => true, - "inherited" => true, - "overrides" => true, - "abstract" => true - ), - - "variables" => array( - "name" => true, - "undoc" => true, - "inherited" => true, - "overrides" => true, - "abstract" => true - ), - - "uses" => array( - "name" => true, - "undoc" => true, - "inherited" => true, - "overrides" => true - ), - - "consts" => array( - "name" => true, - "undoc" => true, - "inherited" => true, - "overrides" => true - ) - ); - - - /** - * Puuuh - findUndocumented() needs this. - * - * @var array - * @see findUndocumented() - */ - var $undocumentedFields = array( - "functions" => "function", - "variables" => "variable", - "uses" => "included file", - "consts" => "constant" - ); - - /** - * Sets the class data and the name of the baseclass. - * - * @param array Raw class data from the parser - * @param string Name of the baseclass of the given classes - * @access public - */ - function setClasses($classes, $baseclass) { - - $this->classes = $classes; - $this->baseclass = $baseclass; - - } // end func setClasses - - function analyse() { - - $this->flag_get = false; - - $this->updateAccessReturn(); - $this->updateBrothersSisters(); - $this->checkSee(); - - $this->classlist = array(); - - $this->buildBottomUpClasslist($this->baseclass); - - } // end func analyse - - /** - * Returns an analysed class or false if there're no classes any more. - * - * @return mixed False if there no classes anymore, otherwise an array with - * the data of the class. - * @access public - */ - function getClass() { - - if (!$this->flag_get) { - reset($this->classlist); - $this->flag_get = true; - } - if (list($k, $classname)=each($this->classlist)) { - - if (isset($this->classes[$classname]["path"])) - $this->inheritClassElements($classname); - - $this->checkFunctionArgs($classname); - $this->findUndocumented($classname); - - $class = $this->classes[$classname]; - unset($this->classes[$classname]); - return $class; - - } else { - - return false; - - } - } // end func getClass - - /** - * Looks for undocumented elements in a certain class - * - * @param string Classname - */ - function findUndocumented($classname) { - - $file = $this->classes["filename"]; - if ($this->classes["undoc"]) - $this->warn->addDocWarning($file, "class", $name, "The class is not documented.", "missing"); - - reset($this->undocumentedFields); - while (list($index, $eltype)=each($this->undocumentedFields)) { - if (!isset($this->classes[$index])) - continue; - - reset($this->classes[$index]); - while (list($elname, $data)=each($this->classes[$index])) - if (isset($data["undoc"]) && $data["undoc"]) - $this->warn->addDocWarning($file, $eltype, $elname, "Undocumented element.", "missing"); - - } - - } // end func findUndocumented - - /** - * Checks the function documentation of a certain class. - * - * @param string Classname - */ - function checkFunctionArgs($classname) { - - if (!isset($this->classes[$classname]["functions"])) - return; - - $file = $this->classes[$classname]["filename"]; - - reset($this->classes[$classname]["functions"]); - while (list($fname, $function)=each($this->classes[$classname]["functions"])) { - - $inherited = isset($function["paraminherited"]); - $this->classes[$classname]["functions"][$fname]["params"] = $this->checkArgDocs($function["args"], $function["params"], $fname, $file, $inherited); - unset($this->classes[$classname]["functions"][$fname]["args"]); - - if ($inherited) - unset($this->classes[$classname]["functions"][$fname]["paraminherited"]); - - } - } // end func checkFunctionArgs - - /** - * Builds an internal list of all classes. - * - * The analyser needs an ordered list of all classes - * to inherit information effective. - * - * @param string Name of the class that starts the recursive build process. - * @see $classlist - */ - function buildBottomUpClasslist($classname) { - - if (isset($this->classes[$classname]["subclasses"])) { - - reset($this->classes[$classname]["subclasses"]); - while (list($subclass, $v)=each($this->classes[$classname]["subclasses"])) - $this->buildBottomUpClasslist($subclass); - - $this->classlist[] = $classname; - - } else { - - $this->classlist[] = $classname; - - } - } // end func buildBottomUpClasslist - - /** - * Adds inherited elements to a class. - * - * @param string Classname - * @return boolean $ok - * @see $classes, $notinherited, addInheritedElements() - */ - function inheritClassElements($classname) { - - if (!isset($this->classes[$classname]["path"])) - return false; - - $undoc = $this->classes[$classname]["undoc"]; - - $path = $this->classes[$classname]["path"]; - reset($path); - while (list($k, $parentclass)=each($path)) { - - $this->addInheritedElements($classname, $parentclass, "functions"); - $this->addInheritedElements($classname, $parentclass, "variables"); - $this->addInheritedElements($classname, $parentclass, "consts"); - $this->addInheritedElements($classname, $parentclass, "uses"); - - reset($this->classes[$parentclass]); - while (list($field, $value)=each($this->classes[$parentclass])) - if (!isset($this->notinherited["class"][$field]) && !isset($this->classes[$classname][$field])) - $this->classes[$classname][$field] = $value; - - if ($undoc && !$this->classes[$parentclass]["undoc"]) { - $this->classes[$classname]["docinherited"] = true; - $this->classes[$classname]["undoc"] = false; - $undoc = false; - } - - } - - return true; - } // end func inheritClassElements - - /** - * Adds inherited functions, variables, constants or included files to a class. - * - * @param string Name of the class that inherits the informations. - * @param string Name of the parentclass - * @param string Type of elements inherited: "functions", "variables", "uses", "consts" - * @return boolean $ok - * @see $classes, $notinherited, isUndocumented() - */ - function addInheritedElements($classname, $parentclass, $type) { - - if (!isset($this->classes[$parentclass][$type])) - return false; - - reset($this->classes[$parentclass][$type]); - while (list($elementname, $data)=each($this->classes[$parentclass][$type])) { - - if (!isset($this->classes[$classname][$type][$elementname])) { - - $this->classes[$classname]["inherited"][$type][$parentclass][$elementname] = true; - - } else { - - $this->classes[$classname][$type][$elementname]["overrides"] = $parentclass; - $this->classes[$classname][$type][$elementname]["undoc"] = $this->isUndocumented($parentclass, $type, $elementname); - $this->classes[$classname]["overrides"][$type][$parentclass][$elementname] = true; - - reset($data); - while (list($field, $value)=each($data)) { - - if (!isset($this->classes[$classname][$type][$elementname][$field]) && !isset($this->notinherited[$type][$field])) { - $this->classes[$classname][$type][$elementname][$field] = $value; - if ("params"==$field && "functions"==$type) $this->classes[$classname][$type][$elementname]["paraminherited"] = true; - } - - } - } - - } - - return true; - } // end func addInheritedElements - - /** - * Returns true if the requested element is undocumented and false if it's documented. - * - * The function checks if the element might inherit documentation - * from any parentclass. - * - * @param string Name of the class of the element - * @param string Element type: functions, variables, uses, consts. - * @param string Element name - * @return boolean $ok - */ - function isUndocumented($classname, $type, $elementname) { - - if ( !isset($this->classes[$classname][$type][$elementname]) || $this->classes[$classname][$type][$elementname]["undoc"] || !isset($this->classes[$classname]["path"]) ) - return true; - - $path = $this->classes[$classname]["path"]; - while (list($k, $parentclass)=each($path)) - if ($this->isUndocumented($parentclass, $type, $elementname)) - return true; - - return false; - } // end func isUndocumented - - function updateBrothersSisters() { - - reset($this->classes); - while (list($classname, $data)=each($this->classes)) { - $this->updateBrotherSisterElements($classname, "functions"); - $this->updateBrotherSisterElements($classname, "variables"); - } - - } // end func updateBrothersSisters - - /** - * @param string Name of the class to update - * @param string Elementtype: functions, variables, ... - * @return boolean - */ - function updateBrotherSisterElements($classname, $type) { - - if (!isset($this->classes[$classname][$type])) - return false; - - reset($this->classes[$classname][$type]); - while (list($elementname, $data) = each($this->classes[$classname][$type])) { - - if (isset($data["brother"])) { - - $name = ( "functions" == $type ) ? substr($data["brother"], 0, -2) : substr($data["brother"], 1); - $name = strtolower($name); - - if (!isset($this->classes[$classname][$type][$name])) { - - $this->warn->addDocWarning($this->classes[$classname]["filename"], $type, $elementname, "Brother '$name' is unknown. Tags gets ignored.", "mismatch"); - unset($this->classes[$classname][$type][$elementname]["brother"]); - - } else { - - $this->classes[$classname][$type][$elementname]["brother"] = $name; - $this->classes[$classname][$type][$elementname] = $this->copyBrotherSisterFields($this->classes[$classname][$type][$elementname], $this->classes[$classname][$type][$name]); - - } - - } - - } - - } // end func updateBrotherSisterElements - - function updateAccessReturn() { - - reset($this->classes); - while (list($classname, $data)=each($this->classes)) { - - if (!isset($data["access"])) - $this->classes[$classname]["access"] = "private"; - - $this->updateAccessReturnElements($classname, "functions"); - $this->updateAccessElements($classname, "variables"); - $this->updateAccessElements($classname, "consts"); - - } - - } // end func updateAccessReturn - - /** - * Updates access and return for certain elements. - * - * This function should only be used to update functions. - * Functions that have the same name as the class (constructors) - * get return void and access public. Functions without - * access get access public and functions without return get - * return void. - * - * @param string Classname - * @param string Element type: functions (, variables, consts, uses) - * @return boolean $ok - * @see updateAccessReturn() - */ - function updateAccessReturnElements($classname, $type) { - - if (!isset($this->classes[$classname][$type])) - return false; - - reset($this->classes[$classname][$type]); - while (list($elementname, $data)=each($this->classes[$classname][$type])) { - - if (!isset($data["access"])) - $this->classes[$classname][$type][$elementname]["access"] = ("functions" == $type && strtolower($elementname) == strtolower($classname)) ? "public" : "private"; - - if (!isset($data["return"])) - $this->classes[$classname][$type][$elementname]["return"] = "void"; - else - if ("functions" == $type && $elementname == $classname) { - $this->warn->addDocWarning($this->classes[$classname]["filename"], "functions", $elementname, "The constructor can't have a return value. @return gets ignored.", "mismatch"); - $this->classes[$classname]["functions"][$elementname]["return"] = "void"; - } - - } - - } // end func updateAccessReturnElements - - /** - * Updates access tags. - * - * @param string Classname - * @param string Element type: functions, variables, consts (, uses) - * @see updateAccessReturnElements() - */ - function updateAccessElements($classname, $type) { - - if (!isset($this->classes[$classname][$type])) - return false; - - reset($this->classes[$classname][$type]); - while (list($elementname, $data)=each($this->classes[$classname][$type])) { - - if (!isset($data["access"])) - $this->classes[$classname][$type][$elementname]["access"] = ("functions" == $type && $elementname == $classname) ? "public" : "private"; - - } - - } // end func updateAccessElements - - function checkSee() { - - reset($this->classes); - while (list($classname, $class) = each($this->classes)) { - - $this->buildElementlist($classname); - - if (isset($class["functions"])) - $this->checkSeeElements($class["functions"], $classname, "functions"); - - if (isset($class["variables"])) - $this->checkSeeElements($class["variables"], $classname, "variables"); - - if (isset($class["consts"])) - $this->checkSeeElements($class["consts"], $classname, "consts"); - - if (isset($class["uses"])) - $this->checkSeeElements($class["uses"], $classname, "uses"); - - } - - } // end func checkSee - - /** - * Checks see references in the given element array (functions, variables...) - * - * References to variables and functions within the same class get checked. - * It the references element does not exist, the reference gets deleted and - * a doc warning gets generated. - * - * @param array List of functions, variables,... - * @param string Name of the class that contains the given elements. - * @param string Elementtype: functions, variables, consts, uses. - */ - function checkSeeElements($elements, $classname, $eltype) { - - reset($elements); - while (list($elname, $element) = each($elements)) { - - if (isset($element["see"])) { - - if (isset($element["see"]["var"])) { - - reset($element["see"]["var"]); - while (list($k, $variable) = each($element["see"]["var"])) - if (!isset($this->elementlist["variables"][strtolower($variable["name"])])) { - $this->warn->addDocWarning($this->classes[$classname]["filename"], "variables", $elname, "@see referrs to the variable '" . $variable["name"] . "' which is not defined in the class. Entry gets ignored.", "mismatch"); - unset($this->classes[$classname][$eltype][$elname]["see"]["var"][$k]); - } - - } - - if (isset($element["see"]["function"])) { - - reset($element["see"]["function"]); - while (list($k, $function) = each($element["see"]["function"])) - if (!isset($this->elementlist["functions"][strtolower(substr($function["name"], 0, -2))])) { - $this->warn->addDocWarning($this->classes[$classname]["filename"], "functions", $elname, "@see referrs to the function '" . $function["name"] . "' which is not defined in the class. Entry gets ignored.", "mismatch"); - unset($this->classes[$classname][$eltype][$elname]["see"]["function"][$k]); - } - - } - - } - - } - - } // end func checkSeeElement - - /** - * Builds an array with all elements of a class and saves it to $this->elementlist. - * - * @param string Name of the class to scan. - */ - function buildElementlist($classname) { - - $elements = array(); - $fields = array("functions", "variables", "consts", "uses"); - - reset($fields); - while (list($k, $field) = each($fields)) - if (isset($this->classes[$classname][$field])) { - - reset($this->classes[$classname][$field]); - while (list($element, ) = each($this->classes[$classname][$field])) - $elements[$field][$element] = true; - - } - - $this->elementlist = $elements; - - } // end func buildElementlist + /** + * Class data. + * + * @var array + */ + var $classes = array(); + + /** + * Name of the baseclass of the given classes. + * + * @var string + */ + var $baseclass = ""; + + /** + * Ordered list of all classes. + * + * @var array + */ + var $classlist = array(); + + /** + * List of not inherited elements. + * + * @var array + */ + var $notinherited = array( + "class" => array( + "name" => true, + "extends" => true, + "undoc" => true, + "variables" => true, + "functions" => true, + "consts" => true, + "uses" => true, + "filename" => true, + "subclasses" => true, + "path" => true, + "baseclass" => true, + "abstract" => true + ), + + "functions" => array( + "name" => true, + "undoc" => true, + "inherited" => true, + "overrides" => true, + "abstract" => true + ), + + "variables" => array( + "name" => true, + "undoc" => true, + "inherited" => true, + "overrides" => true, + "abstract" => true + ), + + "uses" => array( + "name" => true, + "undoc" => true, + "inherited" => true, + "overrides" => true + ), + + + + + "consts" => array( + "name" => true, + "undoc" => true, + "inherited" => true, + "overrides" => true + ) + + ); + + + /** + * Puuuh - findUndocumented() needs this. + * + * @var array + * @see findUndocumented() + */ + var $undocumentedFields = array( + "functions" => "function", + "variables" => "variable", + "uses" => "included file", + "consts" => "constant" + ); + + /** + * Sets the class data and the name of the baseclass. + * + * @param array Raw class data from the parser + * @param string Name of the baseclass of the given classes + * @access public + */ + function setClasses($classes, $baseclass) { + + $this->classes = $classes; + $this->baseclass = $baseclass; + + } // end func setClasses + + function analyse() { + + $this->flag_get = false; + + $this->updateAccessReturn(); + $this->updateBrothersSisters(); + $this->checkSee(); + + $this->classlist = array(); + + $this->buildBottomUpClasslist($this->baseclass); + + } // end func analyse + + /** + * Returns an analysed class or false if there're no classes any more. + * + * @return mixed False if there no classes anymore, otherwise an array with + * the data of the class. + * @accesss public + */ + function getClass() { + + if (!$this->flag_get) { + reset($this->classlist); + $this->flag_get = true; + } + if (list($k, $classname) = each($this->classlist)) { + + if (isset($this->classes[$classname]["path"])) + $this->inheritClassElements($classname); + + $this->checkFunctionArgs($classname); + $this->findUndocumented($classname); + + $class = $this->classes[$classname]; + unset($this->classes[$classname]); + return $class; + + } else { + + return false; + + } + } // end func getClass + + /** + * Looks for undocumented elements in a certain class + * + * @param string Classname + */ + function findUndocumented($classname) { + + $file = $this->classes["filename"]; + if ($this->classes["undoc"]) + $this->warn->addDocWarning($file, "class", $name, "The class is not +documented.", "missing"); + + reset($this->undocumentedFields); + while (list($index, $eltype) = each($this->undocumentedFields)) { + if (!isset($this->classes[$index])) + continue; + + reset($this->classes[$index]); + while (list($elname, $data) = each($this->classes[$index])) + if (isset($data["undoc"]) && $data["undoc"]) + $this->warn->addDocWarning($file, $eltype, $elname, "Undocumented +element.", "missing"); + + } + + } // end func findUndocumented + + /** + * Checks the function documentation of a certain class. + * + * @param string Classname + */ + function checkFunctionArgs($classname) { + + if (!isset($this->classes[$classname]["functions"])) + return; + + $file = $this->classes[$classname]["filename"]; + + reset($this->classes[$classname]["functions"]); + while (list($fname, $function) = +each($this->classes[$classname]["functions"])) { + + $inherited = isset($function["paraminherited"]); + $this->classes[$classname]["functions"][$fname]["params"] = +$this->checkArgDocs($function["args"], $function["params"], $fname, $file, +$inherited); + unset($this->classes[$classname]["functions"][$fname]["args"]); + + if ($inherited) + +unset($this->classes[$classname]["functions"][$fname]["paraminherited"]); + + } + } // end func checkFunctionArgs + + /** + * Builds an internal list of all classes. + * + * The analyser needs an ordered list of all classes + * to inherit information effective. + * + * @param string Name of the class that starts the recursive build +process. + * @see $classlist + */ + function buildBottomUpClasslist($classname) { + + if (isset($this->classes[$classname]["subclasses"])) { + + reset($this->classes[$classname]["subclasses"]); + while (list($subclass, $v) = +each($this->classes[$classname]["subclasses"])) + $this->buildBottomUpClasslist($subclass); + + $this->classlist[] = $classname; + + } else { + + $this->classlist[] = $classname; + + } + } // end func buildBottomUpClasslist + + /** + * Adds inherited elements to a class. + * + * @param string Classname + * @return boolean $ok + * @see $classes, $notinherited, addInheritedElements() + */ + function inheritClassElements($classname) { + + if (!isset($this->classes[$classname]["path"])) + return false; + + $undoc = $this->classes[$classname]["undoc"]; + + $path = $this->classes[$classname]["path"]; + reset($path); + while (list($k, $parentclass) = each($path)) { + + $this->addInheritedElements($classname, $parentclass, "functions"); + $this->addInheritedElements($classname, $parentclass, "variables"); + $this->addInheritedElements($classname, $parentclass, "consts"); + $this->addInheritedElements($classname, $parentclass, "uses"); + + reset($this->classes[$parentclass]); + while (list($field, $value) = each($this->classes[$parentclass])) + if (!isset($this->notinherited["class"][$field]) && +!isset($this->classes[$classname][$field])) + $this->classes[$classname][$field] = $value; + + if ($undoc && !$this->classes[$parentclass]["undoc"]) { + $this->classes[$classname]["docinherited"] = true; + $this->classes[$classname]["undoc"] = false; + $undoc = false; + } + + } + + return true; + } // end func inheritClassElements + + /** + * Adds inherited functions, variables, constants or included files to a class. + * + * @param string Name of the class that inherits the informations. + * @param string Name of the parentclass + * @param string Type of elements inherited: "functions", "variables", "uses", +"consts" + * @return boolean $ok + * @see $classes, $notinherited, isUndocumented() + */ + function addInheritedElements($classname, $parentclass, $type) { + + if (!isset($this->classes[$parentclass][$type])) + return false; + + reset($this->classes[$parentclass][$type]); + while (list($elementname, $data) = each($this->classes[$parentclass][$type])) +{ + + if (!isset($this->classes[$classname][$type][$elementname])) { + + +$this->classes[$classname]["inherited"][$type][$parentclass][$elementname] = true; + + + } else { + + $this->classes[$classname][$type][$elementname]["overrides"] = +$parentclass; + $this->classes[$classname][$type][$elementname]["undoc"] = +$this->isUndocumented($parentclass, $type, $elementname); + +$this->classes[$classname]["overrides"][$type][$parentclass][$elementname] = true; + + reset($data); + while (list($field, $value)=each($data)) { + + if +(!isset($this->classes[$classname][$type][$elementname][$field]) && +!isset($this->notinherited[$type][$field])) { + $this->classes[$classname][$type][$elementname][$field] = +$value; + if ("params" == $field && "functions" == $type) +$this->classes[$classname][$type][$elementname]["paraminherited"] = true; + } + + } + } + + } + + return true; + } // end func addInheritedElements + + /** + * Returns true if the requested element is undocumented and false if it's +documented. + * + * The function checks if the element might inherit documentation + * from any parentclass. + * + * @param string Name of the class of the element + * @param string Element type: functions, variables, uses, consts. + * @param string Element name + * @return boolean $ok + */ + function isUndocumented($classname, $type, $elementname) { + + if ( !isset($this->classes[$classname][$type][$elementname]) || +$this->classes[$classname][$type][$elementname]["undoc"] || +!isset($this->classes[$classname]["path"]) ) + return true; + + $path = $this->classes[$classname]["path"]; + while (list($k, $parentclass) = each($path)) + if ($this->isUndocumented($parentclass, $type, $elementname)) + return true; + + return false; + } // end func isUndocumented + + function updateBrothersSisters() { + + reset($this->classes); + while (list($classname, $data) = each($this->classes)) { + $this->updateBrotherSisterElements($classname, "functions"); + $this->updateBrotherSisterElements($classname, "variables"); + } + + } // end func updateBrothersSisters + + /** + * @param string Name of the class to update + * @param string Elementtype: functions, variables, ... + * @return boolean + */ + function updateBrotherSisterElements($classname, $type) { + + if (!isset($this->classes[$classname][$type])) + return false; + + reset($this->classes[$classname][$type]); + while (list($elementname, $data) = each($this->classes[$classname][$type])) { + + if (isset($data["brother"])) { + + $name = ( "functions" == $type ) ? substr($data["brother"], 0, -2) : +substr($data["brother"], 1); + $name = strtolower($name); + + if (!isset($this->classes[$classname][$type][$name])) { + + +$this->warn->addDocWarning($this->classes[$classname]["filename"], $type, +$elementname, "Brother '$name' is unknown. Tags gets ignored.", "mismatch"); + unset($this->classes[$classname][$type][$elementname]["brother"]); + + } else { + + $this->classes[$classname][$type][$elementname]["brother"] = +$name; + $this->classes[$classname][$type][$elementname] = +$this->copyBrotherSisterFields($this->classes[$classname][$type][$elementname], +$this->classes[$classname][$type][$name]); + + } + + } + + } + + } // end func updateBrotherSisterElements + + function updateAccessReturn() { + + reset($this->classes); + while (list($classname, $data) = each($this->classes)) { + + if (!isset($data["access"])) + $this->classes[$classname]["access"] = "private"; + + $this->updateAccessReturnElements($classname, "functions"); + $this->updateAccessElements($classname, "variables"); + $this->updateAccessElements($classname, "consts"); + + } + + } // end func updateAccessReturn + + /** + * Updates access and return for certain elements. + * + * This function should only be used to update functions. + * Functions that have the same name as the class (constructors) + * get return void and access public. Functions without + * access get access public and functions without return get + * return void. + * + * @param string Classname + * @param string Element type: functions (, variables, consts, uses) + * @return boolean $ok + * @see updateAccessReturn() + */ + function updateAccessReturnElements($classname, $type) { + + if (!isset($this->classes[$classname][$type])) + return false; + + reset($this->classes[$classname][$type]); + while (list($elementname, $data) = each($this->classes[$classname][$type])) { + + if (!isset($data["access"])) + $this->classes[$classname][$type][$elementname]["access"] = +("functions" == $type && strtolower($elementname) == strtolower($classname)) ? +"public" : "private"; + + if (!isset($data["return"])) + $this->classes[$classname][$type][$elementname]["return"] = "void"; + else + if ("functions" == $type && $elementname == $classname) { + +$this->warn->addDocWarning($this->classes[$classname]["filename"], "functions", +$elementname, "The constructor can't have a return value. @return gets ignored.", +"mismatch"); + $this->classes[$classname]["functions"][$elementname]["return"] = +"void"; + } + + } + + } // end func updateAccessReturnElements + + /** + * Updates access tags. + * + * @param string Classname + * @param string Element type: functions, variables, consts (, uses) + * @see updateAccessReturnElements() + */ + function updateAccessElements($classname, $type) { + + if (!isset($this->classes[$classname][$type])) + return false; + + reset($this->classes[$classname][$type]); + while (list($elementname, $data) = each($this->classes[$classname][$type])) { + + if (!isset($data["access"])) + $this->classes[$classname][$type][$elementname]["access"] = +("functions" == $type && $elementname == $classname) ? "public" : "private"; + + } + + } // end func updateAccessElements + + function checkSee() { + + reset($this->classes); + while (list($classname, $class) = each($this->classes)) { + + $this->buildElementlist($classname); + + if (isset($class["functions"])) + $this->checkSeeElements($class["functions"], $classname, "functions"); + + if (isset($class["variables"])) + $this->checkSeeElements($class["variables"], $classname, "variables"); + + if (isset($class["consts"])) + $this->checkSeeElements($class["consts"], $classname, "consts"); + + if (isset($class["uses"])) + $this->checkSeeElements($class["uses"], $classname, "uses"); + + } + + } // end func checkSee + + /** + * Checks see references in the given element array (functions, variables...) + * + * References to variables and functions within the same class get checked. + * It the references element does not exist, the reference gets deleted and + * a doc warning gets generated. + * + * @param array List of functions, variables,... + * @param string Name of the class that contains the given elements. + * @param string Elementtype: functions, variables, consts, uses. + */ + function checkSeeElements($elements, $classname, $eltype) { + + reset($elements); + while (list($elname, $element) = each($elements)) { + + if (isset($element["see"])) { + + if (isset($element["see"]["var"])) { + + reset($element["see"]["var"]); + while (list($k, $variable) = each($element["see"]["var"])) + if +(!isset($this->elementlist["variables"][strtolower($variable["name"])])) { + +$this->warn->addDocWarning($this->classes[$classname]["filename"], "variables", +$elname, "@see referrs to the variable '" . $variable["name"] . "' which is not +defined in the class. Entry gets ignored.", "mismatch"); + +unset($this->classes[$classname][$eltype][$elname]["see"]["var"][$k]); + } + + } + + if (isset($element["see"]["function"])) { + + reset($element["see"]["function"]); + while (list($k, $function) = each($element["see"]["function"])) + if +(!isset($this->elementlist["functions"][strtolower(substr($function["name"], 0, +-2))])) { + +$this->warn->addDocWarning($this->classes[$classname]["filename"], "functions", +$elname, "@see referrs to the function '" . $function["name"] . "' which is not +defined in the class. Entry gets ignored.", "mismatch"); + +unset($this->classes[$classname][$eltype][$elname]["see"]["function"][$k]); + } + + } + + } + + } + + } // end func checkSeeElement + + /** + * Builds an array with all elements of a class and saves it to $this->elementlist. + * + * @param string Name of the class to scan. + */ + function buildElementlist($classname) { + + $elements = array(); + $fields = array("functions", "variables", "consts", "uses"); + + reset($fields); + while (list($k, $field) = each($fields)) + if (isset($this->classes[$classname][$field])) { + + reset($this->classes[$classname][$field]); + while (list($element, ) = each($this->classes[$classname][$field])) + $elements[$field][$element] = true; + + } + + $this->elementlist = $elements; + + } // end func buildElementlist } // end class PhpdocClassAnalyser ?> Index: php4/pear/PHPDoc/analyser/PhpdocModuleAnalyser.php diff -u php4/pear/PHPDoc/analyser/PhpdocModuleAnalyser.php:1.4 php4/pear/PHPDoc/analyser/PhpdocModuleAnalyser.php:1.5 --- php4/pear/PHPDoc/analyser/PhpdocModuleAnalyser.php:1.4 Sun Dec 3 14:37:36 2000 +++ php4/pear/PHPDoc/analyser/PhpdocModuleAnalyser.php Sun Feb 18 07:19:15 2001 @@ -2,365 +2,369 @@ /** * Analyses a modulegroup. * -* @version $Id: PhpdocModuleAnalyser.php,v 1.4 2000/12/03 22:37:36 uw Exp $ +* @version $Id: PhpdocModuleAnalyser.php,v 1.5 2001/02/18 15:19:15 uw Exp $ */ class PhpdocModuleAnalyser extends PhpdocAnalyser { - /** - * Module data - * @var array - */ - var $modulegroup = array(); - - /** - * List of all modules in the modulegroup - * @var array - */ - var $modulelist = array(); - - /** - * Puuuh - findUndocumented() needs this. - * @var array - * @see findUndocumented() - */ - var $undocumentedFields = array( - "functions" => "function", - "uses" => "included file", - "consts" => "constant" - ); - - /** - * Sets the data of the modulegroup to analyse. - * - * @param array Raw modulegroup data from the parser. - * @access public - */ - function setModulegroup($modulegroup) { - - $this->modulegroup = $modulegroup; - - } // end func setModulegroup - - function analyse() { - - $this->flag_get = false; - - $this->buildModulelist(); - - $this->updateAccessReturn(); - $this->updateBrothersSisters(); - $this->checkSee(); - - $this->checkFunctionArgs(); - $this->findUndocumented(); - - } // end func analyse - - /** - * Returns a module from the modulegroup or false if there are no more modules. - * - * @return mixed False if there no more modules in the modulegroup otherwise - * an array with the data of a module. - * @access public - */ - function getModule() { - - if (!$this->flag_get) { - reset($this->modulelist); - $this->flag_get = true; - } - - if (list($modulename, $group) = each($this->modulelist)) { - - $module = $this->modulegroup[$group][$modulename]; - unset($this->modulegroup[$group][$modulename]); - return $module; - - } else { - - return false; - - } - - } // end func getModule - - function findUndocumented() { - - reset($this->modulegroup); - while (list($group, $modules) = each($this->modulegroup)) { - - reset($modules); - while (list($name, $module) = each($modules)) { - - reset($this->undocumentedFields); - while (list($index, $eltype) = each($this->undocumentedFields)) { - if (!isset($module[$index])) - continue; - - $file = $module["filename"]; - - reset($module[$index]); - while (list($elname, $data) = each($module[$index])) - if (isset($data["undoc"]) && $data["undoc"]) - $this->warn->addDocWarning($file, $eltype, $elname, "Undocumented element.", "missing"); - } - - } - - } - - } // end func findUndocumented - - function checkFunctionArgs() { - - reset($this->modulegroup); - while (list($group, $modules) = each($this->modulegroup)) { - - reset($modules); - while (list($name, $module) = each($modules)) { - if (!isset($module["functions"])) - continue; - - $file = $module["filename"]; - - reset($module["functions"]); - while (list($fname, $function) = each($module["functions"])) { - $this->modulegroup[$group][$name]["functions"][$fname]["params"] = $this->checkArgDocs($function["args"], $function["params"], $fname, $file, false); - unset($this->modulegroup[$group][$name]["functions"][$fname]["args"]); - } - - } - - } - - } // end func checkFunctionArgs - - /** - * Builds an internal list of all modules in the modulegroup. - * @see $modulelist, $modulegroup - */ - function buildModulelist() { - - $this->modulelist = array(); - - reset($this->modulegroup); - while (list($group, $modules) = each($this->modulegroup)) { - - reset($modules); - while (list($modulename, $data) = each($modules)) - $this->modulelist[$modulename] = $group; - - } - - } - - - function updateBrothersSisters() { - - reset($this->modulelist); - while (list($modulename, $group) = each($this->modulelist)) { - $this->updateBrotherSisterElements($group, $modulename, "functions"); - $this->updateBrotherSisterElements($group, $modulename, "variables"); - } - - } // end func updateBrothersSisters - - /** - * @param string Modulegroupname - * @param string Modulename - * @param string Elementtype: functions, variables. - * @return boolean - */ - function updateBrotherSisterElements($group, $modulename, $type) { - - if (!isset($this->modulegroup[$group][$modulename][$type])) - return false; - - reset($this->modulegroup[$group][$modulename][$type]); - while (list($elementname, $data) = each($this->modulegroup[$group][$modulename][$type])) { - - if (isset($data["brother"])) { - - $name = ("functions" == $type) ? substr($data["brother"], 0, -2) : substr($data["brother"], 1); - $name = strtolower($name); - - if (!isset($this->modulegroup[$group][$modulename][$type][$name])) { - - $this->warn->addDocWarning($this->modulegroup[$group][$modulename]["filename"], $type, $elementname, "Brother '$name' is unknown. Tags gets ignored.", "mismatch"); - unset($this->modulegroup[$group][$modulename][$type][$elementname]["brother"]); - - } else { - - $this->modulegroup[$group][$modulename][$type][$elementname]["brother"] = $name; - $this->modulegroup[$group][$modulename][$type][$elementname] = $this->copyBrotherSisterFields($this->modulegroup[$group][$modulename][$type][$elementname], $this->modulegroup[$group][$modulename][$type][$name]); - - } - - } - - } - - } // end func updateBrotherSistersElements - - function updateAccessReturn() { - - reset($this->modulelist); - while (list($modulename, $group) = each($this->modulelist)) { - - if (!isset($this->modulegroup[$group][$modulename]["access"])) - $this->modulegroup[$group][$modulename]["access"] = "private"; - - $this->updateAccessReturnElements($group, $modulename, "functions"); - $this->updateAccessReturnElements($group, $modulename, "variables"); - $this->updateAccessElements($group, $modulename, "consts"); - - } - - } // end func updateAccessReturn - - /** - * @param string Modulegroup - * @param string Modulename - * @param string Elementtype: functions, variables, consts. - * @return boolean - */ - function updateAccessReturnElements($group, $modulename, $type) { - - if (!isset($this->modulegroup[$group][$modulename][$type])) - return false; - - reset($this->modulegroup[$group][$modulename][$type]); - while (list($elementname, $data) = each($this->modulegroup[$group][$modulename][$type])) { - - if (!isset($data["access"])) - $this->modulegroup[$group][$modulename][$type][$elementname]["access"] = "private"; - - if (!isset($data["return"])) - $this->modulegroup[$group][$modulename][$type][$elementname]["return"] = "void"; - - } - - } // end func updateAccessReturnElements - - /** - * @param string Modulegroup - * @param string Modulename - * @param string Elementtype: functions, variables, consts. - * @return boolean - */ - function updateAccessElements($group, $modulename, $type) { - - if (!isset($this->modulegroup[$group][$modulename][$type])) - return false; - - reset($this->modulegroup[$group][$modulename][$type]); - while (list($elementname, $data) = each($this->modulegroup[$group][$modulename][$type])) { - - if (!isset($data["access"])) - $this->modulegroup[$group][$modulename][$type][$elementname]["access"] = "private"; - - } - - } // end func updateAccessElements - - function checkSee() { - - reset($this->modulegroup); - while (list($group, $modules) = each($this->modulegroup)) { - - while (list($modulename, $module) = each($modules)) { - - $this->buildElementlist($group, $modulename); - - if (isset($module["functions"])) - $this->checkSeeElements($module["functions"], $group, $modulename, "functions"); - - if (isset($module["variables"])) - $this->checkSeeElements($module["variables"], $group, $modulename, "variables"); - - if (isset($module["consts"])) - $this->checkSeeElements($module["consts"], $group, $modulename, "consts"); - - if (isset($module["uses"])) - $this->checkSeeElements($module["uses"], $group, $modulename, "uses"); - - } - - } - - } // end func checkSee - - /** - * Checks see references in the given element array (functions, variables...) - * - * References to variables and functions within the same module get checked. - * It the references element does not exist, the reference gets deleted and - * a doc warning gets generated. - * - * @param array List of functions, variables,... - * @param string Name of the modulegroup that contains the given elements. - * @param string Name of the module that contains the given elements. - * @param string Elementtype: functions, variables, consts, uses. - */ - function checkSeeElements($elements, $modulegroup, $modulename, $eltype) { - - reset($elements); - while (list($elname, $element) = each($elements)) { - - if (isset($element["see"])) { - - if (isset($element["see"]["var"])) { - - reset($element["see"]["var"]); - while (list($k, $variable) = each($element["see"]["var"])) - if (!isset($this->elementlist["variables"][strtolower($variable["name"])])) { - $this->warn->addDocWarning($this->modulegroup[$modulegroup][$modulename]["filename"], "variables", $elname, "@see referrs to the variable '" . $variable["name"] . "' which is not defined in the class. Entry gets ignored.", "mismatch"); - unset($this->modulegroup[$modulegroup][$modulename][$eltype][$elname]["see"]["var"][$k]); - } - - } - - if (isset($element["see"]["function"])) { - - reset($element["see"]["function"]); - while (list($k, $function) = each($element["see"]["function"])) - if (!isset($this->elementlist["functions"][strtolower(substr($function["name"], 0, -2))])) { - $this->warn->addDocWarning($this->modulegroup[$modulename]["filename"], "functions", $elname, "@see referrs to the function '" . $function["name"] . "' which is not defined in the class. Entry gets ignored.", "mismatch"); - unset($this->modulegroup[$modulegroup][$modulename][$eltype][$elname]["see"]["function"][$k]); - } - - } - - } - - } - - } // end func checkSeeElement - - /** - * Builds an array with all elements of a class and saves it to $this->elementlist. - * - * @param string Name of the modulegroup that contains the module. - * @param string Name of the module to scan. - */ - function buildElementlist($modulegroup, $modulename) { - - $elements = array(); - $fields = array("functions", "variables", "consts", "uses"); - - reset($fields); - while (list($k, $field) = each($fields)) - if (isset($this->modulegroup[$modulegroup][$modulename][$field])) { - - reset($this->modulegroup[$modulegroup][$modulename][$field]); - while (list($element, ) = each($this->modulegroup[$modulegroup][$modulename][$field])) - $elements[$field][$element] = true; - - } - - $this->elementlist = $elements; - - } // end func buildElementlist - + /** + * Module data + * + * @var array + */ + var $modulegroup = array(); + + /** + * List of all modules in the modulegroup + * + * @var array + */ + var $modulelist = array(); + + /** + * Puuuh - findUndocumented() needs this. + * + * @var array + * @see findUndocumented() + */ + var $undocumentedFields = array( + "functions" => "function", + "uses" => "included file", + "consts" => "constant" + ); + + /** + * Sets the data of the modulegroup to analyse. + * + * @param array Raw modulegroup data from the parser. + * @access public + */ + function setModulegroup($modulegroup) { + + $this->modulegroup = $modulegroup; + + } // end func setModulegroup + + function analyse() { + + $this->flag_get = false; + + $this->buildModulelist(); + + $this->updateAccessReturn(); + $this->updateBrothersSisters(); + $this->checkSee(); + + $this->checkFunctionArgs(); + $this->findUndocumented(); + + } // end func analyse + + /** + * Returns a module from the modulegroup or false if there are no more modules. + * + * @return mixed False if there no more modules in the modulegroup otherwise + * an array with the data of a module. + * @access public + */ + function getModule() { + + if (!$this->flag_get) { + reset($this->modulelist); + $this->flag_get = true; + } + + if (list($modulename, $group) = each($this->modulelist)) { + + $module = $this->modulegroup[$group][$modulename]; + unset($this->modulegroup[$group][$modulename]); + return $module; + + } else { + + return false; + + } + + } // end func getModule + + function findUndocumented() { + + reset($this->modulegroup); + while (list($group, $modules) = each($this->modulegroup)) { + + reset($modules); + while (list($name, $module) = each($modules)) { + + reset($this->undocumentedFields); + while (list($index, $eltype) = each($this->undocumentedFields)) { + if (!isset($module[$index])) + continue; + + $file = $module["filename"]; + + reset($module[$index]); + while (list($elname, $data) = each($module[$index])) + if (isset($data["undoc"]) && $data["undoc"]) + $this->warn->addDocWarning($file, $eltype, $elname, +"Undocumented element.", "missing"); + } + + } + + } + + } // end func findUndocumented + + function checkFunctionArgs() { + + reset($this->modulegroup); + while (list($group, $modules) = each($this->modulegroup)) { + + reset($modules); + while (list($name, $module) = each($modules)) { + if (!isset($module["functions"])) + continue; + + $file = $module["filename"]; + + reset($module["functions"]); + while (list($fname, $function) = each($module["functions"])) { + $this->modulegroup[$group][$name]["functions"][$fname]["params"] += $this->checkArgDocs($function["args"], $function["params"], $fname, $file, false); + +unset($this->modulegroup[$group][$name]["functions"][$fname]["args"]); + } + + } + + } + + } // end func checkFunctionArgs + + /** + * Builds an internal list of all modules in the modulegroup. + * + * @see $modulelist, $modulegroup + */ + function buildModulelist() { + + $this->modulelist = array(); + + reset($this->modulegroup); + while (list($group, $modules) = each($this->modulegroup)) { + + reset($modules); + while (list($modulename, $data) = each($modules)) + $this->modulelist[$modulename] = $group; + + } + + } + + + function updateBrothersSisters() { + + reset($this->modulelist); + while (list($modulename, $group) = each($this->modulelist)) { + $this->updateBrotherSisterElements($group, $modulename, "functions"); + $this->updateBrotherSisterElements($group, $modulename, "variables"); + } + + } // end func updateBrothersSisters + + /** + * @param string Modulegroupname + * @param string Modulename + * @param string Elementtype: functions, variables. + * @return boolean + */ + function updateBrotherSisterElements($group, $modulename, $type) { + + if (!isset($this->modulegroup[$group][$modulename][$type])) + return false; + + reset($this->modulegroup[$group][$modulename][$type]); + while (list($elementname, $data) = +each($this->modulegroup[$group][$modulename][$type])) { + + if (isset($data["brother"])) { + + $name = ("functions" == $type) ? substr($data["brother"], 0, -2) : +substr($data["brother"], 1); + $name = strtolower($name); + + if (!isset($this->modulegroup[$group][$modulename][$type][$name])) { + + +$this->warn->addDocWarning($this->modulegroup[$group][$modulename]["filename"], +$type, $elementname, "Brother '$name' is unknown. Tags gets ignored.", "mismatch"); + +unset($this->modulegroup[$group][$modulename][$type][$elementname]["brother"]); + + } else { + + +$this->modulegroup[$group][$modulename][$type][$elementname]["brother"] = $name; + $this->modulegroup[$group][$modulename][$type][$elementname] = +$this->copyBrotherSisterFields($this->modulegroup[$group][$modulename][$type][$elementname], + $this->modulegroup[$group][$modulename][$type][$name]); + + } + + } + + } + + } // end func updateBrotherSistersElements + + function updateAccessReturn() { + + reset($this->modulelist); + while (list($modulename, $group) = each($this->modulelist)) { + + if (!isset($this->modulegroup[$group][$modulename]["access"])) + $this->modulegroup[$group][$modulename]["access"] = "private"; + + $this->updateAccessReturnElements($group, $modulename, "functions"); + $this->updateAccessReturnElements($group, $modulename, "variables"); + $this->updateAccessElements($group, $modulename, "consts"); + + } + + } // end func updateAccessReturn + + /** + * @param string Modulegroup + * @param string Modulename + * @param string Elementtype: functions, variables, consts. + * @return boolean + */ + function updateAccessReturnElements($group, $modulename, $type) { + + if (!isset($this->modulegroup[$group][$modulename][$type])) + return false; + + reset($this->modulegroup[$group][$modulename][$type]); + while (list($elementname, $data) = +each($this->modulegroup[$group][$modulename][$type])) { + + if (!isset($data["access"])) + +$this->modulegroup[$group][$modulename][$type][$elementname]["access"] = "private"; + + if (!isset($data["return"])) + +$this->modulegroup[$group][$modulename][$type][$elementname]["return"] = "void"; + + } + + } // end func updateAccessReturnElements + + /** + * @param string Modulegroup + * @param string Modulename + * @param string Elementtype: functions, variables, consts. + * @return boolean + */ + function updateAccessElements($group, $modulename, $type) { + + if (!isset($this->modulegroup[$group][$modulename][$type])) + return false; + + reset($this->modulegroup[$group][$modulename][$type]); + while (list($elementname, $data) = +each($this->modulegroup[$group][$modulename][$type])) { + + if (!isset($data["access"])) + +$this->modulegroup[$group][$modulename][$type][$elementname]["access"] = "private"; + + } + + } // end func updateAccessElements + + function checkSee() { + + reset($this->modulegroup); + while (list($group, $modules) = each($this->modulegroup)) { + + while (list($modulename, $module) = each($modules)) { + + $this->buildElementlist($group, $modulename); + + if (isset($module["functions"])) + $this->checkSeeElements($module["functions"], $group, +$modulename, "functions"); + + if (isset($module["variables"])) + $this->checkSeeElements($module["variables"], $group, +$modulename, "variables"); + + if (isset($module["consts"])) + $this->checkSeeElements($module["consts"], $group, $modulename, +"consts"); + + if (isset($module["uses"])) + $this->checkSeeElements($module["uses"], $group, $modulename, +"uses"); + + } + + } + + } // end func checkSee + + /** + * Checks see references in the given element array (functions, variables...) + * + * References to variables and functions within the same module get checked. + * It the references element does not exist, the reference gets deleted and + * a doc warning gets generated. + * + * @param array List of functions, variables,... + * @param string Name of the modulegroup that contains the given elements. + * @param string Name of the module that contains the given elements. + * @param string Elementtype: functions, variables, consts, uses. + */ + function checkSeeElements($elements, $modulegroup, $modulename, $eltype) { + + reset($elements); + while (list($elname, $element) = each($elements)) { + + if (isset($element["see"])) { + + if (isset($element["see"]["var"])) { + + reset($element["see"]["var"]); + while (list($k, $variable) = each($element["see"]["var"])) + if +(!isset($this->elementlist["variables"][strtolower($variable["name"])])) { + +$this->warn->addDocWarning($this->modulegroup[$modulegroup][$modulename]["filename"], +"variables", $elname, "@see referrs to the variable '" . $variable["name"] . "' which +is not defined in the class. Entry gets ignored.", "mismatch"); + +unset($this->modulegroup[$modulegroup][$modulename][$eltype][$elname]["see"]["var"][$k]); + } + + } + + if (isset($element["see"]["function"])) { + + reset($element["see"]["function"]); + while (list($k, $function) = each($element["see"]["function"])) + if +(!isset($this->elementlist["functions"][strtolower(substr($function["name"], 0, +-2))])) { + +$this->warn->addDocWarning($this->modulegroup[$modulename]["filename"], "functions", +$elname, "@see referrs to the function '" . $function["name"] . "' which is not +defined in the class. Entry gets ignored.", "mismatch"); + +unset($this->modulegroup[$modulegroup][$modulename][$eltype][$elname]["see"]["function"][$k]); + } + + } + + } + + } + + } // end func checkSeeElement + + /** + * Builds an array with all elements of a class and saves it to $this->elementlist. + * + * @param string Name of the modulegroup that contains the module. + * @param string Name of the module to scan. + */ + function buildElementlist($modulegroup, $modulename) { + + $elements = array(); + $fields = array("functions", "variables", "consts", "uses"); + + reset($fields); + while (list($k, $field) = each($fields)) + if (isset($this->modulegroup[$modulegroup][$modulename][$field])) { + + reset($this->modulegroup[$modulegroup][$modulename][$field]); + while (list($element, ) = +each($this->modulegroup[$modulegroup][$modulename][$field])) + $elements[$field][$element] = true; + + } + + $this->elementlist = $elements; + + } // end func buildElementlist + } // end class PhpdocModuleAnalyser ?>
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]