[ Index ]

PHP Cross Reference of moodle-2.8

title

Body

[close]

/lib/zend/Zend/Server/ -> Reflection.php (source)

   1  <?php
   2  /**
   3   * Zend Framework
   4   *
   5   * LICENSE
   6   *
   7   * This source file is subject to the new BSD license that is bundled
   8   * with this package in the file LICENSE.txt.
   9   * It is also available through the world-wide-web at this URL:
  10   * http://framework.zend.com/license/new-bsd
  11   * If you did not receive a copy of the license and are unable to
  12   * obtain it through the world-wide-web, please send an email
  13   * to [email protected] so we can send you a copy immediately.
  14   *
  15   * @category   Zend
  16   * @package    Zend_Server
  17   * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  18   * @license    http://framework.zend.com/license/new-bsd     New BSD License
  19   */
  20  
  21  /**
  22   * Zend_Server_Reflection_Function
  23   */
  24  require_once 'Zend/Server/Reflection/Function.php';
  25  
  26  /**
  27   * Zend_Server_Reflection_Class
  28   */
  29  require_once 'Zend/Server/Reflection/Class.php';
  30  
  31  /**
  32   * Reflection for determining method signatures to use with server classes
  33   *
  34   * @category   Zend
  35   * @package    Zend_Server
  36   * @subpackage Reflection
  37   * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  38   * @license    http://framework.zend.com/license/new-bsd     New BSD License
  39   * @version $Id$
  40   */
  41  class Zend_Server_Reflection
  42  {
  43      /**
  44       * Perform class reflection to create dispatch signatures
  45       *
  46       * Creates a {@link Zend_Server_Reflection_Class} object for the class or
  47       * object provided.
  48       *
  49       * If extra arguments should be passed to dispatchable methods, these may
  50       * be provided as an array to $argv.
  51       *
  52       * @param string|object $class Class name or object
  53       * @param null|array $argv Optional arguments to be used during the method call
  54       * @param string $namespace Optional namespace with which to prefix the
  55       * method name (used for the signature key). Primarily to avoid collisions,
  56       * also for XmlRpc namespacing
  57       * @return Zend_Server_Reflection_Class
  58       * @throws Zend_Server_Reflection_Exception
  59       */
  60      public static function reflectClass($class, $argv = false, $namespace = '')
  61      {
  62          if (is_object($class)) {
  63              $reflection = new ReflectionObject($class);
  64          } elseif (class_exists($class)) {
  65              $reflection = new ReflectionClass($class);
  66          } else {
  67              require_once 'Zend/Server/Reflection/Exception.php';
  68              throw new Zend_Server_Reflection_Exception('Invalid class or object passed to attachClass()');
  69          }
  70  
  71          if ($argv && !is_array($argv)) {
  72              require_once 'Zend/Server/Reflection/Exception.php';
  73              throw new Zend_Server_Reflection_Exception('Invalid argv argument passed to reflectClass');
  74          }
  75  
  76          return new Zend_Server_Reflection_Class($reflection, $namespace, $argv);
  77      }
  78  
  79      /**
  80       * Perform function reflection to create dispatch signatures
  81       *
  82       * Creates dispatch prototypes for a function. It returns a
  83       * {@link Zend_Server_Reflection_Function} object.
  84       *
  85       * If extra arguments should be passed to the dispatchable function, these
  86       * may be provided as an array to $argv.
  87       *
  88       * @param string $function Function name
  89       * @param null|array $argv Optional arguments to be used during the method call
  90       * @param string $namespace Optional namespace with which to prefix the
  91       * function name (used for the signature key). Primarily to avoid
  92       * collisions, also for XmlRpc namespacing
  93       * @return Zend_Server_Reflection_Function
  94       * @throws Zend_Server_Reflection_Exception
  95       */
  96      public static function reflectFunction($function, $argv = false, $namespace = '')
  97      {
  98          if (!is_string($function) || !function_exists($function)) {
  99              require_once 'Zend/Server/Reflection/Exception.php';
 100              throw new Zend_Server_Reflection_Exception('Invalid function "' . $function . '" passed to reflectFunction');
 101          }
 102  
 103  
 104          if ($argv && !is_array($argv)) {
 105              require_once 'Zend/Server/Reflection/Exception.php';
 106              throw new Zend_Server_Reflection_Exception('Invalid argv argument passed to reflectClass');
 107          }
 108  
 109          return new Zend_Server_Reflection_Function(new ReflectionFunction($function), $namespace, $argv);
 110      }
 111  }


Generated: Fri Nov 28 20:29:05 2014 Cross-referenced by PHPXref 0.7.1