From b346e48adf7ba37d873f0335ab4a1672a7963423 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Thu, 18 May 2017 09:02:00 +0200 Subject: [PATCH] [PropertyInfo] Remove dead code with PHP 7+ --- .../Extractor/ReflectionExtractor.php | 33 ++++--------------- 1 file changed, 7 insertions(+), 26 deletions(-) diff --git a/src/Symfony/Component/PropertyInfo/Extractor/ReflectionExtractor.php b/src/Symfony/Component/PropertyInfo/Extractor/ReflectionExtractor.php index 228aa583e8..0d67b07611 100644 --- a/src/Symfony/Component/PropertyInfo/Extractor/ReflectionExtractor.php +++ b/src/Symfony/Component/PropertyInfo/Extractor/ReflectionExtractor.php @@ -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)); }