declare types in array_map callbacks

This commit is contained in:
DQNEO 2018-04-20 23:08:14 +09:00 committed by Fabien Potencier
parent 9a0422ce45
commit e7d5634cf4
3 changed files with 8 additions and 5 deletions

View File

@ -16,6 +16,7 @@ use Symfony\Component\DependencyInjection\Argument\TaggedIteratorArgument;
use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader; use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
use Symfony\Component\ExpressionLanguage\Expression; use Symfony\Component\ExpressionLanguage\Expression;
@ -44,7 +45,7 @@ class ContainerConfigurator extends AbstractConfigurator
final public function extension($namespace, array $config) final public function extension($namespace, array $config)
{ {
if (!$this->container->hasExtension($namespace)) { if (!$this->container->hasExtension($namespace)) {
$extensions = array_filter(array_map(function ($ext) { return $ext->getAlias(); }, $this->container->getExtensions())); $extensions = array_filter(array_map(function (ExtensionInterface $ext) { return $ext->getAlias(); }, $this->container->getExtensions()));
throw new InvalidArgumentException(sprintf( throw new InvalidArgumentException(sprintf(
'There is no extension able to load the configuration for "%s" (in %s). Looked for namespace "%s", found %s', 'There is no extension able to load the configuration for "%s" (in %s). Looked for namespace "%s", found %s',
$namespace, $namespace,

View File

@ -13,6 +13,7 @@ namespace Symfony\Component\DependencyInjection\Tests\Loader;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use Symfony\Component\DependencyInjection\Argument\IteratorArgument; use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
use Symfony\Component\DependencyInjection\Argument\BoundArgument;
use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
@ -788,7 +789,7 @@ class XmlFileLoaderTest extends TestCase
'$foo' => array(null), '$foo' => array(null),
'$quz' => 'quz', '$quz' => 'quz',
'$factory' => 'factory', '$factory' => 'factory',
), array_map(function ($v) { return $v->getValues()[0]; }, $definition->getBindings())); ), array_map(function (BoundArgument $v) { return $v->getValues()[0]; }, $definition->getBindings()));
$this->assertEquals(array( $this->assertEquals(array(
'quz', 'quz',
null, null,
@ -805,6 +806,6 @@ class XmlFileLoaderTest extends TestCase
'NonExistent' => null, 'NonExistent' => null,
'$quz' => 'quz', '$quz' => 'quz',
'$factory' => 'factory', '$factory' => 'factory',
), array_map(function ($v) { return $v->getValues()[0]; }, $definition->getBindings())); ), array_map(function (BoundArgument $v) { return $v->getValues()[0]; }, $definition->getBindings()));
} }
} }

View File

@ -12,6 +12,7 @@
namespace Symfony\Component\DependencyInjection\Tests\Loader; namespace Symfony\Component\DependencyInjection\Tests\Loader;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use Symfony\Component\DependencyInjection\Argument\BoundArgument;
use Symfony\Component\DependencyInjection\Argument\IteratorArgument; use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\DependencyInjection\Reference;
@ -713,7 +714,7 @@ class YamlFileLoaderTest extends TestCase
'$foo' => array(null), '$foo' => array(null),
'$quz' => 'quz', '$quz' => 'quz',
'$factory' => 'factory', '$factory' => 'factory',
), array_map(function ($v) { return $v->getValues()[0]; }, $definition->getBindings())); ), array_map(function (BoundArgument $v) { return $v->getValues()[0]; }, $definition->getBindings()));
$this->assertEquals(array( $this->assertEquals(array(
'quz', 'quz',
null, null,
@ -730,6 +731,6 @@ class YamlFileLoaderTest extends TestCase
'NonExistent' => null, 'NonExistent' => null,
'$quz' => 'quz', '$quz' => 'quz',
'$factory' => 'factory', '$factory' => 'factory',
), array_map(function ($v) { return $v->getValues()[0]; }, $definition->getBindings())); ), array_map(function (BoundArgument $v) { return $v->getValues()[0]; }, $definition->getBindings()));
} }
} }