[PropertyInfo] Remove dead code with PHP 7+

This commit is contained in:
Kévin Dunglas 2017-05-18 09:02:00 +02:00
parent 15b7cdb9d9
commit b346e48adf
No known key found for this signature in database
GPG Key ID: 4D04EBEF06AAF3A6

View File

@ -47,13 +47,6 @@ class ReflectionExtractor implements PropertyListExtractorInterface, PropertyTyp
*/
public static $arrayMutatorPrefixes = array('add', 'remove');
private $supportsParameterType;
public function __construct()
{
$this->supportsParameterType = method_exists('ReflectionParameter', 'getType');
}
/**
* {@inheritdoc}
*/
@ -152,25 +145,13 @@ class ReflectionExtractor implements PropertyListExtractorInterface, PropertyTyp
$reflectionParameters = $reflectionMethod->getParameters();
$reflectionParameter = $reflectionParameters[0];
if ($this->supportsParameterType) {
if (!$reflectionType = $reflectionParameter->getType()) {
return;
}
$type = $this->extractFromReflectionType($reflectionType);
if (!$reflectionType = $reflectionParameter->getType()) {
return;
}
$type = $this->extractFromReflectionType($reflectionType);
// HHVM reports variadics with "array" but not builtin type hints
if (!$reflectionType->isBuiltin() && Type::BUILTIN_TYPE_ARRAY === $type->getBuiltinType()) {
return;
}
} elseif (preg_match('/^(?:[^ ]++ ){4}([a-zA-Z_\x7F-\xFF][^ ]++)/', $reflectionParameter, $info)) {
if (Type::BUILTIN_TYPE_ARRAY === $info[1]) {
$type = new Type(Type::BUILTIN_TYPE_ARRAY, $reflectionParameter->allowsNull(), null, true);
} elseif (Type::BUILTIN_TYPE_CALLABLE === $info[1]) {
$type = new Type(Type::BUILTIN_TYPE_CALLABLE, $reflectionParameter->allowsNull());
} else {
$type = new Type(Type::BUILTIN_TYPE_OBJECT, $reflectionParameter->allowsNull(), $info[1]);
}
} else {
// HHVM reports variadics with "array" but not builtin type hints
if (!$reflectionType->isBuiltin() && Type::BUILTIN_TYPE_ARRAY === $type->getBuiltinType()) {
return;
}
@ -196,7 +177,7 @@ class ReflectionExtractor implements PropertyListExtractorInterface, PropertyTyp
return;
}
if ($this->supportsParameterType && $reflectionType = $reflectionMethod->getReturnType()) {
if ($reflectionType = $reflectionMethod->getReturnType()) {
return array($this->extractFromReflectionType($reflectionType));
}