QA_Peardoc_Coverage
[ class tree: QA_Peardoc_Coverage ] [ index: QA_Peardoc_Coverage ] [ all elements ]

Source for file MethodList.php

Documentation is available at MethodList.php

  1. <?php
  2. require_once 'QA/Peardoc/Coverage/ClassList.php';
  3.  
  4. /**
  5. * Returns a method list for the class
  6. * defined in the given filename.
  7. *
  8. @category QA
  9. @package  QA_Peardoc_Coverage
  10. @author   Christian Weiske <cweiske@php.net>
  11. @license  http://www.gnu.org/copyleft/lesser.html  LGPL License 2.1
  12. @version  CVS: $Id: MethodList.php,v 1.4 2007/07/18 18:52:44 cweiske Exp $
  13. @link     http://pear.php.net/package/QA_Peardoc_Coverage
  14. */
  15. {
  16.     /**
  17.     * Returns a class => method list for the classes
  18.     * defined in the given filename.
  19.     *
  20.     * @param string $strClassFile Path of a .php file to load
  21.     *
  22.     * @return array Array with classname => methods => bool array
  23.     */
  24.     public static function getMethods($strClassFile)
  25.     {
  26.         if (!file_exists($strClassFile)) {
  27.             throw new Exception('File does not exist: ' $strClassFile);
  28.         else if (!function_exists('token_get_all')) {
  29.             throw new Exception('Please compile php with tokenizer enabled.');
  30.         }
  31.  
  32.         $arClassnames = QA_Peardoc_Coverage_ClassList::getClassnamesFromFilename($strClassFile);
  33.  
  34.         if (count($arClassnames== 0{
  35.             return array();
  36.         }
  37.  
  38.         $bWaitForClassname  = false;
  39.         $bWaitForMethodname = false;
  40.         $arMethods          = array();
  41.         $strClassName       '*funcs*';
  42.         foreach (
  43.             token_get_all(
  44.                 file_get_contents($strClassFile)
  45.             )
  46.             as $token
  47.         {
  48.             if (!is_string($token)) {
  49.                 list($nId$strText$token;
  50.                 if ($nId == T_CLASS{
  51.                     $bWaitForClassname = true;
  52.                 else if ($nId == T_FUNCTION{
  53.                     $bWaitForMethodname = true;
  54.                 else if ($bWaitForClassname && $nId == T_STRING{
  55.                     //classname found
  56.                     $strClassName             $strText;
  57.                     $arMethods[$strClassName= array();
  58.                     $bWaitForClassname        = false;
  59.                 else if ($bWaitForMethodname && $nId == T_STRING{
  60.                     //methodname found
  61.                     $strMethodname $strText;
  62.                     //FIXME: check if docblock
  63.                     //FIXME: use public methods only
  64.                     $arMethods[$strClassName][$strMethodname= false;
  65.                     $bWaitForMethodname                       = false;
  66.                 }
  67.             }
  68.         }
  69.  
  70.         return $arMethods;
  71.     }//public static function getMethods($strClassFile)
  72.  
  73. }//class QA_Peardoc_Coverage_MethodList
  74. ?>

Documentation generated on Mon, 11 Mar 2019 15:10:40 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.