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


PHP ReflectionParameter::getName方法代码示例

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


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

示例1: getName

 /**
  * @return string|null
  */
 public function getName()
 {
     if (empty($this->parameter)) {
         return null;
     }
     return $this->parameter->getName();
 }
开发者ID:spiral,项目名称:components,代码行数:10,代码来源:Context.php

示例2: getReflectionParameterName

 /**
  * Helper method to get the type of a reflection paramter
  * @param \ReflectionParameter $parameter
  * @return NULL|\ReflectionType|string
  */
 protected function getReflectionParameterName(\ReflectionParameter $parameter)
 {
     // parameter is a class
     if ($class = $parameter->getClass()) {
         return $class->getName() . ' \\$' . $parameter->getName();
     }
     return $parameter->getName();
 }
开发者ID:frogsystem,项目名称:spawn,代码行数:13,代码来源:ParameterResolutionException.php

示例3: generateForParameter

 /**
  * Generate key for parameter
  *
  * @param \ReflectionParameter        $parameter
  * @param \ReflectionFunctionAbstract $method
  *
  * @return string
  */
 public static function generateForParameter(\ReflectionParameter $parameter, \ReflectionFunctionAbstract $method)
 {
     if ($method instanceof \ReflectionMethod) {
         $key = $method->getDeclaringClass()->getName() . '::' . $method->getName() . ':' . $parameter->getName();
     } else {
         $key = 'function::' . $method->getName() . ':' . $parameter->getName();
     }
     return $key;
 }
开发者ID:Gtvar,项目名称:FivePercent-Converter,代码行数:17,代码来源:KeyGenerator.php

示例4: injectByClass

 /**
  * @param \ReflectionParameter $class
  * @return mixed|object
  * @throws \Exception
  */
 public function injectByClass($class)
 {
     $reflection = $class->getClass();
     if (is_null($reflection)) {
         return HttpParameter::getInstance()->getOrError($class->getName());
     } else {
         if ($reflection->getName() === Option::class) {
             return HttpParameter::getInstance()->get($class->getName());
         }
     }
     return $this->create($reflection);
 }
开发者ID:pldin601,项目名称:Predictions,代码行数:17,代码来源:Injector.php

示例5: exportCode

 public function exportCode()
 {
     $default_value = null;
     if ($this->_parameter->isDefaultValueAvailable()) {
         $default_value = $this->_parameter->getDefaultValue();
         if (is_scalar($default_value) && !is_numeric($default_value)) {
             $default_value = "'{$default_value}'";
         }
     } elseif ($this->_parameter->isOptional()) {
         $default_value = 'NULL';
     }
     return sprintf('%s%s$%s%s', $this->_parameter->getClass() ? "{$this->_parameter->getClass()->getName()} " : '', $this->_parameter->isPassedByReference() ? '&' : '', $this->_parameter->getName(), $default_value ? " = {$default_value}" : '');
 }
开发者ID:michalkoslab,项目名称:Helpers,代码行数:13,代码来源:ReflectionParameter.php

示例6: from

 /**
  * @return self
  */
 public static function from(\ReflectionParameter $from)
 {
     $param = new static();
     $param->name = $from->getName();
     $param->reference = $from->isPassedByReference();
     if ($from->isArray()) {
         $param->typeHint = 'array';
     } elseif (PHP_VERSION_ID >= 50400 && $from->isCallable()) {
         $param->typeHint = 'callable';
     } else {
         try {
             $param->typeHint = $from->getClass() ? '\\' . $from->getClass()->getName() : NULL;
         } catch (\ReflectionException $e) {
             if (preg_match('#Class (.+) does not exist#', $e->getMessage(), $m)) {
                 $param->typeHint = '\\' . $m[1];
             } else {
                 throw $e;
             }
         }
     }
     $param->optional = PHP_VERSION_ID < 50407 ? $from->isOptional() || $param->typeHint && $from->allowsNull() : $from->isDefaultValueAvailable();
     $param->defaultValue = PHP_VERSION_ID === 50316 ? $from->isOptional() : $from->isDefaultValueAvailable() ? $from->getDefaultValue() : NULL;
     $namespace = $from->getDeclaringClass() ? $from->getDeclaringClass()->getNamespaceName() : NULL;
     $namespace = $namespace ? "\\{$namespace}\\" : '\\';
     if (Nette\Utils\Strings::startsWith($param->typeHint, $namespace)) {
         $param->typeHint = substr($param->typeHint, strlen($namespace));
     }
     return $param;
 }
