本文整理汇总了PHP中ReflectionParameter::isVariadic方法的典型用法代码示例。如果您正苦于以下问题:PHP ReflectionParameter::isVariadic方法的具体用法?PHP ReflectionParameter::isVariadic怎么用?PHP ReflectionParameter::isVariadic使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ReflectionParameter
的用法示例。
在下文中一共展示了ReflectionParameter::isVariadic方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getType
public function getType() : Type
{
if ($this->type === null) {
$phpDocType = $this->phpDocType;
if ($phpDocType !== null && $this->reflection->isDefaultValueAvailable() && $this->reflection->getDefaultValue() === null) {
$phpDocType = $phpDocType->makeNullable();
}
$this->type = TypehintHelper::decideTypeFromReflection($this->reflection->getType(), $phpDocType, $this->reflection->getDeclaringClass() !== null ? $this->reflection->getDeclaringClass()->getName() : null, $this->reflection->isVariadic());
}
return $this->type;
}
示例2: testWrappedMethods
public function testWrappedMethods()
{
$php_parameter = new \ReflectionParameter([$this, 'method'], 'param');
$our_parameter = new ReflectionParameter($php_parameter);
$this->assertSame($php_parameter->getName(), $our_parameter->getName());
$this->assertSame($php_parameter->allowsNull(), $our_parameter->allowsNull());
$this->assertSame($php_parameter->isOptional(), $our_parameter->isOptional());
$this->assertSame($php_parameter->isDefaultValueAvailable(), $our_parameter->isDefaultValueAvailable());
$this->assertSame($php_parameter->isVariadic(), $our_parameter->isVariadic());
$this->assertSame($php_parameter->isPassedByReference(), $our_parameter->isPassedByReference());
$this->assertSame($php_parameter->getDefaultValue(), $our_parameter->getDefaultValue());
}
示例3: getParameterValue
/**
* @param \ReflectionParameter $parameter
* @param mixed $value
*
* @return mixed
*
* @throws HttpException If the object cannot be instantiated.
*/
private function getParameterValue(\ReflectionParameter $parameter, $value)
{
$class = $parameter->getClass();
if ($class) {
if ($parameter->isVariadic()) {
$result = [];
foreach ($value as $subValue) {
$result[] = $this->getObject($class->getName(), $subValue);
}
return $result;
} else {
return $this->getObject($class->getName(), $value);
}
}
return $value;
}
示例4: isVariadic
/**
* @param ReflectionParameter $parameter
*
* @return boolean
* @since Method available since Release 2.2.1
*/
private function isVariadic(ReflectionParameter $parameter)
{
return method_exists('ReflectionParameter', 'isVariadic') && $parameter->isVariadic();
}
示例5: isVariadic
/**
* Returns whether an argument is variadic.
*
* @param \ReflectionParameter $parameter
*
* @return bool
*/
private function isVariadic(\ReflectionParameter $parameter)
{
return PHP_VERSION_ID >= 50600 && $parameter->isVariadic();
}
示例6: isVariadic
private function isVariadic(\ReflectionParameter $parameter)
{
return $this->supportsVariadic && $parameter->isVariadic();
}
示例7: isParameterVariadic
/**
* @param \ReflectionParameter $reflectionParameter
*
* @return bool
*/
protected function isParameterVariadic(\ReflectionParameter $reflectionParameter)
{
if (is_callable(array($reflectionParameter, 'isVariadic')) && $reflectionParameter->isVariadic()) {
return true;
}
return false;
}
示例8: getParameterCode
/**
* Return string representation of parameter
*
* @param Parameter|ParsedParameter $parameter Reflection parameter
*
* @return string
*/
protected function getParameterCode($parameter)
{
$type = '';
if ($parameter->isArray()) {
$type = 'array';
} elseif ($parameter->getClass()) {
$type = '\\' . $parameter->getClass()->name;
}
$defaultValue = null;
$isDefaultValueAvailable = $parameter->isDefaultValueAvailable();
if ($isDefaultValueAvailable) {
if ($parameter instanceof ParsedParameter) {
$defaultValue = $parameter->getDefaultValueDefinition();
} else {
$defaultValue = var_export($parameter->getDefaultValue());
}
} elseif ($parameter->isOptional()) {
$defaultValue = 'null';
}
$code = ($type ? "{$type} " : '') . ($parameter->isPassedByReference() ? '&' : '') . ($this->useVariadics && $parameter->isVariadic() ? '...' : '') . '$' . $parameter->name . ($defaultValue !== null ? " = " . $defaultValue : '');
return $code;
}
示例9: assertSameParameterAttributes
private function assertSameParameterAttributes(\ReflectionParameter $original, ReflectionParameter $stubbed)
{
$this->assertSame($original->getName(), $stubbed->getName());
$this->assertSame($original->isArray(), $stubbed->isArray());
$this->assertSame($original->isCallable(), $stubbed->isCallable());
//$this->assertSame($original->allowsNull(), $stubbed->allowsNull()); @TODO WTF?
$this->assertSame($original->canBePassedByValue(), $stubbed->canBePassedByValue());
$this->assertSame($original->isOptional(), $stubbed->isOptional());
$this->assertSame($original->isPassedByReference(), $stubbed->isPassedByReference());
$this->assertSame($original->isVariadic(), $stubbed->isVariadic());
if ($class = $original->getClass()) {
$stubbedClass = $stubbed->getClass();
$this->assertInstanceOf(ReflectionClass::class, $stubbedClass);
$this->assertSame($class->getName(), $stubbedClass->getName());
} else {
$this->assertNull($stubbed->getClass());
}
}
示例10: isVariadic
/**
* @return bool
*/
public function isVariadic()
{
return $this->parameter->isVariadic();
}