web/lib/Zend/Server/Reflection/Method.php
changeset 64 162c1de6545a
parent 19 1c2f13fd785c
child 68 ecaf28ffe26e
equal deleted inserted replaced
63:5b37998e522e 64:162c1de6545a
       
     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 license@zend.com 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_Abstract
       
    23  */
       
    24 require_once 'Zend/Server/Reflection/Function/Abstract.php';
       
    25 
       
    26 /**
       
    27  * Method Reflection
       
    28  *
       
    29  * @uses       Zend_Server_Reflection_Function_Abstract
       
    30  * @category   Zend
       
    31  * @package    Zend_Server
       
    32  * @subpackage Reflection
       
    33  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
       
    34  * @license    http://framework.zend.com/license/new-bsd     New BSD License
       
    35  * @version $Id: Method.php 20096 2010-01-06 02:05:09Z bkarwin $
       
    36  */
       
    37 class Zend_Server_Reflection_Method extends Zend_Server_Reflection_Function_Abstract
       
    38 {
       
    39     /**
       
    40      * Parent class name
       
    41      * @var string
       
    42      */
       
    43     protected $_class;
       
    44 
       
    45     /**
       
    46      * Parent class reflection
       
    47      * @var Zend_Server_Reflection_Class
       
    48      */
       
    49     protected $_classReflection;
       
    50 
       
    51     /**
       
    52      * Constructor
       
    53      *
       
    54      * @param Zend_Server_Reflection_Class $class
       
    55      * @param ReflectionMethod $r
       
    56      * @param string $namespace
       
    57      * @param array $argv
       
    58      * @return void
       
    59      */
       
    60     public function __construct(Zend_Server_Reflection_Class $class, ReflectionMethod $r, $namespace = null, $argv = array())
       
    61     {
       
    62         $this->_classReflection = $class;
       
    63         $this->_reflection      = $r;
       
    64 
       
    65         $classNamespace = $class->getNamespace();
       
    66 
       
    67         // Determine namespace
       
    68         if (!empty($namespace)) {
       
    69             $this->setNamespace($namespace);
       
    70         } elseif (!empty($classNamespace)) {
       
    71             $this->setNamespace($classNamespace);
       
    72         }
       
    73 
       
    74         // Determine arguments
       
    75         if (is_array($argv)) {
       
    76             $this->_argv = $argv;
       
    77         }
       
    78 
       
    79         // If method call, need to store some info on the class
       
    80         $this->_class = $class->getName();
       
    81 
       
    82         // Perform some introspection
       
    83         $this->_reflect();
       
    84     }
       
    85 
       
    86     /**
       
    87      * Return the reflection for the class that defines this method
       
    88      *
       
    89      * @return Zend_Server_Reflection_Class
       
    90      */
       
    91     public function getDeclaringClass()
       
    92     {
       
    93         return $this->_classReflection;
       
    94     }
       
    95 
       
    96     /**
       
    97      * Wakeup from serialization
       
    98      *
       
    99      * Reflection needs explicit instantiation to work correctly. Re-instantiate
       
   100      * reflection object on wakeup.
       
   101      *
       
   102      * @return void
       
   103      */
       
   104     public function __wakeup()
       
   105     {
       
   106         $this->_classReflection = new Zend_Server_Reflection_Class(new ReflectionClass($this->_class), $this->getNamespace(), $this->getInvokeArguments());
       
   107         $this->_reflection = new ReflectionMethod($this->_classReflection->getName(), $this->getName());
       
   108     }
       
   109 
       
   110 }