当前位置: 首页>>代码示例>>PHP>>正文


PHP ReflectionParameter::__toString方法代码示例

本文整理汇总了PHP中ReflectionParameter::__toString方法的典型用法代码示例。如果您正苦于以下问题:PHP ReflectionParameter::__toString方法的具体用法?PHP ReflectionParameter::__toString怎么用?PHP ReflectionParameter::__toString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ReflectionParameter的用法示例。


在下文中一共展示了ReflectionParameter::__toString方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 public function __construct(ReflectionParameter $param)
 {
     if (method_exists('ReflectionParameter', 'getType')) {
         if ($type = $param->getType()) {
             $this->type_hint = (string) $type;
         }
     } else {
         if ($param->isArray()) {
             $this->type_hint = 'array';
         } else {
             try {
                 if ($this->type_hint = $param->getClass()) {
                     $this->type_hint = $this->type_hint->name;
                 }
             } catch (ReflectionException $e) {
                 preg_match('/\\[\\s\\<\\w+?>\\s([\\w]+)/s', $param->__toString(), $matches);
                 $this->type_hint = isset($matches[1]) ? $matches[1] : '';
             }
         }
     }
     $this->reference = $param->isPassedByReference();
     $this->position = $param->getPosition();
     $this->name = $param->getName();
     if ($param->isDefaultValueAvailable()) {
         $this->default = var_export($param->getDefaultValue(), true);
     }
 }
开发者ID:jnvsor,项目名称:kint,代码行数:27,代码来源:Parameter.php

示例2: __toString

 /**
  * Returns a string representation
  * @return string
  */
 public function __toString()
 {
     if ($this->parameter) {
         return $this->parameter->__toString();
     } else {
         return parent::__toString();
     }
 }
开发者ID:zetacomponents,项目名称:reflection,代码行数:12,代码来源:parameter.php

示例3: __toString

 /**
  * Representation of the object
  *
  * If an exception is caught, its message is returned instead of the
  * original result (but it is not thrown ahead).
  *
  * @return string
  */
 public function __toString()
 {
     try {
         return parent::__toString() . ' with user value { ' . ReflectionValue::export($this->value, true) . ' }';
     } catch (\Exception $e) {
         return $e->__toString();
     }
 }
开发者ID:atelierspierrot,项目名称:reflectors,代码行数:16,代码来源:ReflectionParameterValue.php

示例4: getParameterType

 /**
  * Returns the type of the parameter. In case the parameter has no type (e.g. primitive) the
  * method returns null. 
  * 
  * @param ReflectionParameter $param
  * @return string
  */
 public static function getParameterType(ReflectionParameter $param)
 {
     $matches = array();
     preg_match('/\\[\\s\\<\\w+?>\\s([\\w]+)/s', $param->__toString(), $matches);
     if (isset($matches[1])) {
         return $matches[1];
     } else {
         return null;
     }
 }
开发者ID:xiaoguizhidao,项目名称:extensiongsd,代码行数:17,代码来源:Reflection.php

示例5: getType

 /**
  * @return ReflectionTypeInterface|null
  */
 public function getType()
 {
     if (PHP_MAJOR_VERSION >= 7) {
         if ($this->hasType()) {
             return new ReflectionType($this->parameter->getType());
         } else {
             return null;
         }
     }
     $type = null;
     preg_match('/\\[\\s<\\w+?>\\s([\\\\\\w]+)/', $this->parameter->__toString(), $matches);
     if (isset($matches[1])) {
         if (in_array($matches[1], ReflectionTypeInterface::NON_QUALIFIED_TYPES, true)) {
             $name = $matches[1];
         } else {
             $name = '\\' . $matches[1];
         }
         $type = new ReflectionTypePolyFill($name, $this->parameter->allowsNull());
     }
     return $type;
 }
开发者ID:hostnet,项目名称:entity-plugin-lib,代码行数:24,代码来源:ReflectionParameter.php