开发者ID:NetteCamp,项目名称:2015-nextras-orm-twitter,代码行数:32,代码来源:Parameter.php

示例7: getParameterAnnotations

 public function getParameterAnnotations(\ReflectionParameter $parameter)
 {
     $class = $parameter->getDeclaringClass() ?: 'Closure';
     $method = $parameter->getDeclaringFunction();
     if (!$method->isUserDefined()) {
         return array();
     }
     $context = 'parameter ' . ($class === 'Closure' ? $class : $class->getName()) . '::' . $method->getName() . '($' . $parameter->getName() . ')';
     if ($class === 'Closure') {
         $this->parser->setImports($this->getClosureImports($method));
     } else {
         $this->parser->setImports($this->getImports($class));
         $this->parser->setIgnoredAnnotationNames($this->getIgnoredAnnotationNames($class));
     }
     $lines = file($method->getFileName());
     $lines = array_slice($lines, $start = $method->getStartLine() - 1, $method->getEndLine() - $start);
     $methodBody = Implode($lines);
     $methodBody = str_replace("\n", null, $methodBody);
     $signature = preg_split('/\\)\\s*\\{/', $methodBody);
     $signature = $signature[0];
     $signature = substr($signature, strpos($signature, "function"));
     if (preg_match_all('/\\/\\*\\*(.*?)\\*\\/' . '.*?\\$(\\w+)/', $signature, $matches)) {
         $docComments = $matches[1];
         $names = $matches[2];
         for ($i = 0, $len = count($names); $i < $len; ++$i) {
             if ($names[$i] === $parameter->name) {
                 return $this->parser->parse($docComments[$i], $context);
             }
         }
     }
     return array();
 }
开发者ID:spotframework,项目名称:spot,代码行数:32,代码来源:ReaderImpl.php

示例8: getArgConfig

 /**
  * @param Zend_Config $testConfig
  * @param ReflectionParameter $arg
  * @throws Exception
  * @throws KalturaTestException
  * @return Ambigous
  */
 protected function getArgConfig(Zend_Config $testConfig, ReflectionParameter $arg)
 {
     $argName = $arg->getName();
     $argConfig = $testConfig->get($argName);
     KalturaLog::debug("Tests data [{$argName}] config [" . print_r($argConfig, true) . "]");
     if (!$argConfig) {
         if (!$arg->allowsNull()) {
             throw new Exception("Argument [{$argName}] can't be null for test [" . $this->getName() . "]");
         }
         return null;
     }
     if (is_string($argConfig)) {
         return $argConfig;
     }
     switch ($argConfig->objectType) {
         case 'dependency':
             throw new KalturaTestException("Argument [{$argName}] taken from dependency");
         case 'array':
             return $this->populateArray($argConfig);
         case 'native':
             return $argConfig->value;
         case 'file':
             return $argConfig->path;
         default:
             return $this->populateObject($argConfig);
     }
 }
开发者ID:EfncoPlugins,项目名称:Media-Management-based-on-Kaltura,代码行数:34,代码来源:KalturaTestCaseApiBase.php

示例9: from

 /**
  * @return self
  */
 public static function from(\ReflectionParameter $from)
 {
     $param = new static($from->getName());
     $param->reference = $from->isPassedByReference();
     if (PHP_VERSION_ID >= 70000) {
         $param->typeHint = $from->hasType() ? (string) $from->getType() : NULL;
     } elseif ($from->isArray()) {
         $param->typeHint = 'array';
     } elseif (PHP_VERSION_ID >= 50400 && $from->isCallable()) {
         $param->typeHint = 'callable';
     } else {
         try {
             $param->typeHint = $from->getClass() ? $from->getClass()->getName() : NULL;
         } catch (\ReflectionException $e) {
             if (preg_match('#Class (.+) does not exist#', $e->getMessage(), $m)) {
                 $param->typeHint = $m[1];
             } else {
                 throw $e;
             }
         }
     }
     $param->optional = PHP_VERSION_ID < 50407 ? $from->isOptional() || $param->typeHint && $from->allowsNull() : $from->isDefaultValueAvailable();
     $param->defaultValue = PHP_VERSION_ID === 50316 ? $from->isOptional() : $from->isDefaultValueAvailable() ? $from->getDefaultValue() : NULL;
     return $param;
 }
