[ Index ]

PHP Cross Reference of phpBB-3.3.2-deutsch

title

Body

[close]

/vendor/zendframework/zend-code/src/Reflection/ -> ParameterReflection.php (source)

   1  <?php
   2  /**
   3   * Zend Framework (http://framework.zend.com/)
   4   *
   5   * @link      http://github.com/zendframework/zf2 for the canonical source repository
   6   * @copyright Copyright (c) 2005-2016 Zend Technologies USA Inc. (http://www.zend.com)
   7   * @license   http://framework.zend.com/license/new-bsd New BSD License
   8   */
   9  
  10  namespace Zend\Code\Reflection;
  11  
  12  use ReflectionParameter;
  13  
  14  use function method_exists;
  15  
  16  class ParameterReflection extends ReflectionParameter implements ReflectionInterface
  17  {
  18      /**
  19       * @var bool
  20       */
  21      protected $isFromMethod = false;
  22  
  23      /**
  24       * Get declaring class reflection object
  25       *
  26       * @return ClassReflection
  27       */
  28      public function getDeclaringClass()
  29      {
  30          $phpReflection  = parent::getDeclaringClass();
  31          $zendReflection = new ClassReflection($phpReflection->getName());
  32          unset($phpReflection);
  33  
  34          return $zendReflection;
  35      }
  36  
  37      /**
  38       * Get class reflection object
  39       *
  40       * @return null|ClassReflection
  41       */
  42      public function getClass()
  43      {
  44          $phpReflection = parent::getClass();
  45          if ($phpReflection === null) {
  46              return null;
  47          }
  48  
  49          $zendReflection = new ClassReflection($phpReflection->getName());
  50          unset($phpReflection);
  51  
  52          return $zendReflection;
  53      }
  54  
  55      /**
  56       * Get declaring function reflection object
  57       *
  58       * @return FunctionReflection|MethodReflection
  59       */
  60      public function getDeclaringFunction()
  61      {
  62          $phpReflection = parent::getDeclaringFunction();
  63          if ($phpReflection instanceof \ReflectionMethod) {
  64              $zendReflection = new MethodReflection($this->getDeclaringClass()->getName(), $phpReflection->getName());
  65          } else {
  66              $zendReflection = new FunctionReflection($phpReflection->getName());
  67          }
  68          unset($phpReflection);
  69  
  70          return $zendReflection;
  71      }
  72  
  73      /**
  74       * Get parameter type
  75       *
  76       * @return string|null
  77       */
  78      public function detectType()
  79      {
  80          if (method_exists($this, 'getType')
  81              && ($type = $this->getType())
  82              && $type->isBuiltin()
  83          ) {
  84              return $type->getName();
  85          }
  86  
  87          // can be dropped when dropping PHP7 support:
  88          if ($this->isArray()) {
  89              return 'array';
  90          }
  91  
  92          // can be dropped when dropping PHP7 support:
  93          if ($this->isCallable()) {
  94              return 'callable';
  95          }
  96  
  97          if (($class = $this->getClass()) instanceof \ReflectionClass) {
  98              return $class->getName();
  99          }
 100  
 101          $docBlock = $this->getDeclaringFunction()->getDocBlock();
 102  
 103          if (! $docBlock instanceof DocBlockReflection) {
 104              return null;
 105          }
 106  
 107          $params = $docBlock->getTags('param');
 108  
 109          if (isset($params[$this->getPosition()])) {
 110              return $params[$this->getPosition()]->getType();
 111          }
 112  
 113          return null;
 114      }
 115  
 116      /**
 117       * @return string
 118       */
 119      public function toString()
 120      {
 121          return parent::__toString();
 122      }
 123  
 124      /**
 125       * @return string
 126       */
 127      public function __toString()
 128      {
 129          return parent::__toString();
 130      }
 131  }


Generated: Wed Nov 11 20:28:18 2020 Cross-referenced by PHPXref 0.7.1