Skip to content

Commit

Permalink
minor #26990 declare types in array_map callbacks (DQNEO)
Browse files Browse the repository at this point in the history
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 #26821

Commits
-------

e7d5634 declare types in array_map callbacks
  • Loading branch information
fabpot committed Apr 22, 2018
2 parents cbc2376 + e7d5634 commit 2ed0c67
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
Expand Up @@ -16,6 +16,7 @@
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;

Expand Down Expand Up @@ -45,7 +46,7 @@ public function __construct(ContainerBuilder $container, PhpFileLoader $loader,
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,
Expand Down
Expand Up @@ -13,6 +13,7 @@

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;
Expand Down Expand Up @@ -776,7 +777,7 @@ public function testBindings()
'$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,
Expand All @@ -793,6 +794,6 @@ public function testBindings()
'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()));
}
}
Expand Up @@ -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;
Expand Down Expand Up @@ -719,7 +720,7 @@ public function testBindings()
'$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,
Expand All @@ -736,6 +737,6 @@ public function testBindings()
'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()));
}
}

0 comments on commit 2ed0c67

Please sign in to comment.