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


PHP ReflectionParameter::isDefaultValueConstant方法代码示例

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


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

示例1: isParamDefaultValueConstant

 /**
  * Check whether a parameter's default value is a constant.
  *
  * This is only supported in PHP >= 5.4.3, and currently unimplemented in
  * HHVM.
  *
  * @param \ReflectionParameter $param
  *
  * @return boolean
  */
 protected static function isParamDefaultValueConstant(\ReflectionParameter $param)
 {
     // HHVM doesn't currently support `isDefaultValueConstant`, skip for now
     // see https://github.com/facebook/hhvm/issues/3812
     if (defined('HHVM_VERSION')) {
         return false;
     }
     return version_compare(PHP_VERSION, '5.4.3', '>=') && $param->isDefaultValueConstant();
 }
开发者ID:EnmanuelCode,项目名称:backend-laravel,代码行数:19,代码来源:ClosurePresenter.php

示例2: formatParam

 /**
  * Format an individual Closure parameter.
  *
  * @param \ReflectionParameter $param
  *
  * @return string
  */
 protected function formatParam(\ReflectionParameter $param, $color = false)
 {
     $ret = '$' . $param->name;
     if ($color) {
         $ret = '<strong>' . $ret . '</strong>';
     }
     if ($param->isOptional()) {
         $ret .= ' = ';
         if (version_compare(PHP_VERSION, '5.4.3', '>=') && $param->isDefaultValueConstant()) {
             $name = $param->getDefaultValueConstantName();
             if ($color) {
                 $ret .= '<const>' . $name . '</const>';
             } else {
                 $ret .= $name;
             }
         } elseif ($param->isDefaultValueAvailable()) {
             $ret .= $this->manager->presentRef($param->getDefaultValue(), $color);
         } else {
             if ($color) {
                 $ret .= '<urgent>?</urgent>';
             } else {
                 $ret .= '?';
             }
         }
     }
     return $ret;
 }
开发者ID:fulore,项目名称:psysh,代码行数:34,代码来源:ClosurePresenter.php

示例3: formatParam

 /**
  * Format an individual Closure parameter.
  *
  * @param \ReflectionParameter $param
  *
  * @return string
  */
 protected function formatParam(\ReflectionParameter $param)
 {
     $ret = $this->formatParamName($param->name);
     if ($param->isOptional()) {
         $ret .= ' = ';
         if (version_compare(PHP_VERSION, '5.4.3', '>=') && $param->isDefaultValueConstant()) {
             $name = $param->getDefaultValueConstantName();
             $ret .= '<const>' . $name . '</const>';
         } elseif ($param->isDefaultValueAvailable()) {
             $ret .= $this->manager->presentRef($param->getDefaultValue());
         } else {
             $ret .= '<urgent>?</urgent>';
         }
     }
     return $ret;
 }
开发者ID:fparralejo,项目名称:btrabajo,代码行数:23,代码来源:ClosurePresenter.php

示例4: matchReflector

 public function matchReflector(\ReflectionParameter $reflector)
 {
     $this->setReference($reflector->isPassedByReference());
     // Match the reflector's type hint.
     if ($reflector->isArray()) {
         $this->setTypeHint('array');
     } elseif ($reflector->isCallable()) {
         $this->setTypeHint('callable');
     } elseif ($class = $reflector->getClass()) {
         $this->setTypeHint($class->getName());
     }
     // Match the reflector's default value, if there is one. It will be a
     // scalar value, an array of scalar values, or a constant.
     if ($reflector->isDefaultValueAvailable()) {
         if ($reflector->isDefaultValueConstant()) {
             $this->setValue(ConstantNode::create($reflector->getDefaultValueConstantName()));
         } else {
             $this->setValue(Node::fromValue($reflector->getDefaultValue()));
         }
     }
     return $this;
 }
开发者ID:kidaa30,项目名称:redcat,代码行数:22,代码来源:ParameterNode.php

示例5: paramDetails

 /**
  * Get a declaration of the param for cli command;
  * @param \ReflectionParameter $param
  * @return string
  */
 protected function paramDetails(\ReflectionParameter $param)
 {
     return ' ' . ($param->isOptional() ? '[' : '') . '--' . $param->getName() . ($param->isOptional() ? '=' . ($param->isDefaultValueConstant() ? $param->getDefaultValueConstantName() : '"' . $param->getDefaultValue() . '"') : '') . ($param->isOptional() ? ']' : '');
 }
开发者ID:mpf-soft,项目名称:mpf,代码行数:9,代码来源:NotFound.php