开发者ID:luminousinfoways,项目名称:pccfoas,代码行数:28,代码来源:Parameter.php

示例10: __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

示例11: __construct

 public function __construct(\ReflectionParameter $parameter)
 {
     $this->name = $parameter->getName();
     $this->position = $parameter->getPosition();
     $this->has_default = $parameter->isDefaultValueAvailable();
     $this->default_value = $this->getHasDefault() ? $parameter->getDefaultValue() : null;
 }
开发者ID:kamioftea,项目名称:php-util,代码行数:7,代码来源:Argument.php

示例12: getParamDocBlockHint

 /**
  * @param array                $docBlockParams
  * @param \ReflectionParameter $param
  * @param array                $arguments
  *
  * @return bool|string
  */
 public function getParamDocBlockHint(array $docBlockParams, \ReflectionParameter $param, array $arguments = [])
 {
     $typeHint = false;
     /** @var DocBlock\Tag\ParamTag $docBlockParam */
     foreach ($docBlockParams as $docBlockParam) {
         if (!$docBlockParam instanceof DocBlock\Tag\ParamTag) {
             continue;
         }
         $type = $docBlockParam->getType();
         $docBlockParamName = $docBlockParam->getVariableName();
         if ($param->getName() === ltrim($docBlockParamName, '$') && !empty($type)) {
             $definitions = explode('|', $type);
             foreach ($arguments as $key => $argument) {
                 foreach ($definitions as $definition) {
                     if (is_object($argument) && in_array(ltrim($definition, '\\'), $this->getImplemented(get_class($argument))) && (is_numeric($key) || ltrim($docBlockParamName, '$') === $key)) {
                         $typeHint = $definition;
                         // no need to loop again, since we found a match already!
                         continue 3;
                     }
                 }
             }
             if ($typeHint === false) {
                 // use first definition, there is no way to know which instance of the hinted doc block definitions is actually required
                 // because there were either no arguments given or no argument match was found
                 list($firstDefinition, ) = $definitions;
                 if (!in_array(strtolower($firstDefinition), ['int', 'float', 'bool', 'string', 'array'])) {
                     $typeHint = $firstDefinition;
                 }
             }
         }
     }
     return $typeHint;
 }
开发者ID:cmpayments,项目名称:atreyu,代码行数:40,代码来源:BaseReflector.php

示例13: getArgumentMock

 /**
  * @param \ReflectionParameter $parameter
  * @return mixed
  */
 private function getArgumentMock(\ReflectionParameter $parameter)
 {
     if ($parameter->getClass() !== null) {
         return $this->testCase->getMockBuilder($parameter->getClass()->getName())->disableOriginalConstructor()->getMock();
     }
     throw new \Mocktainer\UnmockableMethodArgumentException($parameter->getDeclaringClass()->getName(), $parameter->getDeclaringFunction()->getName(), $parameter->getName());
 }
开发者ID:paranoiq,项目名称:mocktainer,代码行数:11,代码来源:Mocktainer.php

示例14: getName

 /**
  * Returns this parameters's name
  * @return string
  */
 public function getName()
 {
     if ($this->parameter != null) {
         return $this->parameter->getName();
     } else {
         return parent::getName();
     }
 }
开发者ID:zetacomponents,项目名称:reflection,代码行数:12,代码来源:parameter.php

示例15: getParameterValue

 /**
  * {@inheritdoc}
  */
 public function getParameterValue(\ReflectionParameter $parameter)
 {
     $name = $parameter->getName();
     if (isset($this->values[$name])) {
         return $this->values[$name];
     }
     return $this->fallback->getParameterValue($parameter);
 }
开发者ID:brick,项目名称:di,代码行数:11,代码来源:ArrayValueResolver.php


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