minor #15506 Unpack nested array instead of using temp var (dosten)

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

Discussion
----------

Unpack nested array instead of using temp var

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| License       | MIT

Since php 5.5 we can [unpack nested arrays with `list()`](http://php.net/manual/en/control-structures.foreach.php#control-structures.foreach.list) to avoid temp vars.

Commits
-------

20e9ed6 Unpack nested array instead of using temp var
This commit is contained in:
Fabien Potencier 2015-08-11 23:01:43 +02:00
commit bb4dc7da7f
7 changed files with 8 additions and 19 deletions

View File

@ -159,8 +159,7 @@ class RegisterEventListenersAndSubscribersPassTest extends \PHPUnit_Framework_Te
private function getServiceOrder(ContainerBuilder $container, $method)
{
$order = array();
foreach ($container->getDefinition('doctrine.dbal.default_connection.event_manager')->getMethodCalls() as $call) {
list($name, $arguments) = $call;
foreach ($container->getDefinition('doctrine.dbal.default_connection.event_manager')->getMethodCalls() as list($name, $arguments)) {
if ($method !== $name) {
continue;
}

View File

@ -12,7 +12,6 @@
namespace Symfony\Bundle\SecurityBundle\Tests\DependencyInjection;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\DependencyInjection\Parameter;
use Symfony\Bundle\SecurityBundle\SecurityBundle;
use Symfony\Bundle\SecurityBundle\DependencyInjection\SecurityExtension;
use Symfony\Component\DependencyInjection\ContainerBuilder;
@ -134,8 +133,7 @@ abstract class CompleteConfigurationTest extends \PHPUnit_Framework_TestCase
}
$matcherIds = array();
foreach ($rules as $rule) {
list($matcherId, $attributes, $channel) = $rule;
foreach ($rules as list($matcherId, $attributes, $channel)) {
$requestMatcher = $container->getDefinition($matcherId);
$this->assertFalse(isset($matcherIds[$matcherId]));

View File

@ -45,8 +45,7 @@ class Psr4ClassLoader
{
$class = ltrim($class, '\\');
foreach ($this->prefixes as $current) {
list($currentPrefix, $currentBaseDir) = $current;
foreach ($this->prefixes as list($currentPrefix, $currentBaseDir)) {
if (0 === strpos($class, $currentPrefix)) {
$classWithoutPrefix = substr($class, strlen($currentPrefix));
$file = $currentBaseDir.str_replace('\\', DIRECTORY_SEPARATOR, $classWithoutPrefix).'.php';

View File

@ -330,9 +330,7 @@ class ArrayNode extends BaseNode implements PrototypeNodeInterface
*/
protected function remapXml($value)
{
foreach ($this->xmlRemappings as $transformation) {
list($singular, $plural) = $transformation;
foreach ($this->xmlRemappings as list($singular, $plural)) {
if (!isset($value[$singular])) {
continue;
}

View File

@ -35,8 +35,7 @@ class DecoratorServicePass implements CompilerPassInterface
$definitions->insert(array($id, $definition), array($decorated[2], --$order));
}
foreach ($definitions as $arr) {
list($id, $definition) = $arr;
foreach ($definitions as list($id, $definition)) {
list($inner, $renamedId) = $definition->getDecoratedService();
$definition->setDecoratedService(null);

View File

@ -295,9 +295,7 @@ class XmlFileLoader extends FileLoader
// resolve definitions
krsort($definitions);
foreach ($definitions as $id => $def) {
list($domElement, $file, $wild) = $def;
foreach ($definitions as $id => list($domElement, $file, $wild)) {
// anonymous services are always private
// we could not use the constant false here, because of XML parsing
$domElement->setAttribute('public', 'false');

View File

@ -80,8 +80,7 @@ class ContainerAwareEventDispatcher extends EventDispatcher
$this->lazyLoad($eventName);
if (isset($this->listenerIds[$eventName])) {
foreach ($this->listenerIds[$eventName] as $i => $args) {
list($serviceId, $method, $priority) = $args;
foreach ($this->listenerIds[$eventName] as $i => list($serviceId, $method, $priority)) {
$key = $serviceId.'.'.$method;
if (isset($this->listeners[$eventName][$key]) && $listener === array($this->listeners[$eventName][$key], $method)) {
unset($this->listeners[$eventName][$key]);
@ -183,8 +182,7 @@ class ContainerAwareEventDispatcher extends EventDispatcher
protected function lazyLoad($eventName)
{
if (isset($this->listenerIds[$eventName])) {
foreach ($this->listenerIds[$eventName] as $args) {
list($serviceId, $method, $priority) = $args;
foreach ($this->listenerIds[$eventName] as list($serviceId, $method, $priority)) {
$listener = $this->container->get($serviceId);
$key = $serviceId.'.'.$method;