示例6: getArgumentType

 /**
  * Gets the argument data type
  *
  * Returns same data types as PHP's gettype() method:
  *  'boolean', 'integer', 'double', 'string', 'array',
  *  'object', 'resource', 'NULL', 'unknown type'
  *
  * @param    \ReflectionParameter $argument Argument's ReflectionParameter instance
  * @return    string
  */
 private function getArgumentType(\ReflectionParameter $argument)
 {
     if ($argument->isArray()) {
         return 'array';
     }
     // check to see if it's a typehinted class
     $regex = '/^.*\\<\\w+?> ([\\w\\\\]+?) +.*$/';
     preg_match($regex, $argument->__toString(), $matches);
     if (isset($matches[1])) {
         return 'object';
     }
     if ($argument->isOptional()) {
         return gettype($argument->getDefaultValue());
     }
     return null;
 }
开发者ID:crimsonkissaki,项目名称:mockmaker,代码行数:26,代码来源:ArgumentDataWorker.php

示例7: getParameterClassName

 /**
  * A static version of `ReflectionParameter::getName()` that doesn't require the parameter class to be loaded.
  *
  * This prevents fatal errors when a parameter uses a class name for type hinting but the class is not loaded.
  *
  * @param  \ReflectionParameter $param The parameter reflection object
  * @return string                      The name of the parameter's type hinted object, if there is one.
  */
 protected static function getParameterClassName(\ReflectionParameter $param)
 {
     preg_match('/\\[\\s\\<\\w+?>\\s([a-zA-Z0-9_\\\\]+)/s', $param->__toString(), $matches);
     return isset($matches[1]) ? $matches[1] : null;
 }
开发者ID:johnbillion,项目名称:php-docs-standards,代码行数:13,代码来源:TestCase.php

示例8: getParameterType

 public static final function getParameterType(ReflectionParameter $param)
 {
     preg_match('/\\[\\s\\<\\w+?>\\s([\\w]+)/s', $param->__toString(), $matches);
     return isset($matches[1]) ? $matches[1] : null;
 }
开发者ID:jronatay,项目名称:ultimo-magento-jron,代码行数:5,代码来源:Dispatcher.php

示例9: getClassName

 protected function getClassName(ReflectionParameter $param)
 {
     preg_match('/\\[\\s\\<\\w+?>\\s([\\w]+)/s', $param->__toString(), $matches);
     return isset($matches[1]) ? $matches[1] : null;
 }
开发者ID:rlt3,项目名称:Stream,代码行数:5,代码来源:View.php

示例10: getParameterClassName

 protected function getParameterClassName(\ReflectionParameter $param)
 {
     preg_match('/> ([^ ]+) /', $param->__toString(), $matches);
     return !in_array($matches[1], ['$' . $param->getName(), 'array'], true) ? $matches[1] : null;
 }
开发者ID:octahedron,项目名称:pulp,代码行数:5,代码来源:InjectionMetaClass.php

示例11: getParamClassName

 private function getParamClassName(\ReflectionParameter $param)
 {
     preg_match('/\\[\\s\\<\\w+?>\\s([\\w\\\\]+)/s', $param->__toString(), $matches);
     return isset($matches[1]) ? $matches[1] : null;
 }
开发者ID:shaggy8871,项目名称:frame,代码行数:5,代码来源:Router.php

示例12: foo

<?php

function foo(array $x = array('a', 'b'))
{
}
$r = new ReflectionParameter('foo', 0);
echo $r->__toString();
开发者ID:badlamer,项目名称:hhvm,代码行数:7,代码来源:bug60357.php

示例13: getClassName

 private static function getClassName(\ReflectionParameter $param)
 {
     preg_match('/(\\w+)\\s\\$\\w+\\s\\]$/s', $param->__toString(), $matches);
     return isset($matches[1]) ? $matches[1] : null;
 }
开发者ID:boudra,项目名称:yapf,代码行数:5,代码来源:Services.php


注:本文中的ReflectionParameter::__toString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。