示例6: getParameterDefinition

 /**
  * @param \ReflectionParameter $r
  *
  * @return string
  */
 protected function getParameterDefinition(\ReflectionParameter $r)
 {
     $type = '';
     if ($r->isArray()) {
         $type = 'array';
     } elseif ($r->isCallable()) {
         $type = 'callable';
     } elseif ($r->getClass()) {
         $type = '\\' . $r->getClass()->getName();
     }
     $name = $r->getName();
     $default = '';
     if ($r->isDefaultValueAvailable() and $r->isDefaultValueConstant()) {
         $default = ' = \\' . $r->getDefaultValueConstantName();
     } elseif ($r->isDefaultValueAvailable()) {
         $default = ' = ' . var_export($r->getDefaultValue(), true);
     }
     $definition = trim($type . ' $' . $name . $default);
     return $definition;
 }
开发者ID:mihai-stancu,项目名称:rpc-bundle,代码行数:25,代码来源:ProxyGenerator.php

示例7: getPhpForParameter

 /**
  * @param \ReflectionParameter $parameter
  * @return string
  */
 protected function getPhpForParameter(\ReflectionParameter $parameter)
 {
     $php = null;
     if ($parameter->getClass() instanceof \ReflectionClass) {
         $php .= '\\' . $parameter->getClass()->name . ' ';
     } elseif ($parameter->isCallable()) {
         $php .= 'callable ';
     } elseif ($parameter->isArray()) {
         $php .= 'array ';
     }
     if ($parameter->isPassedByReference()) {
         $php .= '&';
     }
     $php .= '$' . $parameter->name;
     if ($parameter->isDefaultValueAvailable()) {
         $parameterDefaultValue = $parameter->getDefaultValue();
         if ($parameter->isDefaultValueConstant()) {
             $defaultValue = $parameter->getDefaultValueConstantName();
         } elseif ($parameterDefaultValue === null) {
             $defaultValue = 'null';
         } elseif (is_bool($parameterDefaultValue)) {
             $defaultValue = $parameterDefaultValue === true ? 'true' : 'false';
         } elseif (is_string($parameterDefaultValue)) {
             $defaultValue = '\'' . $parameterDefaultValue . '\'';
         } elseif (is_array($parameterDefaultValue)) {
             $defaultValue = 'array()';
         } else {
             $defaultValue = $parameterDefaultValue;
         }
         $php .= ' = ' . $defaultValue;
     }
     return $php;
 }
开发者ID:steevanb,项目名称:doctrine-read-only-hydrator,代码行数:37,代码来源:ReadOnlyHydrator.php

示例8: setDependencyByReflection

 /**
  * Set dependency value by reflection
  *
  * @param ParameterDefinition $parameterDefinition
  * @param \ReflectionParameter $reflectionParameter
  * @throws \InvalidArgumentException
  * @throws ReferenceNotImplementsException
  */
 public function setDependencyByReflection(ParameterDefinition $parameterDefinition, \ReflectionParameter $reflectionParameter)
 {
     // If default value available
     if ($reflectionParameter->isDefaultValueAvailable()) {
         // There is a constant
         if ($reflectionParameter->isDefaultValueConstant()) {
             $parameterDefinition->setDependency(new ConstantReference($reflectionParameter->getDefaultValueConstantName()));
         } else {
             // There is some php types
             $parameterDefinition->setDependency(CollectionReference::convertValueToReference($reflectionParameter->getDefaultValue()));
         }
         // There is class dependency
     } elseif ($this->checkIfTypeHingIsClass($parameterDefinition)) {
         $class = (string) $parameterDefinition->getTypeHint();
         $parameterDefinition->setDependency(new ClassReference($class));
     }
 }
开发者ID:samsonframework,项目名称:container,代码行数:25,代码来源:ReflectionParameterAnalyzer.php

示例9: getParamStr

function getParamStr(ReflectionParameter $param)
{
    $name = $param->getName();
    //support variable-length argument lists
    if ($name == '...') {
        return '$_ = null';
    }
    $str = '$' . $name;
    if ($param->isPassedByReference()) {
        $str = '&' . $str;
    }
    if ($param->isArray()) {
        $str = 'array ' . $str;
    } else {
        if ($param->isCallable()) {
            $str = 'callable ' . $str;
        }
    }
    //it's impossible to get default value of build-in function's parameter, just for forward compatible
    if ($param->isOptional() && $param->isDefaultValueAvailable()) {
        if ($param->isDefaultValueConstant()) {
            $default = $param->getDefaultValueConstantName();
        } else {
            $default = $param->getDefaultValue();
        }
        $str .= ' = ' . $default;
    }
    return $str;
}
开发者ID:leo108,项目名称:php_extension_autocomplete_generator,代码行数:29,代码来源:generator.php


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