minor #26990 declare types in array_map callbacks (DQNEO)

This PR was squashed before being merged into the 4.1-dev branch (closes #26990).

Discussion
----------

declare types in array_map callbacks

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets |
| License       | MIT
| Doc PR        |

This is a continuation of https://github.com/symfony/symfony/pull/26821

Commits
-------

e7d5634cf4 declare types in array_map callbacks
This commit is contained in:
Fabien Potencier 2018-04-22 08:37:48 +02:00
commit 2ed0c67375
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\Definition;
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
use Symfony\Component\ExpressionLanguage\Expression;
@ -45,7 +46,7 @@ class ContainerConfigurator extends AbstractConfigurator
final public function extension(string $namespace, array $config)
{
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(
'There is no extension able to load the configuration for "%s" (in %s). Looked for namespace "%s", found %s',
$namespace,

View File

@ -13,6 +13,7 @@ namespace Symfony\Component\DependencyInjection\Tests\Loader;
use PHPUnit\Framework\TestCase;
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
use Symfony\Component\DependencyInjection\Argument\BoundArgument;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
@ -776,7 +777,7 @@ class XmlFileLoaderTest extends TestCase
'$foo' => array(null),
'$quz' => 'quz',
'$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(
'quz',
null,
@ -793,6 +794,6 @@ class XmlFileLoaderTest extends TestCase
'NonExistent' => null,
'$quz' => 'quz',
'$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;
use PHPUnit\Framework\TestCase;
use Symfony\Component\DependencyInjection\Argument\BoundArgument;
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;
@ -719,7 +720,7 @@ class YamlFileLoaderTest extends TestCase
'$foo' => array(null),
'$quz' => 'quz',
'$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(
'quz',
null,
@ -736,6 +737,6 @@ class YamlFileLoaderTest extends TestCase
'NonExistent' => null,
'$quz' => 'quz',
'$factory' => 'factory',
), array_map(function ($v) { return $v->getValues()[0]; }, $definition->getBindings()));
), array_map(function (BoundArgument $v) { return $v->getValues()[0]; }, $definition->getBindings()));
}
}