[DependencyInjection] Remove dead code with PHP 7+
This commit is contained in:
parent
15b7cdb9d9
commit
372e96e157
@ -250,7 +250,7 @@ class AutowirePass extends AbstractRecursivePass
|
||||
$class = $reflectionMethod instanceof \ReflectionMethod ? $reflectionMethod->class : $this->currentId;
|
||||
$method = $reflectionMethod->name;
|
||||
$parameters = $reflectionMethod->getParameters();
|
||||
if (method_exists('ReflectionMethod', 'isVariadic') && $reflectionMethod->isVariadic()) {
|
||||
if ($reflectionMethod->isVariadic()) {
|
||||
array_pop($parameters);
|
||||
}
|
||||
|
||||
@ -533,11 +533,10 @@ class AutowirePass extends AbstractRecursivePass
|
||||
$class = false;
|
||||
}
|
||||
|
||||
$isVariadic = method_exists($parameter, 'isVariadic') && $parameter->isVariadic();
|
||||
$methodArgumentsMetadata[] = array(
|
||||
'class' => $class,
|
||||
'isOptional' => $parameter->isOptional(),
|
||||
'defaultValue' => ($parameter->isOptional() && !$isVariadic) ? $parameter->getDefaultValue() : null,
|
||||
'defaultValue' => ($parameter->isOptional() && !$parameter->isVariadic()) ? $parameter->getDefaultValue() : null,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -37,10 +37,6 @@ class FactoryReturnTypePass implements CompilerPassInterface
|
||||
*/
|
||||
public function process(ContainerBuilder $container)
|
||||
{
|
||||
// works only since php 7.0 and hhvm 3.11
|
||||
if (!method_exists(\ReflectionMethod::class, 'getReturnType')) {
|
||||
return;
|
||||
}
|
||||
$resolveClassPassChanges = null !== $this->resolveClassPass ? $this->resolveClassPass->getChanges() : array();
|
||||
|
||||
foreach ($container->getDefinitions() as $id => $definition) {
|
||||
|
@ -28,7 +28,7 @@ class ProxyHelper
|
||||
|
||||
foreach ($r->getParameters() as $i => $p) {
|
||||
$k = '$'.$p->name;
|
||||
if (method_exists($p, 'isVariadic') && $p->isVariadic()) {
|
||||
if ($p->isVariadic()) {
|
||||
$k = '...'.$k;
|
||||
}
|
||||
$call[] = $k;
|
||||
@ -72,17 +72,9 @@ class ProxyHelper
|
||||
public static function getTypeHint(\ReflectionFunctionAbstract $r, \ReflectionParameter $p = null, $noBuiltin = false)
|
||||
{
|
||||
if ($p instanceof \ReflectionParameter) {
|
||||
if (method_exists($p, 'getType')) {
|
||||
$type = $p->getType();
|
||||
} elseif (preg_match('/^(?:[^ ]++ ){4}([a-zA-Z_\x7F-\xFF][^ ]++)/', $p, $type)) {
|
||||
$name = $type = $type[1];
|
||||
|
||||
if ('callable' === $name || 'array' === $name) {
|
||||
return $noBuiltin ? null : $name;
|
||||
}
|
||||
}
|
||||
$type = $p->getType();
|
||||
} else {
|
||||
$type = method_exists($r, 'getReturnType') ? $r->getReturnType() : null;
|
||||
$type = $r->getReturnType();
|
||||
}
|
||||
if (!$type) {
|
||||
return;
|
||||
|
@ -44,13 +44,8 @@ class FactoryReturnTypePassTest extends TestCase
|
||||
$pass = new FactoryReturnTypePass();
|
||||
$pass->process($container);
|
||||
|
||||
if (method_exists(\ReflectionMethod::class, 'getReturnType')) {
|
||||
$this->assertEquals(FactoryDummy::class, $factory->getClass());
|
||||
$this->assertEquals(\stdClass::class, $foo->getClass());
|
||||
} else {
|
||||
$this->assertNull($factory->getClass());
|
||||
$this->assertNull($foo->getClass());
|
||||
}
|
||||
$this->assertEquals(FactoryDummy::class, $factory->getClass());
|
||||
$this->assertEquals(\stdClass::class, $foo->getClass());
|
||||
$this->assertEquals(__CLASS__, $bar->getClass());
|
||||
}
|
||||
|
||||
@ -71,11 +66,7 @@ class FactoryReturnTypePassTest extends TestCase
|
||||
$pass = new FactoryReturnTypePass();
|
||||
$pass->process($container);
|
||||
|
||||
if (method_exists(\ReflectionMethod::class, 'getReturnType')) {
|
||||
$this->assertEquals($returnType, $service->getClass());
|
||||
} else {
|
||||
$this->assertNull($service->getClass());
|
||||
}
|
||||
$this->assertEquals($returnType, $service->getClass());
|
||||
}
|
||||
|
||||
public function returnTypesProvider()
|
||||
|
Reference in New Issue
Block a user