[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'); public static $arrayMutatorPrefixes = array('add', 'remove');
private $supportsParameterType;
public function __construct()
{
$this->supportsParameterType = method_exists('ReflectionParameter', 'getType');
}
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
@ -152,7 +145,6 @@ class ReflectionExtractor implements PropertyListExtractorInterface, PropertyTyp
$reflectionParameters = $reflectionMethod->getParameters(); $reflectionParameters = $reflectionMethod->getParameters();
$reflectionParameter = $reflectionParameters[0]; $reflectionParameter = $reflectionParameters[0];
if ($this->supportsParameterType) {
if (!$reflectionType = $reflectionParameter->getType()) { if (!$reflectionType = $reflectionParameter->getType()) {
return; return;
} }
@ -162,17 +154,6 @@ class ReflectionExtractor implements PropertyListExtractorInterface, PropertyTyp
if (!$reflectionType->isBuiltin() && Type::BUILTIN_TYPE_ARRAY === $type->getBuiltinType()) { if (!$reflectionType->isBuiltin() && Type::BUILTIN_TYPE_ARRAY === $type->getBuiltinType()) {
return; 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 {
return;
}
if (in_array($prefix, self::$arrayMutatorPrefixes)) { if (in_array($prefix, self::$arrayMutatorPrefixes)) {
$type = new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true, new Type(Type::BUILTIN_TYPE_INT), $type); $type = new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true, new Type(Type::BUILTIN_TYPE_INT), $type);
@ -196,7 +177,7 @@ class ReflectionExtractor implements PropertyListExtractorInterface, PropertyTyp
return; return;
} }
if ($this->supportsParameterType && $reflectionType = $reflectionMethod->getReturnType()) { if ($reflectionType = $reflectionMethod->getReturnType()) {
return array($this->extractFromReflectionType($reflectionType)); return array($this->extractFromReflectionType($reflectionType));
} }