fixed CS
This commit is contained in:
parent
c0323bd24b
commit
d2098d7e5d
16
.php_cs.dist
16
.php_cs.dist
|
@ -5,26 +5,26 @@ if (!file_exists(__DIR__.'/src')) {
|
|||
}
|
||||
|
||||
return PhpCsFixer\Config::create()
|
||||
->setRules(array(
|
||||
->setRules([
|
||||
'@Symfony' => true,
|
||||
'@Symfony:risky' => true,
|
||||
'@PHPUnit48Migration:risky' => true,
|
||||
'php_unit_no_expectation_annotation' => false, // part of `PHPUnitXYMigration:risky` ruleset, to be enabled when PHPUnit 4.x support will be dropped, as we don't want to rewrite exceptions handling twice
|
||||
'array_syntax' => array('syntax' => 'short'),
|
||||
'array_syntax' => ['syntax' => 'short'],
|
||||
'fopen_flags' => false,
|
||||
'ordered_imports' => true,
|
||||
'protected_to_private' => false,
|
||||
// Part of @Symfony:risky in PHP-CS-Fixer 2.13.0. To be removed from the config file once upgrading
|
||||
'native_function_invocation' => array('include' => array('@compiler_optimized'), 'scope' => 'namespaced'),
|
||||
'native_function_invocation' => ['include' => ['@compiler_optimized'], 'scope' => 'namespaced'],
|
||||
// Part of future @Symfony ruleset in PHP-CS-Fixer To be removed from the config file once upgrading
|
||||
'phpdoc_types_order' => array('null_adjustment' => 'always_last', 'sort_algorithm' => 'none'),
|
||||
))
|
||||
'phpdoc_types_order' => ['null_adjustment' => 'always_last', 'sort_algorithm' => 'none'],
|
||||
])
|
||||
->setRiskyAllowed(true)
|
||||
->setFinder(
|
||||
PhpCsFixer\Finder::create()
|
||||
->in(__DIR__.'/src')
|
||||
->append(array(__FILE__))
|
||||
->exclude(array(
|
||||
->append([__FILE__])
|
||||
->exclude([
|
||||
'Symfony/Bridge/ProxyManager/Tests/LazyProxy/PhpDumper/Fixtures',
|
||||
// directories containing files with content that is autogenerated by `var_export`, which breaks CS in output code
|
||||
'Symfony/Component/DependencyInjection/Tests/Fixtures',
|
||||
|
@ -40,7 +40,7 @@ return PhpCsFixer\Config::create()
|
|||
'Symfony/Bundle/FrameworkBundle/Resources/views/Form',
|
||||
// explicit trigger_error tests
|
||||
'Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/',
|
||||
))
|
||||
])
|
||||
// Support for older PHPunit version
|
||||
->notPath('Symfony/Bridge/PhpUnit/SymfonyTestsListener.php')
|
||||
// file content autogenerated by `var_export`
|
||||
|
|
|
@ -66,13 +66,13 @@ class RegisterEventListenersAndSubscribersPass implements CompilerPassInterface
|
|||
|
||||
foreach ($taggedSubscribers as $taggedSubscriber) {
|
||||
list($id, $tag) = $taggedSubscriber;
|
||||
$connections = isset($tag['connection']) ? array($tag['connection']) : array_keys($this->connections);
|
||||
$connections = isset($tag['connection']) ? [$tag['connection']] : array_keys($this->connections);
|
||||
foreach ($connections as $con) {
|
||||
if (!isset($this->connections[$con])) {
|
||||
throw new RuntimeException(sprintf('The Doctrine connection "%s" referenced in service "%s" does not exist. Available connections names: %s', $con, $id, implode(', ', array_keys($this->connections))));
|
||||
}
|
||||
|
||||
$this->getEventManagerDef($container, $con)->addMethodCall('addEventSubscriber', array(new Reference($id)));
|
||||
$this->getEventManagerDef($container, $con)->addMethodCall('addEventSubscriber', [new Reference($id)]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ class RegisterEventListenersAndSubscribersPass implements CompilerPassInterface
|
|||
{
|
||||
$listenerTag = $this->tagPrefix.'.event_listener';
|
||||
$taggedListeners = $this->findAndSortTags($listenerTag, $container);
|
||||
$listenerRefs = array();
|
||||
$listenerRefs = [];
|
||||
|
||||
foreach ($taggedListeners as $taggedListener) {
|
||||
list($id, $tag) = $taggedListener;
|
||||
|
@ -89,7 +89,7 @@ class RegisterEventListenersAndSubscribersPass implements CompilerPassInterface
|
|||
throw new InvalidArgumentException(sprintf('Doctrine event listener "%s" must specify the "event" attribute.', $id));
|
||||
}
|
||||
|
||||
$connections = isset($tag['connection']) ? array($tag['connection']) : array_keys($this->connections);
|
||||
$connections = isset($tag['connection']) ? [$tag['connection']] : array_keys($this->connections);
|
||||
foreach ($connections as $con) {
|
||||
if (!isset($this->connections[$con])) {
|
||||
throw new RuntimeException(sprintf('The Doctrine connection "%s" referenced in service "%s" does not exist. Available connections names: %s', $con, $id, implode(', ', array_keys($this->connections))));
|
||||
|
@ -97,7 +97,7 @@ class RegisterEventListenersAndSubscribersPass implements CompilerPassInterface
|
|||
$listenerRefs[$con][$id] = new Reference($id);
|
||||
|
||||
// we add one call per event per service so we have the correct order
|
||||
$this->getEventManagerDef($container, $con)->addMethodCall('addEventListener', array(array($tag['event']), $id));
|
||||
$this->getEventManagerDef($container, $con)->addMethodCall('addEventListener', [[$tag['event']], $id]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -135,12 +135,12 @@ class RegisterEventListenersAndSubscribersPass implements CompilerPassInterface
|
|||
*/
|
||||
private function findAndSortTags($tagName, ContainerBuilder $container)
|
||||
{
|
||||
$sortedTags = array();
|
||||
$sortedTags = [];
|
||||
|
||||
foreach ($container->findTaggedServiceIds($tagName, true) as $serviceId => $tags) {
|
||||
foreach ($tags as $attributes) {
|
||||
$priority = isset($attributes['priority']) ? $attributes['priority'] : 0;
|
||||
$sortedTags[$priority][] = array($serviceId, $attributes);
|
||||
$sortedTags[$priority][] = [$serviceId, $attributes];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ class DoctrineOrmTypeGuesser implements FormTypeGuesserInterface
|
|||
{
|
||||
protected $registry;
|
||||
|
||||
private $cache = array();
|
||||
private $cache = [];
|
||||
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
|
@ -39,7 +39,7 @@ class DoctrineOrmTypeGuesser implements FormTypeGuesserInterface
|
|||
public function guessType($class, $property)
|
||||
{
|
||||
if (!$ret = $this->getMetadata($class)) {
|
||||
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\TextType', array(), Guess::LOW_CONFIDENCE);
|
||||
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\TextType', [], Guess::LOW_CONFIDENCE);
|
||||
}
|
||||
|
||||
list($metadata, $name) = $ret;
|
||||
|
@ -48,45 +48,45 @@ class DoctrineOrmTypeGuesser implements FormTypeGuesserInterface
|
|||
$multiple = $metadata->isCollectionValuedAssociation($property);
|
||||
$mapping = $metadata->getAssociationMapping($property);
|
||||
|
||||
return new TypeGuess('Symfony\Bridge\Doctrine\Form\Type\EntityType', array('em' => $name, 'class' => $mapping['targetEntity'], 'multiple' => $multiple), Guess::HIGH_CONFIDENCE);
|
||||
return new TypeGuess('Symfony\Bridge\Doctrine\Form\Type\EntityType', ['em' => $name, 'class' => $mapping['targetEntity'], 'multiple' => $multiple], Guess::HIGH_CONFIDENCE);
|
||||
}
|
||||
|
||||
switch ($metadata->getTypeOfField($property)) {
|
||||
case Type::TARRAY:
|
||||
case Type::SIMPLE_ARRAY:
|
||||
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\CollectionType', array(), Guess::MEDIUM_CONFIDENCE);
|
||||
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\CollectionType', [], Guess::MEDIUM_CONFIDENCE);
|
||||
case Type::BOOLEAN:
|
||||
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\CheckboxType', array(), Guess::HIGH_CONFIDENCE);
|
||||
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\CheckboxType', [], Guess::HIGH_CONFIDENCE);
|
||||
case Type::DATETIME:
|
||||
case Type::DATETIMETZ:
|
||||
case 'vardatetime':
|
||||
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\DateTimeType', array(), Guess::HIGH_CONFIDENCE);
|
||||
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\DateTimeType', [], Guess::HIGH_CONFIDENCE);
|
||||
case 'datetime_immutable':
|
||||
case 'datetimetz_immutable':
|
||||
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\DateTimeType', array('input' => 'datetime_immutable'), Guess::HIGH_CONFIDENCE);
|
||||
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\DateTimeType', ['input' => 'datetime_immutable'], Guess::HIGH_CONFIDENCE);
|
||||
case 'dateinterval':
|
||||
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\DateIntervalType', array(), Guess::HIGH_CONFIDENCE);
|
||||
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\DateIntervalType', [], Guess::HIGH_CONFIDENCE);
|
||||
case Type::DATE:
|
||||
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\DateType', array(), Guess::HIGH_CONFIDENCE);
|
||||
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\DateType', [], Guess::HIGH_CONFIDENCE);
|
||||
case 'date_immutable':
|
||||
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\DateType', array('input' => 'datetime_immutable'), Guess::HIGH_CONFIDENCE);
|
||||
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\DateType', ['input' => 'datetime_immutable'], Guess::HIGH_CONFIDENCE);
|
||||
case Type::TIME:
|
||||
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\TimeType', array(), Guess::HIGH_CONFIDENCE);
|
||||
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\TimeType', [], Guess::HIGH_CONFIDENCE);
|
||||
case 'time_immutable':
|
||||
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\TimeType', array('input' => 'datetime_immutable'), Guess::HIGH_CONFIDENCE);
|
||||
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\TimeType', ['input' => 'datetime_immutable'], Guess::HIGH_CONFIDENCE);
|
||||
case Type::DECIMAL:
|
||||
case Type::FLOAT:
|
||||
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\NumberType', array(), Guess::MEDIUM_CONFIDENCE);
|
||||
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\NumberType', [], Guess::MEDIUM_CONFIDENCE);
|
||||
case Type::INTEGER:
|
||||
case Type::BIGINT:
|
||||
case Type::SMALLINT:
|
||||
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\IntegerType', array(), Guess::MEDIUM_CONFIDENCE);
|
||||
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\IntegerType', [], Guess::MEDIUM_CONFIDENCE);
|
||||
case Type::STRING:
|
||||
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\TextType', array(), Guess::MEDIUM_CONFIDENCE);
|
||||
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\TextType', [], Guess::MEDIUM_CONFIDENCE);
|
||||
case Type::TEXT:
|
||||
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\TextareaType', array(), Guess::MEDIUM_CONFIDENCE);
|
||||
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\TextareaType', [], Guess::MEDIUM_CONFIDENCE);
|
||||
default:
|
||||
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\TextType', array(), Guess::LOW_CONFIDENCE);
|
||||
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\TextType', [], Guess::LOW_CONFIDENCE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -141,7 +141,7 @@ class DoctrineOrmTypeGuesser implements FormTypeGuesserInterface
|
|||
return new ValueGuess($mapping['length'], Guess::HIGH_CONFIDENCE);
|
||||
}
|
||||
|
||||
if (\in_array($ret[0]->getTypeOfField($property), array(Type::DECIMAL, Type::FLOAT))) {
|
||||
if (\in_array($ret[0]->getTypeOfField($property), [Type::DECIMAL, Type::FLOAT])) {
|
||||
return new ValueGuess(null, Guess::MEDIUM_CONFIDENCE);
|
||||
}
|
||||
}
|
||||
|
@ -154,7 +154,7 @@ class DoctrineOrmTypeGuesser implements FormTypeGuesserInterface
|
|||
{
|
||||
$ret = $this->getMetadata($class);
|
||||
if ($ret && isset($ret[0]->fieldMappings[$property]) && !$ret[0]->hasAssociation($property)) {
|
||||
if (\in_array($ret[0]->getTypeOfField($property), array(Type::DECIMAL, Type::FLOAT))) {
|
||||
if (\in_array($ret[0]->getTypeOfField($property), [Type::DECIMAL, Type::FLOAT])) {
|
||||
return new ValueGuess(null, Guess::MEDIUM_CONFIDENCE);
|
||||
}
|
||||
}
|
||||
|
@ -172,7 +172,7 @@ class DoctrineOrmTypeGuesser implements FormTypeGuesserInterface
|
|||
$this->cache[$class] = null;
|
||||
foreach ($this->registry->getManagers() as $name => $em) {
|
||||
try {
|
||||
return $this->cache[$class] = array($em->getClassMetadata($class), $name);
|
||||
return $this->cache[$class] = [$em->getClassMetadata($class), $name];
|
||||
} catch (MappingException $e) {
|
||||
// not an entity or mapped super class
|
||||
} catch (LegacyMappingException $e) {
|
||||
|
|
|
@ -46,7 +46,7 @@ class RegisterEventListenersAndSubscribersPassTest extends TestCase
|
|||
|
||||
$abstractDefinition = new Definition('stdClass');
|
||||
$abstractDefinition->setAbstract(true);
|
||||
$abstractDefinition->addTag('doctrine.event_listener', array('event' => 'test'));
|
||||
$abstractDefinition->addTag('doctrine.event_listener', ['event' => 'test']);
|
||||
|
||||
$container->setDefinition('a', $abstractDefinition);
|
||||
|
||||
|
@ -60,30 +60,30 @@ class RegisterEventListenersAndSubscribersPassTest extends TestCase
|
|||
$container
|
||||
->register('a', 'stdClass')
|
||||
->setPublic(false)
|
||||
->addTag('doctrine.event_listener', array(
|
||||
->addTag('doctrine.event_listener', [
|
||||
'event' => 'bar',
|
||||
))
|
||||
->addTag('doctrine.event_listener', array(
|
||||
])
|
||||
->addTag('doctrine.event_listener', [
|
||||
'event' => 'foo',
|
||||
'priority' => -5,
|
||||
))
|
||||
->addTag('doctrine.event_listener', array(
|
||||
])
|
||||
->addTag('doctrine.event_listener', [
|
||||
'event' => 'foo_bar',
|
||||
'priority' => 3,
|
||||
))
|
||||
])
|
||||
;
|
||||
$container
|
||||
->register('b', 'stdClass')
|
||||
->addTag('doctrine.event_listener', array(
|
||||
->addTag('doctrine.event_listener', [
|
||||
'event' => 'foo',
|
||||
))
|
||||
])
|
||||
;
|
||||
$container
|
||||
->register('c', 'stdClass')
|
||||
->addTag('doctrine.event_listener', array(
|
||||
->addTag('doctrine.event_listener', [
|
||||
'event' => 'foo_bar',
|
||||
'priority' => 4,
|
||||
))
|
||||
])
|
||||
;
|
||||
|
||||
$this->process($container);
|
||||
|
@ -91,24 +91,24 @@ class RegisterEventListenersAndSubscribersPassTest extends TestCase
|
|||
$methodCalls = $eventManagerDef->getMethodCalls();
|
||||
|
||||
$this->assertEquals(
|
||||
array(
|
||||
array('addEventListener', array(array('foo_bar'), 'c')),
|
||||
array('addEventListener', array(array('foo_bar'), 'a')),
|
||||
array('addEventListener', array(array('bar'), 'a')),
|
||||
array('addEventListener', array(array('foo'), 'b')),
|
||||
array('addEventListener', array(array('foo'), 'a')),
|
||||
),
|
||||
[
|
||||
['addEventListener', [['foo_bar'], 'c']],
|
||||
['addEventListener', [['foo_bar'], 'a']],
|
||||
['addEventListener', [['bar'], 'a']],
|
||||
['addEventListener', [['foo'], 'b']],
|
||||
['addEventListener', [['foo'], 'a']],
|
||||
],
|
||||
$methodCalls
|
||||
);
|
||||
|
||||
$serviceLocatorDef = $container->getDefinition((string) $eventManagerDef->getArgument(0));
|
||||
$this->assertSame(ServiceLocator::class, $serviceLocatorDef->getClass());
|
||||
$this->assertEquals(
|
||||
array(
|
||||
[
|
||||
'c' => new ServiceClosureArgument(new Reference('c')),
|
||||
'a' => new ServiceClosureArgument(new Reference('a')),
|
||||
'b' => new ServiceClosureArgument(new Reference('b')),
|
||||
),
|
||||
],
|
||||
$serviceLocatorDef->getArgument(0)
|
||||
);
|
||||
}
|
||||
|
@ -119,25 +119,25 @@ class RegisterEventListenersAndSubscribersPassTest extends TestCase
|
|||
|
||||
$container
|
||||
->register('a', 'stdClass')
|
||||
->addTag('doctrine.event_listener', array(
|
||||
->addTag('doctrine.event_listener', [
|
||||
'event' => 'onFlush',
|
||||
))
|
||||
])
|
||||
;
|
||||
|
||||
$container
|
||||
->register('b', 'stdClass')
|
||||
->addTag('doctrine.event_listener', array(
|
||||
->addTag('doctrine.event_listener', [
|
||||
'event' => 'onFlush',
|
||||
'connection' => 'default',
|
||||
))
|
||||
])
|
||||
;
|
||||
|
||||
$container
|
||||
->register('c', 'stdClass')
|
||||
->addTag('doctrine.event_listener', array(
|
||||
->addTag('doctrine.event_listener', [
|
||||
'event' => 'onFlush',
|
||||
'connection' => 'second',
|
||||
))
|
||||
])
|
||||
;
|
||||
|
||||
$this->process($container);
|
||||
|
@ -146,40 +146,40 @@ class RegisterEventListenersAndSubscribersPassTest extends TestCase
|
|||
|
||||
// first connection
|
||||
$this->assertEquals(
|
||||
array(
|
||||
array('addEventListener', array(array('onFlush'), 'a')),
|
||||
array('addEventListener', array(array('onFlush'), 'b')),
|
||||
),
|
||||
[
|
||||
['addEventListener', [['onFlush'], 'a']],
|
||||
['addEventListener', [['onFlush'], 'b']],
|
||||
],
|
||||
$eventManagerDef->getMethodCalls()
|
||||
);
|
||||
|
||||
$serviceLocatorDef = $container->getDefinition((string) $eventManagerDef->getArgument(0));
|
||||
$this->assertSame(ServiceLocator::class, $serviceLocatorDef->getClass());
|
||||
$this->assertEquals(
|
||||
array(
|
||||
[
|
||||
'a' => new ServiceClosureArgument(new Reference('a')),
|
||||
'b' => new ServiceClosureArgument(new Reference('b')),
|
||||
),
|
||||
],
|
||||
$serviceLocatorDef->getArgument(0)
|
||||
);
|
||||
|
||||
// second connection
|
||||
$secondEventManagerDef = $container->getDefinition('doctrine.dbal.second_connection.event_manager');
|
||||
$this->assertEquals(
|
||||
array(
|
||||
array('addEventListener', array(array('onFlush'), 'a')),
|
||||
array('addEventListener', array(array('onFlush'), 'c')),
|
||||
),
|
||||
[
|
||||
['addEventListener', [['onFlush'], 'a']],
|
||||
['addEventListener', [['onFlush'], 'c']],
|
||||
],
|
||||
$secondEventManagerDef->getMethodCalls()
|
||||
);
|
||||
|
||||
$serviceLocatorDef = $container->getDefinition((string) $secondEventManagerDef->getArgument(0));
|
||||
$this->assertSame(ServiceLocator::class, $serviceLocatorDef->getClass());
|
||||
$this->assertEquals(
|
||||
array(
|
||||
[
|
||||
'a' => new ServiceClosureArgument(new Reference('a')),
|
||||
'c' => new ServiceClosureArgument(new Reference('c')),
|
||||
),
|
||||
],
|
||||
$serviceLocatorDef->getArgument(0)
|
||||
);
|
||||
}
|
||||
|
@ -190,42 +190,42 @@ class RegisterEventListenersAndSubscribersPassTest extends TestCase
|
|||
|
||||
$container
|
||||
->register('a', 'stdClass')
|
||||
->addTag('doctrine.event_subscriber', array(
|
||||
->addTag('doctrine.event_subscriber', [
|
||||
'event' => 'onFlush',
|
||||
))
|
||||
])
|
||||
;
|
||||
|
||||
$container
|
||||
->register('b', 'stdClass')
|
||||
->addTag('doctrine.event_subscriber', array(
|
||||
->addTag('doctrine.event_subscriber', [
|
||||
'event' => 'onFlush',
|
||||
'connection' => 'default',
|
||||
))
|
||||
])
|
||||
;
|
||||
|
||||
$container
|
||||
->register('c', 'stdClass')
|
||||
->addTag('doctrine.event_subscriber', array(
|
||||
->addTag('doctrine.event_subscriber', [
|
||||
'event' => 'onFlush',
|
||||
'connection' => 'second',
|
||||
))
|
||||
])
|
||||
;
|
||||
|
||||
$this->process($container);
|
||||
|
||||
$this->assertEquals(
|
||||
array(
|
||||
array('addEventSubscriber', array(new Reference('a'))),
|
||||
array('addEventSubscriber', array(new Reference('b'))),
|
||||
),
|
||||
[
|
||||
['addEventSubscriber', [new Reference('a')]],
|
||||
['addEventSubscriber', [new Reference('b')]],
|
||||
],
|
||||
$container->getDefinition('doctrine.dbal.default_connection.event_manager')->getMethodCalls()
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
array(
|
||||
array('addEventSubscriber', array(new Reference('a'))),
|
||||
array('addEventSubscriber', array(new Reference('c'))),
|
||||
),
|
||||
[
|
||||
['addEventSubscriber', [new Reference('a')]],
|
||||
['addEventSubscriber', [new Reference('c')]],
|
||||
],
|
||||
$container->getDefinition('doctrine.dbal.second_connection.event_manager')->getMethodCalls()
|
||||
);
|
||||
}
|
||||
|
@ -240,39 +240,39 @@ class RegisterEventListenersAndSubscribersPassTest extends TestCase
|
|||
;
|
||||
$container
|
||||
->register('b', 'stdClass')
|
||||
->addTag('doctrine.event_subscriber', array(
|
||||
->addTag('doctrine.event_subscriber', [
|
||||
'priority' => 5,
|
||||
))
|
||||
])
|
||||
;
|
||||
$container
|
||||
->register('c', 'stdClass')
|
||||
->addTag('doctrine.event_subscriber', array(
|
||||
->addTag('doctrine.event_subscriber', [
|
||||
'priority' => 10,
|
||||
))
|
||||
])
|
||||
;
|
||||
$container
|
||||
->register('d', 'stdClass')
|
||||
->addTag('doctrine.event_subscriber', array(
|
||||
->addTag('doctrine.event_subscriber', [
|
||||
'priority' => 10,
|
||||
))
|
||||
])
|
||||
;
|
||||
$container
|
||||
->register('e', 'stdClass')
|
||||
->addTag('doctrine.event_subscriber', array(
|
||||
->addTag('doctrine.event_subscriber', [
|
||||
'priority' => 10,
|
||||
))
|
||||
])
|
||||
;
|
||||
|
||||
$this->process($container);
|
||||
|
||||
$this->assertEquals(
|
||||
array(
|
||||
array('addEventSubscriber', array(new Reference('c'))),
|
||||
array('addEventSubscriber', array(new Reference('d'))),
|
||||
array('addEventSubscriber', array(new Reference('e'))),
|
||||
array('addEventSubscriber', array(new Reference('b'))),
|
||||
array('addEventSubscriber', array(new Reference('a'))),
|
||||
),
|
||||
[
|
||||
['addEventSubscriber', [new Reference('c')]],
|
||||
['addEventSubscriber', [new Reference('d')]],
|
||||
['addEventSubscriber', [new Reference('e')]],
|
||||
['addEventSubscriber', [new Reference('b')]],
|
||||
['addEventSubscriber', [new Reference('a')]],
|
||||
],
|
||||
$container->getDefinition('doctrine.dbal.default_connection.event_manager')->getMethodCalls()
|
||||
);
|
||||
}
|
||||
|
@ -283,9 +283,9 @@ class RegisterEventListenersAndSubscribersPassTest extends TestCase
|
|||
|
||||
$this->process($container);
|
||||
|
||||
$this->assertEquals(array(), $container->getDefinition('doctrine.dbal.default_connection.event_manager')->getMethodCalls());
|
||||
$this->assertEquals([], $container->getDefinition('doctrine.dbal.default_connection.event_manager')->getMethodCalls());
|
||||
|
||||
$this->assertEquals(array(), $container->getDefinition('doctrine.dbal.second_connection.event_manager')->getMethodCalls());
|
||||
$this->assertEquals([], $container->getDefinition('doctrine.dbal.second_connection.event_manager')->getMethodCalls());
|
||||
}
|
||||
|
||||
private function process(ContainerBuilder $container)
|
||||
|
@ -298,7 +298,7 @@ class RegisterEventListenersAndSubscribersPassTest extends TestCase
|
|||
{
|
||||
$container = new ContainerBuilder();
|
||||
|
||||
$connections = array('default' => 'doctrine.dbal.default_connection');
|
||||
$connections = ['default' => 'doctrine.dbal.default_connection'];
|
||||
|
||||
$container->register('doctrine.dbal.default_connection.event_manager', 'stdClass')
|
||||
->addArgument(new Reference('service_container'));
|
||||
|
|
|
@ -32,13 +32,13 @@ class DoctrineExtensionTest extends TestCase
|
|||
|
||||
$this->extension = $this
|
||||
->getMockBuilder('Symfony\Bridge\Doctrine\DependencyInjection\AbstractDoctrineExtension')
|
||||
->setMethods(array(
|
||||
->setMethods([
|
||||
'getMappingResourceConfigDirectory',
|
||||
'getObjectManagerElementName',
|
||||
'getMappingObjectDefaultName',
|
||||
'getMappingResourceExtension',
|
||||
'load',
|
||||
))
|
||||
])
|
||||
->getMock()
|
||||
;
|
||||
|
||||
|
@ -54,19 +54,19 @@ class DoctrineExtensionTest extends TestCase
|
|||
*/
|
||||
public function testFixManagersAutoMappingsWithTwoAutomappings()
|
||||
{
|
||||
$emConfigs = array(
|
||||
'em1' => array(
|
||||
$emConfigs = [
|
||||
'em1' => [
|
||||
'auto_mapping' => true,
|
||||
),
|
||||
'em2' => array(
|
||||
],
|
||||
'em2' => [
|
||||
'auto_mapping' => true,
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
$bundles = array(
|
||||
$bundles = [
|
||||
'FirstBundle' => 'My\FirstBundle',
|
||||
'SecondBundle' => 'My\SecondBundle',
|
||||
);
|
||||
];
|
||||
|
||||
$reflection = new \ReflectionClass(\get_class($this->extension));
|
||||
$method = $reflection->getMethod('fixManagersAutoMappings');
|
||||
|
@ -77,69 +77,69 @@ class DoctrineExtensionTest extends TestCase
|
|||
|
||||
public function getAutomappingData()
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
array( // no auto mapping on em1
|
||||
return [
|
||||
[
|
||||
[ // no auto mapping on em1
|
||||
'auto_mapping' => false,
|
||||
),
|
||||
array( // no auto mapping on em2
|
||||
],
|
||||
[ // no auto mapping on em2
|
||||
'auto_mapping' => false,
|
||||
),
|
||||
array(),
|
||||
array(),
|
||||
),
|
||||
array(
|
||||
array( // no auto mapping on em1
|
||||
],
|
||||
[],
|
||||
[],
|
||||
],
|
||||
[
|
||||
[ // no auto mapping on em1
|
||||
'auto_mapping' => false,
|
||||
),
|
||||
array( // auto mapping enabled on em2
|
||||
],
|
||||
[ // auto mapping enabled on em2
|
||||
'auto_mapping' => true,
|
||||
),
|
||||
array(),
|
||||
array(
|
||||
'mappings' => array(
|
||||
'FirstBundle' => array(
|
||||
],
|
||||
[],
|
||||
[
|
||||
'mappings' => [
|
||||
'FirstBundle' => [
|
||||
'mapping' => true,
|
||||
'is_bundle' => true,
|
||||
),
|
||||
'SecondBundle' => array(
|
||||
],
|
||||
'SecondBundle' => [
|
||||
'mapping' => true,
|
||||
'is_bundle' => true,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
array(
|
||||
array( // no auto mapping on em1, but it defines SecondBundle as own
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
[
|
||||
[ // no auto mapping on em1, but it defines SecondBundle as own
|
||||
'auto_mapping' => false,
|
||||
'mappings' => array(
|
||||
'SecondBundle' => array(
|
||||
'mappings' => [
|
||||
'SecondBundle' => [
|
||||
'mapping' => true,
|
||||
'is_bundle' => true,
|
||||
),
|
||||
),
|
||||
),
|
||||
array( // auto mapping enabled on em2
|
||||
],
|
||||
],
|
||||
],
|
||||
[ // auto mapping enabled on em2
|
||||
'auto_mapping' => true,
|
||||
),
|
||||
array(
|
||||
'mappings' => array(
|
||||
'SecondBundle' => array(
|
||||
],
|
||||
[
|
||||
'mappings' => [
|
||||
'SecondBundle' => [
|
||||
'mapping' => true,
|
||||
'is_bundle' => true,
|
||||
),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'mappings' => array(
|
||||
'FirstBundle' => array(
|
||||
],
|
||||
],
|
||||
],
|
||||
[
|
||||
'mappings' => [
|
||||
'FirstBundle' => [
|
||||
'mapping' => true,
|
||||
'is_bundle' => true,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -147,15 +147,15 @@ class DoctrineExtensionTest extends TestCase
|
|||
*/
|
||||
public function testFixManagersAutoMappings(array $originalEm1, array $originalEm2, array $expectedEm1, array $expectedEm2)
|
||||
{
|
||||
$emConfigs = array(
|
||||
$emConfigs = [
|
||||
'em1' => $originalEm1,
|
||||
'em2' => $originalEm2,
|
||||
);
|
||||
];
|
||||
|
||||
$bundles = array(
|
||||
$bundles = [
|
||||
'FirstBundle' => 'My\FirstBundle',
|
||||
'SecondBundle' => 'My\SecondBundle',
|
||||
);
|
||||
];
|
||||
|
||||
$reflection = new \ReflectionClass(\get_class($this->extension));
|
||||
$method = $reflection->getMethod('fixManagersAutoMappings');
|
||||
|
@ -163,39 +163,39 @@ class DoctrineExtensionTest extends TestCase
|
|||
|
||||
$newEmConfigs = $method->invoke($this->extension, $emConfigs, $bundles);
|
||||
|
||||
$this->assertEquals($newEmConfigs['em1'], array_merge(array(
|
||||
$this->assertEquals($newEmConfigs['em1'], array_merge([
|
||||
'auto_mapping' => false,
|
||||
), $expectedEm1));
|
||||
$this->assertEquals($newEmConfigs['em2'], array_merge(array(
|
||||
], $expectedEm1));
|
||||
$this->assertEquals($newEmConfigs['em2'], array_merge([
|
||||
'auto_mapping' => false,
|
||||
), $expectedEm2));
|
||||
], $expectedEm2));
|
||||
}
|
||||
|
||||
public function providerBasicDrivers()
|
||||
{
|
||||
return array(
|
||||
array('doctrine.orm.cache.apc.class', array('type' => 'apc')),
|
||||
array('doctrine.orm.cache.apcu.class', array('type' => 'apcu')),
|
||||
array('doctrine.orm.cache.array.class', array('type' => 'array')),
|
||||
array('doctrine.orm.cache.xcache.class', array('type' => 'xcache')),
|
||||
array('doctrine.orm.cache.wincache.class', array('type' => 'wincache')),
|
||||
array('doctrine.orm.cache.zenddata.class', array('type' => 'zenddata')),
|
||||
array('doctrine.orm.cache.redis.class', array('type' => 'redis'), array('setRedis')),
|
||||
array('doctrine.orm.cache.memcached.class', array('type' => 'memcached'), array('setMemcached')),
|
||||
);
|
||||
return [
|
||||
['doctrine.orm.cache.apc.class', ['type' => 'apc']],
|
||||
['doctrine.orm.cache.apcu.class', ['type' => 'apcu']],
|
||||
['doctrine.orm.cache.array.class', ['type' => 'array']],
|
||||
['doctrine.orm.cache.xcache.class', ['type' => 'xcache']],
|
||||
['doctrine.orm.cache.wincache.class', ['type' => 'wincache']],
|
||||
['doctrine.orm.cache.zenddata.class', ['type' => 'zenddata']],
|
||||
['doctrine.orm.cache.redis.class', ['type' => 'redis'], ['setRedis']],
|
||||
['doctrine.orm.cache.memcached.class', ['type' => 'memcached'], ['setMemcached']],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerBasicDrivers
|
||||
*/
|
||||
public function testLoadBasicCacheDriver(string $class, array $config, array $expectedCalls = array())
|
||||
public function testLoadBasicCacheDriver(string $class, array $config, array $expectedCalls = [])
|
||||
{
|
||||
$container = $this->createContainer();
|
||||
$cacheName = 'metadata_cache';
|
||||
$objectManager = array(
|
||||
$objectManager = [
|
||||
'name' => 'default',
|
||||
'metadata_cache_driver' => $config,
|
||||
);
|
||||
];
|
||||
|
||||
$this->invokeLoadCacheDriver($objectManager, $container, $cacheName);
|
||||
|
||||
|
@ -219,13 +219,13 @@ class DoctrineExtensionTest extends TestCase
|
|||
$cacheName = 'metadata_cache';
|
||||
$container = $this->createContainer();
|
||||
$definition = new Definition('%doctrine.orm.cache.apc.class%');
|
||||
$objectManager = array(
|
||||
$objectManager = [
|
||||
'name' => 'default',
|
||||
'metadata_cache_driver' => array(
|
||||
'metadata_cache_driver' => [
|
||||
'type' => 'service',
|
||||
'id' => 'service_driver',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
$container->setDefinition('service_driver', $definition);
|
||||
|
||||
|
@ -242,12 +242,12 @@ class DoctrineExtensionTest extends TestCase
|
|||
{
|
||||
$cacheName = 'metadata_cache';
|
||||
$container = $this->createContainer();
|
||||
$objectManager = array(
|
||||
$objectManager = [
|
||||
'name' => 'default',
|
||||
'metadata_cache_driver' => array(
|
||||
'metadata_cache_driver' => [
|
||||
'type' => 'unrecognized_type',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
$this->invokeLoadCacheDriver($objectManager, $container, $cacheName);
|
||||
}
|
||||
|
@ -258,19 +258,19 @@ class DoctrineExtensionTest extends TestCase
|
|||
|
||||
$method->setAccessible(true);
|
||||
|
||||
$method->invokeArgs($this->extension, array($objectManager, $container, $cacheName));
|
||||
$method->invokeArgs($this->extension, [$objectManager, $container, $cacheName]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Symfony\Component\DependencyInjection\ContainerBuilder
|
||||
*/
|
||||
protected function createContainer(array $data = array())
|
||||
protected function createContainer(array $data = [])
|
||||
{
|
||||
return new ContainerBuilder(new ParameterBag(array_merge(array(
|
||||
'kernel.bundles' => array('FrameworkBundle' => 'Symfony\\Bundle\\FrameworkBundle\\FrameworkBundle'),
|
||||
return new ContainerBuilder(new ParameterBag(array_merge([
|
||||
'kernel.bundles' => ['FrameworkBundle' => 'Symfony\\Bundle\\FrameworkBundle\\FrameworkBundle'],
|
||||
'kernel.cache_dir' => __DIR__,
|
||||
'kernel.container_class' => 'kernel',
|
||||
'kernel.project_dir' => __DIR__,
|
||||
), $data)));
|
||||
], $data)));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,8 +25,8 @@ class DoctrineExtractorTest extends TestCase
|
|||
{
|
||||
private function createExtractor(bool $legacy = false)
|
||||
{
|
||||
$config = Setup::createAnnotationMetadataConfiguration(array(__DIR__.\DIRECTORY_SEPARATOR.'Fixtures'), true);
|
||||
$entityManager = EntityManager::create(array('driver' => 'pdo_sqlite'), $config);
|
||||
$config = Setup::createAnnotationMetadataConfiguration([__DIR__.\DIRECTORY_SEPARATOR.'Fixtures'], true);
|
||||
$entityManager = EntityManager::create(['driver' => 'pdo_sqlite'], $config);
|
||||
|
||||
if (!DBALType::hasType('foo')) {
|
||||
DBALType::addType('foo', 'Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineFooType');
|
||||
|
@ -49,7 +49,7 @@ class DoctrineExtractorTest extends TestCase
|
|||
private function doTestGetProperties(bool $legacy)
|
||||
{
|
||||
$this->assertEquals(
|
||||
array(
|
||||
[
|
||||
'id',
|
||||
'guid',
|
||||
'time',
|
||||
|
@ -67,7 +67,7 @@ class DoctrineExtractorTest extends TestCase
|
|||
'bar',
|
||||
'indexedBar',
|
||||
'indexedFoo',
|
||||
),
|
||||
],
|
||||
$this->createExtractor($legacy)->getProperties('Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineDummy')
|
||||
);
|
||||
}
|
||||
|
@ -89,10 +89,10 @@ class DoctrineExtractorTest extends TestCase
|
|||
}
|
||||
|
||||
$this->assertEquals(
|
||||
array(
|
||||
[
|
||||
'id',
|
||||
'embedded',
|
||||
),
|
||||
],
|
||||
$this->createExtractor($legacy)->getProperties('Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineWithEmbedded')
|
||||
);
|
||||
}
|
||||
|
@ -115,7 +115,7 @@ class DoctrineExtractorTest extends TestCase
|
|||
|
||||
private function doTestExtract(bool $legacy, $property, array $type = null)
|
||||
{
|
||||
$this->assertEquals($type, $this->createExtractor($legacy)->getTypes('Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineDummy', $property, array()));
|
||||
$this->assertEquals($type, $this->createExtractor($legacy)->getTypes('Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineDummy', $property, []));
|
||||
}
|
||||
|
||||
public function testExtractWithEmbedded()
|
||||
|
@ -134,16 +134,16 @@ class DoctrineExtractorTest extends TestCase
|
|||
$this->markTestSkipped('@Embedded is not available in Doctrine ORM lower than 2.5.');
|
||||
}
|
||||
|
||||
$expectedTypes = array(new Type(
|
||||
$expectedTypes = [new Type(
|
||||
Type::BUILTIN_TYPE_OBJECT,
|
||||
false,
|
||||
'Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineEmbeddable'
|
||||
));
|
||||
)];
|
||||
|
||||
$actualTypes = $this->createExtractor($legacy)->getTypes(
|
||||
'Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineWithEmbedded',
|
||||
'embedded',
|
||||
array()
|
||||
[]
|
||||
);
|
||||
|
||||
$this->assertEquals($expectedTypes, $actualTypes);
|
||||
|
@ -151,47 +151,47 @@ class DoctrineExtractorTest extends TestCase
|
|||
|
||||
public function typesProvider()
|
||||
{
|
||||
return array(
|
||||
array('id', array(new Type(Type::BUILTIN_TYPE_INT))),
|
||||
array('guid', array(new Type(Type::BUILTIN_TYPE_STRING))),
|
||||
array('bigint', array(new Type(Type::BUILTIN_TYPE_STRING))),
|
||||
array('time', array(new Type(Type::BUILTIN_TYPE_OBJECT, false, 'DateTime'))),
|
||||
array('timeImmutable', array(new Type(Type::BUILTIN_TYPE_OBJECT, false, 'DateTimeImmutable'))),
|
||||
array('dateInterval', array(new Type(Type::BUILTIN_TYPE_OBJECT, false, 'DateInterval'))),
|
||||
array('float', array(new Type(Type::BUILTIN_TYPE_FLOAT))),
|
||||
array('decimal', array(new Type(Type::BUILTIN_TYPE_STRING))),
|
||||
array('bool', array(new Type(Type::BUILTIN_TYPE_BOOL))),
|
||||
array('binary', array(new Type(Type::BUILTIN_TYPE_RESOURCE))),
|
||||
array('json', array(new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true))),
|
||||
array('foo', array(new Type(Type::BUILTIN_TYPE_OBJECT, true, 'Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineRelation'))),
|
||||
array('bar', array(new Type(
|
||||
return [
|
||||
['id', [new Type(Type::BUILTIN_TYPE_INT)]],
|
||||
['guid', [new Type(Type::BUILTIN_TYPE_STRING)]],
|
||||
['bigint', [new Type(Type::BUILTIN_TYPE_STRING)]],
|
||||
['time', [new Type(Type::BUILTIN_TYPE_OBJECT, false, 'DateTime')]],
|
||||
['timeImmutable', [new Type(Type::BUILTIN_TYPE_OBJECT, false, 'DateTimeImmutable')]],
|
||||
['dateInterval', [new Type(Type::BUILTIN_TYPE_OBJECT, false, 'DateInterval')]],
|
||||
['float', [new Type(Type::BUILTIN_TYPE_FLOAT)]],
|
||||
['decimal', [new Type(Type::BUILTIN_TYPE_STRING)]],
|
||||
['bool', [new Type(Type::BUILTIN_TYPE_BOOL)]],
|
||||
['binary', [new Type(Type::BUILTIN_TYPE_RESOURCE)]],
|
||||
['json', [new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true)]],
|
||||
['foo', [new Type(Type::BUILTIN_TYPE_OBJECT, true, 'Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineRelation')]],
|
||||
['bar', [new Type(
|
||||
Type::BUILTIN_TYPE_OBJECT,
|
||||
false,
|
||||
'Doctrine\Common\Collections\Collection',
|
||||
true,
|
||||
new Type(Type::BUILTIN_TYPE_INT),
|
||||
new Type(Type::BUILTIN_TYPE_OBJECT, false, 'Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineRelation')
|
||||
))),
|
||||
array('indexedBar', array(new Type(
|
||||
)]],
|
||||
['indexedBar', [new Type(
|
||||
Type::BUILTIN_TYPE_OBJECT,
|
||||
false,
|
||||
'Doctrine\Common\Collections\Collection',
|
||||
true,
|
||||
new Type(Type::BUILTIN_TYPE_STRING),
|
||||
new Type(Type::BUILTIN_TYPE_OBJECT, false, 'Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineRelation')
|
||||
))),
|
||||
array('indexedFoo', array(new Type(
|
||||
)]],
|
||||
['indexedFoo', [new Type(
|
||||
Type::BUILTIN_TYPE_OBJECT,
|
||||
false,
|
||||
'Doctrine\Common\Collections\Collection',
|
||||
true,
|
||||
new Type(Type::BUILTIN_TYPE_STRING),
|
||||
new Type(Type::BUILTIN_TYPE_OBJECT, false, 'Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineRelation')
|
||||
))),
|
||||
array('simpleArray', array(new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true, new Type(Type::BUILTIN_TYPE_INT), new Type(Type::BUILTIN_TYPE_STRING)))),
|
||||
array('customFoo', null),
|
||||
array('notMapped', null),
|
||||
);
|
||||
)]],
|
||||
['simpleArray', [new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true, new Type(Type::BUILTIN_TYPE_INT), new Type(Type::BUILTIN_TYPE_STRING))]],
|
||||
['customFoo', null],
|
||||
['notMapped', null],
|
||||
];
|
||||
}
|
||||
|
||||
public function testGetPropertiesCatchException()
|
||||
|
|
|
@ -36,7 +36,7 @@ class Logger extends BaseLogger implements DebugLoggerInterface, ResetInterface
|
|||
return $logger->getLogs(...\func_get_args());
|
||||
}
|
||||
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -22,16 +22,16 @@ class LoggerTest extends TestCase
|
|||
public function testGetLogsWithoutDebugProcessor()
|
||||
{
|
||||
$handler = new TestHandler();
|
||||
$logger = new Logger(__METHOD__, array($handler));
|
||||
$logger = new Logger(__METHOD__, [$handler]);
|
||||
|
||||
$logger->error('error message');
|
||||
$this->assertSame(array(), $logger->getLogs());
|
||||
$this->assertSame([], $logger->getLogs());
|
||||
}
|
||||
|
||||
public function testCountErrorsWithoutDebugProcessor()
|
||||
{
|
||||
$handler = new TestHandler();
|
||||
$logger = new Logger(__METHOD__, array($handler));
|
||||
$logger = new Logger(__METHOD__, [$handler]);
|
||||
|
||||
$logger->error('error message');
|
||||
$this->assertSame(0, $logger->countErrors());
|
||||
|
@ -41,7 +41,7 @@ class LoggerTest extends TestCase
|
|||
{
|
||||
$handler = new TestHandler();
|
||||
$processor = new DebugProcessor();
|
||||
$logger = new Logger(__METHOD__, array($handler), array($processor));
|
||||
$logger = new Logger(__METHOD__, [$handler], [$processor]);
|
||||
|
||||
$logger->error('error message');
|
||||
$this->assertCount(1, $logger->getLogs());
|
||||
|
@ -51,7 +51,7 @@ class LoggerTest extends TestCase
|
|||
{
|
||||
$handler = new TestHandler();
|
||||
$processor = new DebugProcessor();
|
||||
$logger = new Logger(__METHOD__, array($handler), array($processor));
|
||||
$logger = new Logger(__METHOD__, [$handler], [$processor]);
|
||||
|
||||
$logger->debug('test message');
|
||||
$logger->info('test message');
|
||||
|
@ -69,7 +69,7 @@ class LoggerTest extends TestCase
|
|||
public function testGetLogsWithDebugProcessor2()
|
||||
{
|
||||
$handler = new TestHandler();
|
||||
$logger = new Logger('test', array($handler));
|
||||
$logger = new Logger('test', [$handler]);
|
||||
$logger->pushProcessor(new DebugProcessor());
|
||||
|
||||
$logger->info('test');
|
||||
|
@ -88,7 +88,7 @@ class LoggerTest extends TestCase
|
|||
$processor->expects($this->once())->method('countErrors')->with($request);
|
||||
|
||||
$handler = new TestHandler();
|
||||
$logger = new Logger('test', array($handler));
|
||||
$logger = new Logger('test', [$handler]);
|
||||
$logger->pushProcessor($processor);
|
||||
|
||||
$logger->getLogs($request);
|
||||
|
@ -98,7 +98,7 @@ class LoggerTest extends TestCase
|
|||
public function testClear()
|
||||
{
|
||||
$handler = new TestHandler();
|
||||
$logger = new Logger('test', array($handler));
|
||||
$logger = new Logger('test', [$handler]);
|
||||
$logger->pushProcessor(new DebugProcessor());
|
||||
|
||||
$logger->info('test');
|
||||
|
|
|
@ -94,18 +94,18 @@ class ProxyDumperTest extends TestCase
|
|||
|
||||
public function getPrivatePublicDefinitions()
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
return [
|
||||
[
|
||||
(new Definition(__CLASS__))
|
||||
->setPublic(false),
|
||||
'privates',
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
(new Definition(__CLASS__))
|
||||
->setPublic(true),
|
||||
'services',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -125,8 +125,8 @@ class ProxyDumperTest extends TestCase
|
|||
$definition = new Definition($class);
|
||||
|
||||
$definition->setLazy(true);
|
||||
$definition->addTag('proxy', array('interface' => DummyInterface::class));
|
||||
$definition->addTag('proxy', array('interface' => SunnyInterface::class));
|
||||
$definition->addTag('proxy', ['interface' => DummyInterface::class]);
|
||||
$definition->addTag('proxy', ['interface' => SunnyInterface::class]);
|
||||
|
||||
$implem = "<?php\n\n".$this->dumper->getProxyCode($definition);
|
||||
$factory = $this->dumper->getProxyFactoryCode($definition, 'foo', '$this->getFooService(false)');
|
||||
|
@ -179,12 +179,12 @@ EOPHP;
|
|||
*/
|
||||
public function getProxyCandidates()
|
||||
{
|
||||
$definitions = array(
|
||||
array(new Definition(__CLASS__), true),
|
||||
array(new Definition('stdClass'), true),
|
||||
array(new Definition(uniqid('foo', true)), false),
|
||||
array(new Definition(), false),
|
||||
);
|
||||
$definitions = [
|
||||
[new Definition(__CLASS__), true],
|
||||
[new Definition('stdClass'), true],
|
||||
[new Definition(uniqid('foo', true)), false],
|
||||
[new Definition(), false],
|
||||
];
|
||||
|
||||
array_map(
|
||||
function ($definition) {
|
||||
|
|
|
@ -37,7 +37,7 @@ class DebugCommand extends Command
|
|||
private $twigDefaultPath;
|
||||
private $rootDir;
|
||||
|
||||
public function __construct(Environment $twig, string $projectDir = null, array $bundlesMetadata = array(), string $twigDefaultPath = null, string $rootDir = null)
|
||||
public function __construct(Environment $twig, string $projectDir = null, array $bundlesMetadata = [], string $twigDefaultPath = null, string $rootDir = null)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
|
@ -51,11 +51,11 @@ class DebugCommand extends Command
|
|||
protected function configure()
|
||||
{
|
||||
$this
|
||||
->setDefinition(array(
|
||||
->setDefinition([
|
||||
new InputArgument('name', InputArgument::OPTIONAL, 'The template name'),
|
||||
new InputOption('filter', null, InputOption::VALUE_REQUIRED, 'Show details for all entries matching this filter'),
|
||||
new InputOption('format', null, InputOption::VALUE_REQUIRED, 'The output format (text or json)', 'text'),
|
||||
))
|
||||
])
|
||||
->setDescription('Shows a list of twig functions, filters, globals and tests')
|
||||
->setHelp(<<<'EOF'
|
||||
The <info>%command.name%</info> command outputs a list of twig functions,
|
||||
|
@ -115,11 +115,11 @@ EOF
|
|||
$io->listing($files);
|
||||
}
|
||||
} else {
|
||||
$alternatives = array();
|
||||
$alternatives = [];
|
||||
|
||||
if ($paths) {
|
||||
$shortnames = array();
|
||||
$dirs = array();
|
||||
$shortnames = [];
|
||||
$dirs = [];
|
||||
foreach (current($paths) as $path) {
|
||||
$dirs[] = $this->isAbsolutePath($path) ? $path : $this->projectDir.'/'.$path;
|
||||
}
|
||||
|
@ -141,9 +141,9 @@ EOF
|
|||
|
||||
$io->section('Configured Paths');
|
||||
if ($paths) {
|
||||
$io->table(array('Namespace', 'Paths'), $this->buildTableRows($paths));
|
||||
$io->table(['Namespace', 'Paths'], $this->buildTableRows($paths));
|
||||
} else {
|
||||
$alternatives = array();
|
||||
$alternatives = [];
|
||||
$namespace = $this->parseTemplateName($name)[0];
|
||||
|
||||
if (FilesystemLoader::MAIN_NAMESPACE === $namespace) {
|
||||
|
@ -159,7 +159,7 @@ EOF
|
|||
$this->error($io, $message, $alternatives);
|
||||
|
||||
if (!$alternatives && $paths = $this->getLoaderPaths()) {
|
||||
$io->table(array('Namespace', 'Paths'), $this->buildTableRows($paths));
|
||||
$io->table(['Namespace', 'Paths'], $this->buildTableRows($paths));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -184,9 +184,9 @@ EOF
|
|||
|
||||
private function displayGeneralText(SymfonyStyle $io, string $filter = null)
|
||||
{
|
||||
$types = array('functions', 'filters', 'tests', 'globals');
|
||||
$types = ['functions', 'filters', 'tests', 'globals'];
|
||||
foreach ($types as $index => $type) {
|
||||
$items = array();
|
||||
$items = [];
|
||||
foreach ($this->twig->{'get'.ucfirst($type)}() as $name => $entity) {
|
||||
if (!$filter || false !== strpos($name, $filter)) {
|
||||
$items[$name] = $name.$this->getPrettyMetadata($type, $entity);
|
||||
|
@ -205,7 +205,7 @@ EOF
|
|||
|
||||
if (!$filter && $paths = $this->getLoaderPaths()) {
|
||||
$io->section('Loader Paths');
|
||||
$io->table(array('Namespace', 'Paths'), $this->buildTableRows($paths));
|
||||
$io->table(['Namespace', 'Paths'], $this->buildTableRows($paths));
|
||||
}
|
||||
|
||||
if ($wrongBundles = $this->findWrongBundleOverrides()) {
|
||||
|
@ -217,8 +217,8 @@ EOF
|
|||
|
||||
private function displayGeneralJson(SymfonyStyle $io, $filter)
|
||||
{
|
||||
$types = array('functions', 'filters', 'tests', 'globals');
|
||||
$data = array();
|
||||
$types = ['functions', 'filters', 'tests', 'globals'];
|
||||
$data = [];
|
||||
foreach ($types as $type) {
|
||||
foreach ($this->twig->{'get'.ucfirst($type)}() as $name => $entity) {
|
||||
if (!$filter || false !== strpos($name, $filter)) {
|
||||
|
@ -245,15 +245,15 @@ EOF
|
|||
{
|
||||
/** @var FilesystemLoader $loader */
|
||||
$loader = $this->twig->getLoader();
|
||||
$loaderPaths = array();
|
||||
$loaderPaths = [];
|
||||
$namespaces = $loader->getNamespaces();
|
||||
if (null !== $name) {
|
||||
$namespace = $this->parseTemplateName($name)[0];
|
||||
$namespaces = array_intersect(array($namespace), $namespaces);
|
||||
$namespaces = array_intersect([$namespace], $namespaces);
|
||||
}
|
||||
|
||||
foreach ($namespaces as $namespace) {
|
||||
$paths = array_map(array($this, 'getRelativePath'), $loader->getPaths($namespace));
|
||||
$paths = array_map([$this, 'getRelativePath'], $loader->getPaths($namespace));
|
||||
|
||||
if (FilesystemLoader::MAIN_NAMESPACE === $namespace) {
|
||||
$namespace = '(None)';
|
||||
|
@ -357,8 +357,8 @@ EOF
|
|||
|
||||
private function findWrongBundleOverrides(): array
|
||||
{
|
||||
$alternatives = array();
|
||||
$bundleNames = array();
|
||||
$alternatives = [];
|
||||
$bundleNames = [];
|
||||
|
||||
if ($this->rootDir && $this->projectDir) {
|
||||
$folders = glob($this->rootDir.'/Resources/*/views', GLOB_ONLYDIR);
|
||||
|
@ -391,7 +391,7 @@ EOF
|
|||
}
|
||||
|
||||
if ($notFoundBundles = array_diff_key($bundleNames, $this->bundlesMetadata)) {
|
||||
$alternatives = array();
|
||||
$alternatives = [];
|
||||
foreach ($notFoundBundles as $notFoundBundle => $path) {
|
||||
$alternatives[$path] = $this->findAlternatives($notFoundBundle, array_keys($this->bundlesMetadata));
|
||||
}
|
||||
|
@ -402,7 +402,7 @@ EOF
|
|||
|
||||
private function buildWarningMessages(array $wrongBundles): array
|
||||
{
|
||||
$messages = array();
|
||||
$messages = [];
|
||||
foreach ($wrongBundles as $path => $alternatives) {
|
||||
$message = sprintf('Path "%s" not matching any bundle found', $path);
|
||||
if ($alternatives) {
|
||||
|
@ -421,7 +421,7 @@ EOF
|
|||
return $messages;
|
||||
}
|
||||
|
||||
private function error(SymfonyStyle $io, string $message, array $alternatives = array()): void
|
||||
private function error(SymfonyStyle $io, string $message, array $alternatives = []): void
|
||||
{
|
||||
if ($alternatives) {
|
||||
if (1 === \count($alternatives)) {
|
||||
|
@ -439,7 +439,7 @@ EOF
|
|||
{
|
||||
/** @var FilesystemLoader $loader */
|
||||
$loader = $this->twig->getLoader();
|
||||
$files = array();
|
||||
$files = [];
|
||||
list($namespace, $shortname) = $this->parseTemplateName($name);
|
||||
|
||||
foreach ($loader->getPaths($namespace) as $path) {
|
||||
|
@ -470,29 +470,29 @@ EOF
|
|||
$namespace = substr($name, 1, $pos - 1);
|
||||
$shortname = substr($name, $pos + 1);
|
||||
|
||||
return array($namespace, $shortname);
|
||||
return [$namespace, $shortname];
|
||||
}
|
||||
|
||||
return array($default, $name);
|
||||
return [$default, $name];
|
||||
}
|
||||
|
||||
private function buildTableRows(array $loaderPaths): array
|
||||
{
|
||||
$rows = array();
|
||||
$rows = [];
|
||||
$firstNamespace = true;
|
||||
$prevHasSeparator = false;
|
||||
|
||||
foreach ($loaderPaths as $namespace => $paths) {
|
||||
if (!$firstNamespace && !$prevHasSeparator && \count($paths) > 1) {
|
||||
$rows[] = array('', '');
|
||||
$rows[] = ['', ''];
|
||||
}
|
||||
$firstNamespace = false;
|
||||
foreach ($paths as $path) {
|
||||
$rows[] = array($namespace, $path.\DIRECTORY_SEPARATOR);
|
||||
$rows[] = [$namespace, $path.\DIRECTORY_SEPARATOR];
|
||||
$namespace = '';
|
||||
}
|
||||
if (\count($paths) > 1) {
|
||||
$rows[] = array('', '');
|
||||
$rows[] = ['', ''];
|
||||
$prevHasSeparator = true;
|
||||
} else {
|
||||
$prevHasSeparator = false;
|
||||
|
@ -507,7 +507,7 @@ EOF
|
|||
|
||||
private function findAlternatives(string $name, array $collection): array
|
||||
{
|
||||
$alternatives = array();
|
||||
$alternatives = [];
|
||||
foreach ($collection as $item) {
|
||||
$lev = levenshtein($name, $item);
|
||||
if ($lev <= \strlen($name) / 3 || false !== strpos($item, $name)) {
|
||||
|
|
|
@ -43,18 +43,18 @@ class CodeExtension extends AbstractExtension
|
|||
*/
|
||||
public function getFilters()
|
||||
{
|
||||
return array(
|
||||
new TwigFilter('abbr_class', array($this, 'abbrClass'), array('is_safe' => array('html'))),
|
||||
new TwigFilter('abbr_method', array($this, 'abbrMethod'), array('is_safe' => array('html'))),
|
||||
new TwigFilter('format_args', array($this, 'formatArgs'), array('is_safe' => array('html'))),
|
||||
new TwigFilter('format_args_as_text', array($this, 'formatArgsAsText')),
|
||||
new TwigFilter('file_excerpt', array($this, 'fileExcerpt'), array('is_safe' => array('html'))),
|
||||
new TwigFilter('format_file', array($this, 'formatFile'), array('is_safe' => array('html'))),
|
||||
new TwigFilter('format_file_from_text', array($this, 'formatFileFromText'), array('is_safe' => array('html'))),
|
||||
new TwigFilter('format_log_message', array($this, 'formatLogMessage'), array('is_safe' => array('html'))),
|
||||
new TwigFilter('file_link', array($this, 'getFileLink')),
|
||||
new TwigFilter('file_relative', array($this, 'getFileRelative')),
|
||||
);
|
||||
return [
|
||||
new TwigFilter('abbr_class', [$this, 'abbrClass'], ['is_safe' => ['html']]),
|
||||
new TwigFilter('abbr_method', [$this, 'abbrMethod'], ['is_safe' => ['html']]),
|
||||
new TwigFilter('format_args', [$this, 'formatArgs'], ['is_safe' => ['html']]),
|
||||
new TwigFilter('format_args_as_text', [$this, 'formatArgsAsText']),
|
||||
new TwigFilter('file_excerpt', [$this, 'fileExcerpt'], ['is_safe' => ['html']]),
|
||||
new TwigFilter('format_file', [$this, 'formatFile'], ['is_safe' => ['html']]),
|
||||
new TwigFilter('format_file_from_text', [$this, 'formatFileFromText'], ['is_safe' => ['html']]),
|
||||
new TwigFilter('format_log_message', [$this, 'formatLogMessage'], ['is_safe' => ['html']]),
|
||||
new TwigFilter('file_link', [$this, 'getFileLink']),
|
||||
new TwigFilter('file_relative', [$this, 'getFileRelative']),
|
||||
];
|
||||
}
|
||||
|
||||
public function abbrClass($class)
|
||||
|
@ -88,7 +88,7 @@ class CodeExtension extends AbstractExtension
|
|||
*/
|
||||
public function formatArgs($args)
|
||||
{
|
||||
$result = array();
|
||||
$result = [];
|
||||
foreach ($args as $key => $item) {
|
||||
if ('object' === $item[0]) {
|
||||
$parts = explode('\\', $item[1]);
|
||||
|
@ -147,7 +147,7 @@ class CodeExtension extends AbstractExtension
|
|||
}, $code);
|
||||
$content = explode('<br />', $code);
|
||||
|
||||
$lines = array();
|
||||
$lines = [];
|
||||
if (0 > $srcContext) {
|
||||
$srcContext = \count($content);
|
||||
}
|
||||
|
@ -205,7 +205,7 @@ class CodeExtension extends AbstractExtension
|
|||
public function getFileLink($file, $line)
|
||||
{
|
||||
if ($fmt = $this->fileLinkFormat) {
|
||||
return \is_string($fmt) ? strtr($fmt, array('%f' => $file, '%l' => $line)) : $fmt->format($file, $line);
|
||||
return \is_string($fmt) ? strtr($fmt, ['%f' => $file, '%l' => $line]) : $fmt->format($file, $line);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -235,7 +235,7 @@ class CodeExtension extends AbstractExtension
|
|||
public function formatLogMessage($message, array $context)
|
||||
{
|
||||
if ($context && false !== strpos($message, '{')) {
|
||||
$replacements = array();
|
||||
$replacements = [];
|
||||
foreach ($context as $key => $val) {
|
||||
if (is_scalar($val)) {
|
||||
$replacements['{'.$key.'}'] = $val;
|
||||
|
|
|
@ -69,10 +69,10 @@ class TranslationExtension extends AbstractExtension
|
|||
*/
|
||||
public function getFilters()
|
||||
{
|
||||
return array(
|
||||
new TwigFilter('trans', array($this, 'trans')),
|
||||
new TwigFilter('transchoice', array($this, 'transchoice'), array('deprecated' => '4.2', 'alternative' => 'trans" with parameter "%count%')),
|
||||
);
|
||||
return [
|
||||
new TwigFilter('trans', [$this, 'trans']),
|
||||
new TwigFilter('transchoice', [$this, 'transchoice'], ['deprecated' => '4.2', 'alternative' => 'trans" with parameter "%count%']),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -82,7 +82,7 @@ class TranslationExtension extends AbstractExtension
|
|||
*/
|
||||
public function getTokenParsers()
|
||||
{
|
||||
return array(
|
||||
return [
|
||||
// {% trans %}Symfony is great!{% endtrans %}
|
||||
new TransTokenParser(),
|
||||
|
||||
|
@ -93,7 +93,7 @@ class TranslationExtension extends AbstractExtension
|
|||
|
||||
// {% trans_default_domain "foobar" %}
|
||||
new TransDefaultDomainTokenParser(),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -101,7 +101,7 @@ class TranslationExtension extends AbstractExtension
|
|||
*/
|
||||
public function getNodeVisitors()
|
||||
{
|
||||
return array($this->getTranslationNodeVisitor(), new TranslationDefaultDomainNodeVisitor());
|
||||
return [$this->getTranslationNodeVisitor(), new TranslationDefaultDomainNodeVisitor()];
|
||||
}
|
||||
|
||||
public function getTranslationNodeVisitor()
|
||||
|
@ -109,7 +109,7 @@ class TranslationExtension extends AbstractExtension
|
|||
return $this->translationNodeVisitor ?: $this->translationNodeVisitor = new TranslationNodeVisitor();
|
||||
}
|
||||
|
||||
public function trans($message, array $arguments = array(), $domain = null, $locale = null, $count = null)
|
||||
public function trans($message, array $arguments = [], $domain = null, $locale = null, $count = null)
|
||||
{
|
||||
if (null !== $count) {
|
||||
$arguments['%count%'] = $count;
|
||||
|
@ -124,16 +124,16 @@ class TranslationExtension extends AbstractExtension
|
|||
/**
|
||||
* @deprecated since Symfony 4.2, use the trans() method instead with a %count% parameter
|
||||
*/
|
||||
public function transchoice($message, $count, array $arguments = array(), $domain = null, $locale = null)
|
||||
public function transchoice($message, $count, array $arguments = [], $domain = null, $locale = null)
|
||||
{
|
||||
if (null === $this->translator) {
|
||||
return $this->doTrans($message, array_merge(array('%count%' => $count), $arguments), $domain, $locale);
|
||||
return $this->doTrans($message, array_merge(['%count%' => $count], $arguments), $domain, $locale);
|
||||
}
|
||||
if ($this->translator instanceof TranslatorInterface) {
|
||||
return $this->translator->trans($message, array_merge(array('%count%' => $count), $arguments), $domain, $locale);
|
||||
return $this->translator->trans($message, array_merge(['%count%' => $count], $arguments), $domain, $locale);
|
||||
}
|
||||
|
||||
return $this->translator->transChoice($message, $count, array_merge(array('%count%' => $count), $arguments), $domain, $locale);
|
||||
return $this->translator->transChoice($message, $count, array_merge(['%count%' => $count], $arguments), $domain, $locale);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -23,7 +23,7 @@ class DebugCommandTest extends TestCase
|
|||
public function testDebugCommand()
|
||||
{
|
||||
$tester = $this->createCommandTester();
|
||||
$ret = $tester->execute(array(), array('decorated' => false));
|
||||
$ret = $tester->execute([], ['decorated' => false]);
|
||||
|
||||
$this->assertEquals(0, $ret, 'Returns 0 in case of success');
|
||||
$this->assertContains('Functions', trim($tester->getDisplay()));
|
||||
|
@ -32,11 +32,11 @@ class DebugCommandTest extends TestCase
|
|||
public function testFilterAndJsonFormatOptions()
|
||||
{
|
||||
$tester = $this->createCommandTester();
|
||||
$ret = $tester->execute(array('--filter' => 'abs', '--format' => 'json'), array('decorated' => false));
|
||||
$ret = $tester->execute(['--filter' => 'abs', '--format' => 'json'], ['decorated' => false]);
|
||||
|
||||
$expected = array(
|
||||
'filters' => array('abs' => array()),
|
||||
);
|
||||
$expected = [
|
||||
'filters' => ['abs' => []],
|
||||
];
|
||||
|
||||
$this->assertEquals(0, $ret, 'Returns 0 in case of success');
|
||||
$this->assertEquals($expected, json_decode($tester->getDisplay(true), true));
|
||||
|
@ -44,19 +44,19 @@ class DebugCommandTest extends TestCase
|
|||
|
||||
public function testWarningsWrongBundleOverriding()
|
||||
{
|
||||
$bundleMetadata = array(
|
||||
$bundleMetadata = [
|
||||
'TwigBundle' => 'vendor/twig-bundle/',
|
||||
'WebProfilerBundle' => 'vendor/web-profiler-bundle/',
|
||||
);
|
||||
];
|
||||
$defaultPath = \dirname(__DIR__).\DIRECTORY_SEPARATOR.'Fixtures'.\DIRECTORY_SEPARATOR.'templates';
|
||||
|
||||
$tester = $this->createCommandTester(array(), $bundleMetadata, $defaultPath);
|
||||
$ret = $tester->execute(array('--filter' => 'unknown', '--format' => 'json'), array('decorated' => false));
|
||||
$tester = $this->createCommandTester([], $bundleMetadata, $defaultPath);
|
||||
$ret = $tester->execute(['--filter' => 'unknown', '--format' => 'json'], ['decorated' => false]);
|
||||
|
||||
$expected = array('warnings' => array(
|
||||
$expected = ['warnings' => [
|
||||
'Path "templates/bundles/UnknownBundle" not matching any bundle found',
|
||||
'Path "templates/bundles/WebProfileBundle" not matching any bundle found, did you mean "WebProfilerBundle"?',
|
||||
));
|
||||
]];
|
||||
|
||||
$this->assertEquals(0, $ret, 'Returns 0 in case of success');
|
||||
$this->assertEquals($expected, json_decode($tester->getDisplay(true), true));
|
||||
|
@ -68,21 +68,21 @@ class DebugCommandTest extends TestCase
|
|||
*/
|
||||
public function testDeprecationForWrongBundleOverridingInLegacyPath()
|
||||
{
|
||||
$bundleMetadata = array(
|
||||
$bundleMetadata = [
|
||||
'TwigBundle' => 'vendor/twig-bundle/',
|
||||
'WebProfilerBundle' => 'vendor/web-profiler-bundle/',
|
||||
);
|
||||
];
|
||||
$defaultPath = \dirname(__DIR__).\DIRECTORY_SEPARATOR.'Fixtures'.\DIRECTORY_SEPARATOR.'templates';
|
||||
$rootDir = \dirname(__DIR__).\DIRECTORY_SEPARATOR.'Fixtures';
|
||||
|
||||
$tester = $this->createCommandTester(array(), $bundleMetadata, $defaultPath, $rootDir);
|
||||
$ret = $tester->execute(array('--filter' => 'unknown', '--format' => 'json'), array('decorated' => false));
|
||||
$tester = $this->createCommandTester([], $bundleMetadata, $defaultPath, $rootDir);
|
||||
$ret = $tester->execute(['--filter' => 'unknown', '--format' => 'json'], ['decorated' => false]);
|
||||
|
||||
$expected = array('warnings' => array(
|
||||
$expected = ['warnings' => [
|
||||
'Path "Resources/BarBundle" not matching any bundle found',
|
||||
'Path "templates/bundles/UnknownBundle" not matching any bundle found',
|
||||
'Path "templates/bundles/WebProfileBundle" not matching any bundle found, did you mean "WebProfilerBundle"?',
|
||||
));
|
||||
]];
|
||||
|
||||
$this->assertEquals(0, $ret, 'Returns 0 in case of success');
|
||||
$this->assertEquals($expected, json_decode($tester->getDisplay(true), true));
|
||||
|
@ -94,7 +94,7 @@ class DebugCommandTest extends TestCase
|
|||
*/
|
||||
public function testMalformedTemplateName()
|
||||
{
|
||||
$this->createCommandTester()->execute(array('name' => '@foo'));
|
||||
$this->createCommandTester()->execute(['name' => '@foo']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -103,7 +103,7 @@ class DebugCommandTest extends TestCase
|
|||
public function testDebugTemplateName(array $input, string $output, array $paths)
|
||||
{
|
||||
$tester = $this->createCommandTester($paths);
|
||||
$ret = $tester->execute($input, array('decorated' => false));
|
||||
$ret = $tester->execute($input, ['decorated' => false]);
|
||||
|
||||
$this->assertEquals(0, $ret, 'Returns 0 in case of success');
|
||||
$this->assertStringMatchesFormat($output, $tester->getDisplay(true));
|
||||
|
@ -111,14 +111,14 @@ class DebugCommandTest extends TestCase
|
|||
|
||||
public function getDebugTemplateNameTestData()
|
||||
{
|
||||
$defaultPaths = array(
|
||||
$defaultPaths = [
|
||||
'templates/' => null,
|
||||
'templates/bundles/TwigBundle/' => 'Twig',
|
||||
'vendors/twig-bundle/Resources/views/' => 'Twig',
|
||||
);
|
||||
];
|
||||
|
||||
yield 'no template paths configured for your application' => array(
|
||||
'input' => array('name' => 'base.html.twig'),
|
||||
yield 'no template paths configured for your application' => [
|
||||
'input' => ['name' => 'base.html.twig'],
|
||||
'output' => <<<TXT
|
||||
|
||||
Matched File
|
||||
|
@ -140,11 +140,11 @@ Configured Paths
|
|||
|
||||
TXT
|
||||
,
|
||||
'paths' => array('vendors/twig-bundle/Resources/views/' => 'Twig'),
|
||||
);
|
||||
'paths' => ['vendors/twig-bundle/Resources/views/' => 'Twig'],
|
||||
];
|
||||
|
||||
yield 'no matched template' => array(
|
||||
'input' => array('name' => '@App/foo.html.twig'),
|
||||
yield 'no matched template' => [
|
||||
'input' => ['name' => '@App/foo.html.twig'],
|
||||
'output' => <<<TXT
|
||||
|
||||
Matched File
|
||||
|
@ -170,10 +170,10 @@ Configured Paths
|
|||
TXT
|
||||
,
|
||||
'paths' => $defaultPaths,
|
||||
);
|
||||
];
|
||||
|
||||
yield 'matched file' => array(
|
||||
'input' => array('name' => 'base.html.twig'),
|
||||
yield 'matched file' => [
|
||||
'input' => ['name' => 'base.html.twig'],
|
||||
'output' => <<<TXT
|
||||
|
||||
Matched File
|
||||
|
@ -194,10 +194,10 @@ Configured Paths
|
|||
TXT
|
||||
,
|
||||
'paths' => $defaultPaths,
|
||||
);
|
||||
];
|
||||
|
||||
yield 'overridden files' => array(
|
||||
'input' => array('name' => '@Twig/error.html.twig'),
|
||||
yield 'overridden files' => [
|
||||
'input' => ['name' => '@Twig/error.html.twig'],
|
||||
'output' => <<<TXT
|
||||
|
||||
Matched File
|
||||
|
@ -224,10 +224,10 @@ Configured Paths
|
|||
TXT
|
||||
,
|
||||
'paths' => $defaultPaths,
|
||||
);
|
||||
];
|
||||
|
||||
yield 'template namespace alternative' => array(
|
||||
'input' => array('name' => '@Twg/error.html.twig'),
|
||||
yield 'template namespace alternative' => [
|
||||
'input' => ['name' => '@Twg/error.html.twig'],
|
||||
'output' => <<<TXT
|
||||
|
||||
Matched File
|
||||
|
@ -247,10 +247,10 @@ Configured Paths
|
|||
TXT
|
||||
,
|
||||
'paths' => $defaultPaths,
|
||||
);
|
||||
];
|
||||
|
||||
yield 'template name alternative' => array(
|
||||
'input' => array('name' => '@Twig/eror.html.twig'),
|
||||
yield 'template name alternative' => [
|
||||
'input' => ['name' => '@Twig/eror.html.twig'],
|
||||
'output' => <<<TXT
|
||||
|
||||
Matched File
|
||||
|
@ -276,13 +276,13 @@ Configured Paths
|
|||
TXT
|
||||
,
|
||||
'paths' => $defaultPaths,
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
private function createCommandTester(array $paths = array(), array $bundleMetadata = array(), string $defaultPath = null, string $rootDir = null): CommandTester
|
||||
private function createCommandTester(array $paths = [], array $bundleMetadata = [], string $defaultPath = null, string $rootDir = null): CommandTester
|
||||
{
|
||||
$projectDir = \dirname(__DIR__).\DIRECTORY_SEPARATOR.'Fixtures';
|
||||
$loader = new FilesystemLoader(array(), $projectDir);
|
||||
$loader = new FilesystemLoader([], $projectDir);
|
||||
foreach ($paths as $path => $namespace) {
|
||||
if (null === $namespace) {
|
||||
$loader->addPath($path);
|
||||
|
|
|
@ -122,12 +122,12 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
|||
|
||||
public function testHelpAttr()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, array(
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [
|
||||
'help' => 'Help text test!',
|
||||
'help_attr' => array(
|
||||
'help_attr' => [
|
||||
'class' => 'class-test',
|
||||
),
|
||||
));
|
||||
],
|
||||
]);
|
||||
$view = $form->createView();
|
||||
$html = $this->renderHelp($view);
|
||||
|
||||
|
|
|
@ -179,12 +179,12 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
|
|||
|
||||
public function testHelpAttr()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, array(
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [
|
||||
'help' => 'Help text test!',
|
||||
'help_attr' => array(
|
||||
'help_attr' => [
|
||||
'class' => 'class-test',
|
||||
),
|
||||
));
|
||||
],
|
||||
]);
|
||||
$view = $form->createView();
|
||||
$html = $this->renderHelp($view);
|
||||
|
||||
|
|
|
@ -27,11 +27,11 @@ class DumpExtensionTest extends TestCase
|
|||
public function testDumpTag($template, $debug, $expectedOutput, $expectedDumped)
|
||||
{
|
||||
$extension = new DumpExtension(new VarCloner());
|
||||
$twig = new Environment(new ArrayLoader(array('template' => $template)), array(
|
||||
$twig = new Environment(new ArrayLoader(['template' => $template]), [
|
||||
'debug' => $debug,
|
||||
'cache' => false,
|
||||
'optimizations' => 0,
|
||||
));
|
||||
]);
|
||||
$twig->addExtension($extension);
|
||||
|
||||
$dumped = null;
|
||||
|
@ -54,11 +54,11 @@ class DumpExtensionTest extends TestCase
|
|||
|
||||
public function getDumpTags()
|
||||
{
|
||||
return array(
|
||||
array('A{% dump %}B', true, 'AB', array()),
|
||||
array('A{% set foo="bar"%}B{% dump %}C', true, 'ABC', array('foo' => 'bar')),
|
||||
array('A{% dump %}B', false, 'AB', null),
|
||||
);
|
||||
return [
|
||||
['A{% dump %}B', true, 'AB', []],
|
||||
['A{% set foo="bar"%}B{% dump %}C', true, 'ABC', ['foo' => 'bar']],
|
||||
['A{% dump %}B', false, 'AB', null],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -67,11 +67,11 @@ class DumpExtensionTest extends TestCase
|
|||
public function testDump($context, $args, $expectedOutput, $debug = true)
|
||||
{
|
||||
$extension = new DumpExtension(new VarCloner());
|
||||
$twig = new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock(), array(
|
||||
$twig = new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock(), [
|
||||
'debug' => $debug,
|
||||
'cache' => false,
|
||||
'optimizations' => 0,
|
||||
));
|
||||
]);
|
||||
|
||||
array_unshift($args, $context);
|
||||
array_unshift($args, $twig);
|
||||
|
@ -88,24 +88,24 @@ class DumpExtensionTest extends TestCase
|
|||
|
||||
public function getDumpArgs()
|
||||
{
|
||||
return array(
|
||||
array(array(), array(), '', false),
|
||||
array(array(), array(), "<pre class=sf-dump id=sf-dump data-indent-pad=\" \">[]\n</pre><script>Sfdump(\"sf-dump\")</script>\n"),
|
||||
array(
|
||||
array(),
|
||||
array(123, 456),
|
||||
return [
|
||||
[[], [], '', false],
|
||||
[[], [], "<pre class=sf-dump id=sf-dump data-indent-pad=\" \">[]\n</pre><script>Sfdump(\"sf-dump\")</script>\n"],
|
||||
[
|
||||
[],
|
||||
[123, 456],
|
||||
"<pre class=sf-dump id=sf-dump data-indent-pad=\" \"><span class=sf-dump-num>123</span>\n</pre><script>Sfdump(\"sf-dump\")</script>\n"
|
||||
."<pre class=sf-dump id=sf-dump data-indent-pad=\" \"><span class=sf-dump-num>456</span>\n</pre><script>Sfdump(\"sf-dump\")</script>\n",
|
||||
),
|
||||
array(
|
||||
array('foo' => 'bar'),
|
||||
array(),
|
||||
],
|
||||
[
|
||||
['foo' => 'bar'],
|
||||
[],
|
||||
"<pre class=sf-dump id=sf-dump data-indent-pad=\" \"><span class=sf-dump-note>array:1</span> [<samp>\n"
|
||||
." \"<span class=sf-dump-key>foo</span>\" => \"<span class=sf-dump-str title=\"3 characters\">bar</span>\"\n"
|
||||
."</samp>]\n"
|
||||
."</pre><script>Sfdump(\"sf-dump\")</script>\n",
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function testCustomDumper()
|
||||
|
@ -123,13 +123,13 @@ class DumpExtensionTest extends TestCase
|
|||
'</pre><script>Sfdump("%s")</script>'
|
||||
);
|
||||
$extension = new DumpExtension(new VarCloner(), $dumper);
|
||||
$twig = new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock(), array(
|
||||
$twig = new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock(), [
|
||||
'debug' => true,
|
||||
'cache' => false,
|
||||
'optimizations' => 0,
|
||||
));
|
||||
]);
|
||||
|
||||
$dump = $extension->dump($twig, array(), 'foo');
|
||||
$dump = $extension->dump($twig, [], 'foo');
|
||||
$dump = preg_replace('/sf-dump-\d+/', 'sf-dump', $dump);
|
||||
|
||||
$this->assertEquals(
|
||||
|
|
|
@ -15,7 +15,7 @@ use Symfony\Contracts\Translation\TranslatorInterface;
|
|||
|
||||
class StubTranslator implements TranslatorInterface
|
||||
{
|
||||
public function trans($id, array $parameters = array(), $domain = null, $locale = null)
|
||||
public function trans($id, array $parameters = [], $domain = null, $locale = null)
|
||||
{
|
||||
return '[trans]'.$id.'[/trans]';
|
||||
}
|
||||
|
|
|
@ -35,22 +35,22 @@ class FormExtensionDivLayoutTest extends AbstractDivLayoutTest
|
|||
{
|
||||
parent::setUp();
|
||||
|
||||
$loader = new StubFilesystemLoader(array(
|
||||
$loader = new StubFilesystemLoader([
|
||||
__DIR__.'/../../Resources/views/Form',
|
||||
__DIR__.'/Fixtures/templates/form',
|
||||
));
|
||||
]);
|
||||
|
||||
$environment = new Environment($loader, array('strict_variables' => true));
|
||||
$environment = new Environment($loader, ['strict_variables' => true]);
|
||||
$environment->addExtension(new TranslationExtension(new StubTranslator()));
|
||||
$environment->addGlobal('global', '');
|
||||
// the value can be any template that exists
|
||||
$environment->addGlobal('dynamic_template_name', 'child_label');
|
||||
$environment->addExtension(new FormExtension());
|
||||
|
||||
$rendererEngine = new TwigRendererEngine(array(
|
||||
$rendererEngine = new TwigRendererEngine([
|
||||
'form_div_layout.html.twig',
|
||||
'custom_widgets.html.twig',
|
||||
), $environment);
|
||||
], $environment);
|
||||
$this->renderer = new FormRenderer($rendererEngine, $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock());
|
||||
$this->registerTwigRuntimeLoader($environment, $this->renderer);
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ class FormExtensionDivLayoutTest extends AbstractDivLayoutTest
|
|||
->createView()
|
||||
;
|
||||
|
||||
$this->setTheme($view, array('theme_use.html.twig'));
|
||||
$this->setTheme($view, ['theme_use.html.twig']);
|
||||
|
||||
$this->assertMatchesXpath(
|
||||
$this->renderWidget($view),
|
||||
|
@ -77,7 +77,7 @@ class FormExtensionDivLayoutTest extends AbstractDivLayoutTest
|
|||
->createView()
|
||||
;
|
||||
|
||||
$this->setTheme($view, array('theme_extends.html.twig'));
|
||||
$this->setTheme($view, ['theme_extends.html.twig']);
|
||||
|
||||
$this->assertMatchesXpath(
|
||||
$this->renderWidget($view),
|
||||
|
@ -92,7 +92,7 @@ class FormExtensionDivLayoutTest extends AbstractDivLayoutTest
|
|||
->createView()
|
||||
;
|
||||
|
||||
$this->renderer->setTheme($view, array('page_dynamic_extends.html.twig'));
|
||||
$this->renderer->setTheme($view, ['page_dynamic_extends.html.twig']);
|
||||
$this->assertMatchesXpath(
|
||||
$this->renderer->searchAndRenderBlock($view, 'row'),
|
||||
'/div/label[text()="child"]'
|
||||
|
@ -101,18 +101,18 @@ class FormExtensionDivLayoutTest extends AbstractDivLayoutTest
|
|||
|
||||
public function isSelectedChoiceProvider()
|
||||
{
|
||||
return array(
|
||||
array(true, '0', '0'),
|
||||
array(true, '1', '1'),
|
||||
array(true, '', ''),
|
||||
array(true, '1.23', '1.23'),
|
||||
array(true, 'foo', 'foo'),
|
||||
array(true, 'foo10', 'foo10'),
|
||||
array(true, 'foo', array(1, 'foo', 'foo10')),
|
||||
return [
|
||||
[true, '0', '0'],
|
||||
[true, '1', '1'],
|
||||
[true, '', ''],
|
||||
[true, '1.23', '1.23'],
|
||||
[true, 'foo', 'foo'],
|
||||
[true, 'foo10', 'foo10'],
|
||||
[true, 'foo', [1, 'foo', 'foo10']],
|
||||
|
||||
array(false, 10, array(1, 'foo', 'foo10')),
|
||||
array(false, 0, array(1, 'foo', 'foo10')),
|
||||
);
|
||||
[false, 10, [1, 'foo', 'foo10']],
|
||||
[false, 0, [1, 'foo', 'foo10']],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -127,10 +127,10 @@ class FormExtensionDivLayoutTest extends AbstractDivLayoutTest
|
|||
|
||||
public function testStartTagHasNoActionAttributeWhenActionIsEmpty()
|
||||
{
|
||||
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array(
|
||||
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, [
|
||||
'method' => 'get',
|
||||
'action' => '',
|
||||
));
|
||||
]);
|
||||
|
||||
$html = $this->renderStart($form->createView());
|
||||
|
||||
|
@ -139,10 +139,10 @@ class FormExtensionDivLayoutTest extends AbstractDivLayoutTest
|
|||
|
||||
public function testStartTagHasActionAttributeWhenActionIsZero()
|
||||
{
|
||||
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array(
|
||||
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, [
|
||||
'method' => 'get',
|
||||
'action' => '0',
|
||||
));
|
||||
]);
|
||||
|
||||
$html = $this->renderStart($form->createView());
|
||||
|
||||
|
@ -151,10 +151,10 @@ class FormExtensionDivLayoutTest extends AbstractDivLayoutTest
|
|||
|
||||
public function isRootFormProvider()
|
||||
{
|
||||
return array(
|
||||
array(true, new FormView()),
|
||||
array(false, new FormView(new FormView())),
|
||||
);
|
||||
return [
|
||||
[true, new FormView()],
|
||||
[false, new FormView(new FormView())],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -167,18 +167,18 @@ class FormExtensionDivLayoutTest extends AbstractDivLayoutTest
|
|||
|
||||
public function testMoneyWidgetInIso()
|
||||
{
|
||||
$environment = new Environment(new StubFilesystemLoader(array(
|
||||
$environment = new Environment(new StubFilesystemLoader([
|
||||
__DIR__.'/../../Resources/views/Form',
|
||||
__DIR__.'/Fixtures/templates/form',
|
||||
)), array('strict_variables' => true));
|
||||
]), ['strict_variables' => true]);
|
||||
$environment->addExtension(new TranslationExtension(new StubTranslator()));
|
||||
$environment->addExtension(new FormExtension());
|
||||
$environment->setCharset('ISO-8859-1');
|
||||
|
||||
$rendererEngine = new TwigRendererEngine(array(
|
||||
$rendererEngine = new TwigRendererEngine([
|
||||
'form_div_layout.html.twig',
|
||||
'custom_widgets.html.twig',
|
||||
), $environment);
|
||||
], $environment);
|
||||
$this->renderer = new FormRenderer($rendererEngine, $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock());
|
||||
$this->registerTwigRuntimeLoader($environment, $this->renderer);
|
||||
|
||||
|
@ -192,12 +192,12 @@ class FormExtensionDivLayoutTest extends AbstractDivLayoutTest
|
|||
|
||||
public function testHelpAttr()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, array(
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [
|
||||
'help' => 'Help text test!',
|
||||
'help_attr' => array(
|
||||
'help_attr' => [
|
||||
'class' => 'class-test',
|
||||
),
|
||||
));
|
||||
],
|
||||
]);
|
||||
$view = $form->createView();
|
||||
$html = $this->renderHelp($view);
|
||||
|
||||
|
@ -210,15 +210,15 @@ class FormExtensionDivLayoutTest extends AbstractDivLayoutTest
|
|||
);
|
||||
}
|
||||
|
||||
protected function renderForm(FormView $view, array $vars = array())
|
||||
protected function renderForm(FormView $view, array $vars = [])
|
||||
{
|
||||
return (string) $this->renderer->renderBlock($view, 'form', $vars);
|
||||
}
|
||||
|
||||
protected function renderLabel(FormView $view, $label = null, array $vars = array())
|
||||
protected function renderLabel(FormView $view, $label = null, array $vars = [])
|
||||
{
|
||||
if (null !== $label) {
|
||||
$vars += array('label' => $label);
|
||||
$vars += ['label' => $label];
|
||||
}
|
||||
|
||||
return (string) $this->renderer->searchAndRenderBlock($view, 'label', $vars);
|
||||
|
@ -234,27 +234,27 @@ class FormExtensionDivLayoutTest extends AbstractDivLayoutTest
|
|||
return (string) $this->renderer->searchAndRenderBlock($view, 'errors');
|
||||
}
|
||||
|
||||
protected function renderWidget(FormView $view, array $vars = array())
|
||||
protected function renderWidget(FormView $view, array $vars = [])
|
||||
{
|
||||
return (string) $this->renderer->searchAndRenderBlock($view, 'widget', $vars);
|
||||
}
|
||||
|
||||
protected function renderRow(FormView $view, array $vars = array())
|
||||
protected function renderRow(FormView $view, array $vars = [])
|
||||
{
|
||||
return (string) $this->renderer->searchAndRenderBlock($view, 'row', $vars);
|
||||
}
|
||||
|
||||
protected function renderRest(FormView $view, array $vars = array())
|
||||
protected function renderRest(FormView $view, array $vars = [])
|
||||
{
|
||||
return (string) $this->renderer->searchAndRenderBlock($view, 'rest', $vars);
|
||||
}
|
||||
|
||||
protected function renderStart(FormView $view, array $vars = array())
|
||||
protected function renderStart(FormView $view, array $vars = [])
|
||||
{
|
||||
return (string) $this->renderer->renderBlock($view, 'form_start', $vars);
|
||||
}
|
||||
|
||||
protected function renderEnd(FormView $view, array $vars = array())
|
||||
protected function renderEnd(FormView $view, array $vars = [])
|
||||
{
|
||||
return (string) $this->renderer->renderBlock($view, 'form_end', $vars);
|
||||
}
|
||||
|
@ -266,15 +266,15 @@ class FormExtensionDivLayoutTest extends AbstractDivLayoutTest
|
|||
|
||||
public static function themeBlockInheritanceProvider()
|
||||
{
|
||||
return array(
|
||||
array(array('theme.html.twig')),
|
||||
);
|
||||
return [
|
||||
[['theme.html.twig']],
|
||||
];
|
||||
}
|
||||
|
||||
public static function themeInheritanceProvider()
|
||||
{
|
||||
return array(
|
||||
array(array('parent_label.html.twig'), array('child_label.html.twig')),
|
||||
);
|
||||
return [
|
||||
[['parent_label.html.twig'], ['child_label.html.twig']],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,30 +34,30 @@ class FormExtensionTableLayoutTest extends AbstractTableLayoutTest
|
|||
{
|
||||
parent::setUp();
|
||||
|
||||
$loader = new StubFilesystemLoader(array(
|
||||
$loader = new StubFilesystemLoader([
|
||||
__DIR__.'/../../Resources/views/Form',
|
||||
__DIR__.'/Fixtures/templates/form',
|
||||
));
|
||||
]);
|
||||
|
||||
$environment = new Environment($loader, array('strict_variables' => true));
|
||||
$environment = new Environment($loader, ['strict_variables' => true]);
|
||||
$environment->addExtension(new TranslationExtension(new StubTranslator()));
|
||||
$environment->addGlobal('global', '');
|
||||
$environment->addExtension(new FormExtension());
|
||||
|
||||
$rendererEngine = new TwigRendererEngine(array(
|
||||
$rendererEngine = new TwigRendererEngine([
|
||||
'form_table_layout.html.twig',
|
||||
'custom_widgets.html.twig',
|
||||
), $environment);
|
||||
], $environment);
|
||||
$this->renderer = new FormRenderer($rendererEngine, $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock());
|
||||
$this->registerTwigRuntimeLoader($environment, $this->renderer);
|
||||
}
|
||||
|
||||
public function testStartTagHasNoActionAttributeWhenActionIsEmpty()
|
||||
{
|
||||
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array(
|
||||
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, [
|
||||
'method' => 'get',
|
||||
'action' => '',
|
||||
));
|
||||
]);
|
||||
|
||||
$html = $this->renderStart($form->createView());
|
||||
|
||||
|
@ -66,10 +66,10 @@ class FormExtensionTableLayoutTest extends AbstractTableLayoutTest
|
|||
|
||||
public function testStartTagHasActionAttributeWhenActionIsZero()
|
||||
{
|
||||
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array(
|
||||
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, [
|
||||
'method' => 'get',
|
||||
'action' => '0',
|
||||
));
|
||||
]);
|
||||
|
||||
$html = $this->renderStart($form->createView());
|
||||
|
||||
|
@ -78,12 +78,12 @@ class FormExtensionTableLayoutTest extends AbstractTableLayoutTest
|
|||
|
||||
public function testHelpAttr()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, array(
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [
|
||||
'help' => 'Help text test!',
|
||||
'help_attr' => array(
|
||||
'help_attr' => [
|
||||
'class' => 'class-test',
|
||||
),
|
||||
));
|
||||
],
|
||||
]);
|
||||
$view = $form->createView();
|
||||
$html = $this->renderHelp($view);
|
||||
|
||||
|
@ -96,15 +96,15 @@ class FormExtensionTableLayoutTest extends AbstractTableLayoutTest
|
|||
);
|
||||
}
|
||||
|
||||
protected function renderForm(FormView $view, array $vars = array())
|
||||
protected function renderForm(FormView $view, array $vars = [])
|
||||
{
|
||||
return (string) $this->renderer->renderBlock($view, 'form', $vars);
|
||||
}
|
||||
|
||||
protected function renderLabel(FormView $view, $label = null, array $vars = array())
|
||||
protected function renderLabel(FormView $view, $label = null, array $vars = [])
|
||||
{
|
||||
if (null !== $label) {
|
||||
$vars += array('label' => $label);
|
||||
$vars += ['label' => $label];
|
||||
}
|
||||
|
||||
return (string) $this->renderer->searchAndRenderBlock($view, 'label', $vars);
|
||||
|
@ -120,27 +120,27 @@ class FormExtensionTableLayoutTest extends AbstractTableLayoutTest
|
|||
return (string) $this->renderer->searchAndRenderBlock($view, 'errors');
|
||||
}
|
||||
|
||||
protected function renderWidget(FormView $view, array $vars = array())
|
||||
protected function renderWidget(FormView $view, array $vars = [])
|
||||
{
|
||||
return (string) $this->renderer->searchAndRenderBlock($view, 'widget', $vars);
|
||||
}
|
||||
|
||||
protected function renderRow(FormView $view, array $vars = array())
|
||||
protected function renderRow(FormView $view, array $vars = [])
|
||||
{
|
||||
return (string) $this->renderer->searchAndRenderBlock($view, 'row', $vars);
|
||||
}
|
||||
|
||||
protected function renderRest(FormView $view, array $vars = array())
|
||||
protected function renderRest(FormView $view, array $vars = [])
|
||||
{
|
||||
return (string) $this->renderer->searchAndRenderBlock($view, 'rest', $vars);
|
||||
}
|
||||
|
||||
protected function renderStart(FormView $view, array $vars = array())
|
||||
protected function renderStart(FormView $view, array $vars = [])
|
||||
{
|
||||
return (string) $this->renderer->renderBlock($view, 'form_start', $vars);
|
||||
}
|
||||
|
||||
protected function renderEnd(FormView $view, array $vars = array())
|
||||
protected function renderEnd(FormView $view, array $vars = [])
|
||||
{
|
||||
return (string) $this->renderer->renderBlock($view, 'form_end', $vars);
|
||||
}
|
||||
|
|
|
@ -28,12 +28,12 @@ class TwigExtractorTest extends TestCase
|
|||
public function testExtract($template, $messages)
|
||||
{
|
||||
$loader = $this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock();
|
||||
$twig = new Environment($loader, array(
|
||||
$twig = new Environment($loader, [
|
||||
'strict_variables' => true,
|
||||
'debug' => true,
|
||||
'cache' => false,
|
||||
'autoescape' => false,
|
||||
));
|
||||
]);
|
||||
$twig->addExtension(new TranslationExtension($this->getMockBuilder(TranslatorInterface::class)->getMock()));
|
||||
|
||||
$extractor = new TwigExtractor($twig);
|
||||
|
@ -61,23 +61,23 @@ class TwigExtractorTest extends TestCase
|
|||
|
||||
public function getExtractData()
|
||||
{
|
||||
return array(
|
||||
array('{{ "new key" | trans() }}', array('new key' => 'messages')),
|
||||
array('{{ "new key" | trans() | upper }}', array('new key' => 'messages')),
|
||||
array('{{ "new key" | trans({}, "domain") }}', array('new key' => 'domain')),
|
||||
array('{% trans %}new key{% endtrans %}', array('new key' => 'messages')),
|
||||
array('{% trans %} new key {% endtrans %}', array('new key' => 'messages')),
|
||||
array('{% trans from "domain" %}new key{% endtrans %}', array('new key' => 'domain')),
|
||||
array('{% set foo = "new key" | trans %}', array('new key' => 'messages')),
|
||||
array('{{ 1 ? "new key" | trans : "another key" | trans }}', array('new key' => 'messages', 'another key' => 'messages')),
|
||||
return [
|
||||
['{{ "new key" | trans() }}', ['new key' => 'messages']],
|
||||
['{{ "new key" | trans() | upper }}', ['new key' => 'messages']],
|
||||
['{{ "new key" | trans({}, "domain") }}', ['new key' => 'domain']],
|
||||
['{% trans %}new key{% endtrans %}', ['new key' => 'messages']],
|
||||
['{% trans %} new key {% endtrans %}', ['new key' => 'messages']],
|
||||
['{% trans from "domain" %}new key{% endtrans %}', ['new key' => 'domain']],
|
||||
['{% set foo = "new key" | trans %}', ['new key' => 'messages']],
|
||||
['{{ 1 ? "new key" | trans : "another key" | trans }}', ['new key' => 'messages', 'another key' => 'messages']],
|
||||
|
||||
// make sure 'trans_default_domain' tag is supported
|
||||
array('{% trans_default_domain "domain" %}{{ "new key"|trans }}', array('new key' => 'domain')),
|
||||
array('{% trans_default_domain "domain" %}{% trans %}new key{% endtrans %}', array('new key' => 'domain')),
|
||||
['{% trans_default_domain "domain" %}{{ "new key"|trans }}', ['new key' => 'domain']],
|
||||
['{% trans_default_domain "domain" %}{% trans %}new key{% endtrans %}', ['new key' => 'domain']],
|
||||
|
||||
// make sure this works with twig's named arguments
|
||||
array('{{ "new key" | trans(domain="domain") }}', array('new key' => 'domain')),
|
||||
);
|
||||
['{{ "new key" | trans(domain="domain") }}', ['new key' => 'domain']],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -85,17 +85,17 @@ class TwigExtractorTest extends TestCase
|
|||
*/
|
||||
public function getLegacyExtractData()
|
||||
{
|
||||
return array(
|
||||
array('{{ "new key" | transchoice(1) }}', array('new key' => 'messages')),
|
||||
array('{{ "new key" | transchoice(1) | upper }}', array('new key' => 'messages')),
|
||||
array('{{ "new key" | transchoice(1, {}, "domain") }}', array('new key' => 'domain')),
|
||||
return [
|
||||
['{{ "new key" | transchoice(1) }}', ['new key' => 'messages']],
|
||||
['{{ "new key" | transchoice(1) | upper }}', ['new key' => 'messages']],
|
||||
['{{ "new key" | transchoice(1, {}, "domain") }}', ['new key' => 'domain']],
|
||||
|
||||
// make sure 'trans_default_domain' tag is supported
|
||||
array('{% trans_default_domain "domain" %}{{ "new key"|transchoice }}', array('new key' => 'domain')),
|
||||
['{% trans_default_domain "domain" %}{{ "new key"|transchoice }}', ['new key' => 'domain']],
|
||||
|
||||
// make sure this works with twig's named arguments
|
||||
array('{{ "new key" | transchoice(domain="domain", count=1) }}', array('new key' => 'domain')),
|
||||
);
|
||||
['{{ "new key" | transchoice(domain="domain", count=1) }}', ['new key' => 'domain']],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -128,11 +128,11 @@ class TwigExtractorTest extends TestCase
|
|||
*/
|
||||
public function resourcesWithSyntaxErrorsProvider()
|
||||
{
|
||||
return array(
|
||||
array(__DIR__.'/../Fixtures'),
|
||||
array(__DIR__.'/../Fixtures/extractor/syntax_error.twig'),
|
||||
array(new \SplFileInfo(__DIR__.'/../Fixtures/extractor/syntax_error.twig')),
|
||||
);
|
||||
return [
|
||||
[__DIR__.'/../Fixtures'],
|
||||
[__DIR__.'/../Fixtures/extractor/syntax_error.twig'],
|
||||
[new \SplFileInfo(__DIR__.'/../Fixtures/extractor/syntax_error.twig')],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -140,13 +140,13 @@ class TwigExtractorTest extends TestCase
|
|||
*/
|
||||
public function testExtractWithFiles($resource)
|
||||
{
|
||||
$loader = new ArrayLoader(array());
|
||||
$twig = new Environment($loader, array(
|
||||
$loader = new ArrayLoader([]);
|
||||
$twig = new Environment($loader, [
|
||||
'strict_variables' => true,
|
||||
'debug' => true,
|
||||
'cache' => false,
|
||||
'autoescape' => false,
|
||||
));
|
||||
]);
|
||||
$twig->addExtension(new TranslationExtension($this->getMockBuilder(TranslatorInterface::class)->getMock()));
|
||||
|
||||
$extractor = new TwigExtractor($twig);
|
||||
|
@ -164,12 +164,12 @@ class TwigExtractorTest extends TestCase
|
|||
{
|
||||
$directory = __DIR__.'/../Fixtures/extractor/';
|
||||
|
||||
return array(
|
||||
array($directory.'with_translations.html.twig'),
|
||||
array(array($directory.'with_translations.html.twig')),
|
||||
array(array(new \SplFileInfo($directory.'with_translations.html.twig'))),
|
||||
array(new \ArrayObject(array($directory.'with_translations.html.twig'))),
|
||||
array(new \ArrayObject(array(new \SplFileInfo($directory.'with_translations.html.twig')))),
|
||||
);
|
||||
return [
|
||||
[$directory.'with_translations.html.twig'],
|
||||
[[$directory.'with_translations.html.twig']],
|
||||
[[new \SplFileInfo($directory.'with_translations.html.twig')]],
|
||||
[new \ArrayObject([$directory.'with_translations.html.twig'])],
|
||||
[new \ArrayObject([new \SplFileInfo($directory.'with_translations.html.twig')])],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ class TransChoiceTokenParser extends TransTokenParser
|
|||
|
||||
@trigger_error(sprintf('The "transchoice" tag is deprecated since Symfony 4.2, use the "trans" one instead with a "%%count%%" parameter in %s line %d.', $stream->getSourceContext()->getName(), $lineno), E_USER_DEPRECATED);
|
||||
|
||||
$vars = new ArrayExpression(array(), $lineno);
|
||||
$vars = new ArrayExpression([], $lineno);
|
||||
|
||||
$count = $this->parser->getExpressionParser()->parseExpression();
|
||||
|
||||
|
@ -69,7 +69,7 @@ class TransChoiceTokenParser extends TransTokenParser
|
|||
|
||||
$stream->expect(Token::BLOCK_END_TYPE);
|
||||
|
||||
$body = $this->parser->subparse(array($this, 'decideTransChoiceFork'), true);
|
||||
$body = $this->parser->subparse([$this, 'decideTransChoiceFork'], true);
|
||||
|
||||
if (!$body instanceof TextNode && !$body instanceof AbstractExpression) {
|
||||
throw new SyntaxError('A message inside a transchoice tag must be a simple text.', $body->getTemplateLine(), $stream->getSourceContext());
|
||||
|
@ -82,7 +82,7 @@ class TransChoiceTokenParser extends TransTokenParser
|
|||
|
||||
public function decideTransChoiceFork($token)
|
||||
{
|
||||
return $token->test(array('endtranschoice'));
|
||||
return $token->test(['endtranschoice']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -40,7 +40,7 @@ class TransTokenParser extends AbstractTokenParser
|
|||
$stream = $this->parser->getStream();
|
||||
|
||||
$count = null;
|
||||
$vars = new ArrayExpression(array(), $lineno);
|
||||
$vars = new ArrayExpression([], $lineno);
|
||||
$domain = null;
|
||||
$locale = null;
|
||||
if (!$stream->test(Token::BLOCK_END_TYPE)) {
|
||||
|
@ -73,7 +73,7 @@ class TransTokenParser extends AbstractTokenParser
|
|||
|
||||
// {% trans %}message{% endtrans %}
|
||||
$stream->expect(Token::BLOCK_END_TYPE);
|
||||
$body = $this->parser->subparse(array($this, 'decideTransFork'), true);
|
||||
$body = $this->parser->subparse([$this, 'decideTransFork'], true);
|
||||
|
||||
if (!$body instanceof TextNode && !$body instanceof AbstractExpression) {
|
||||
throw new SyntaxError('A message inside a trans tag must be a simple text.', $body->getTemplateLine(), $stream->getSourceContext());
|
||||
|
@ -86,7 +86,7 @@ class TransTokenParser extends AbstractTokenParser
|
|||
|
||||
public function decideTransFork($token)
|
||||
{
|
||||
return $token->test(array('endtrans'));
|
||||
return $token->test(['endtrans']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -61,44 +61,44 @@ EOT
|
|||
/** @var KernelInterface $kernel */
|
||||
$kernel = $this->getApplication()->getKernel();
|
||||
|
||||
$rows = array(
|
||||
array('<info>Symfony</>'),
|
||||
$rows = [
|
||||
['<info>Symfony</>'],
|
||||
new TableSeparator(),
|
||||
array('Version', Kernel::VERSION),
|
||||
array('End of maintenance', Kernel::END_OF_MAINTENANCE.(self::isExpired(Kernel::END_OF_MAINTENANCE) ? ' <error>Expired</>' : '')),
|
||||
array('End of life', Kernel::END_OF_LIFE.(self::isExpired(Kernel::END_OF_LIFE) ? ' <error>Expired</>' : '')),
|
||||
['Version', Kernel::VERSION],
|
||||
['End of maintenance', Kernel::END_OF_MAINTENANCE.(self::isExpired(Kernel::END_OF_MAINTENANCE) ? ' <error>Expired</>' : '')],
|
||||
['End of life', Kernel::END_OF_LIFE.(self::isExpired(Kernel::END_OF_LIFE) ? ' <error>Expired</>' : '')],
|
||||
new TableSeparator(),
|
||||
array('<info>Kernel</>'),
|
||||
['<info>Kernel</>'],
|
||||
new TableSeparator(),
|
||||
array('Type', \get_class($kernel)),
|
||||
array('Environment', $kernel->getEnvironment()),
|
||||
array('Debug', $kernel->isDebug() ? 'true' : 'false'),
|
||||
array('Charset', $kernel->getCharset()),
|
||||
array('Cache directory', self::formatPath($kernel->getCacheDir(), $kernel->getProjectDir()).' (<comment>'.self::formatFileSize($kernel->getCacheDir()).'</>)'),
|
||||
array('Log directory', self::formatPath($kernel->getLogDir(), $kernel->getProjectDir()).' (<comment>'.self::formatFileSize($kernel->getLogDir()).'</>)'),
|
||||
['Type', \get_class($kernel)],
|
||||
['Environment', $kernel->getEnvironment()],
|
||||
['Debug', $kernel->isDebug() ? 'true' : 'false'],
|
||||
['Charset', $kernel->getCharset()],
|
||||
['Cache directory', self::formatPath($kernel->getCacheDir(), $kernel->getProjectDir()).' (<comment>'.self::formatFileSize($kernel->getCacheDir()).'</>)'],
|
||||
['Log directory', self::formatPath($kernel->getLogDir(), $kernel->getProjectDir()).' (<comment>'.self::formatFileSize($kernel->getLogDir()).'</>)'],
|
||||
new TableSeparator(),
|
||||
array('<info>PHP</>'),
|
||||
['<info>PHP</>'],
|
||||
new TableSeparator(),
|
||||
array('Version', PHP_VERSION),
|
||||
array('Architecture', (PHP_INT_SIZE * 8).' bits'),
|
||||
array('Intl locale', class_exists('Locale', false) && \Locale::getDefault() ? \Locale::getDefault() : 'n/a'),
|
||||
array('Timezone', date_default_timezone_get().' (<comment>'.(new \DateTime())->format(\DateTime::W3C).'</>)'),
|
||||
array('OPcache', \extension_loaded('Zend OPcache') && filter_var(ini_get('opcache.enable'), FILTER_VALIDATE_BOOLEAN) ? 'true' : 'false'),
|
||||
array('APCu', \extension_loaded('apcu') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? 'true' : 'false'),
|
||||
array('Xdebug', \extension_loaded('xdebug') ? 'true' : 'false'),
|
||||
);
|
||||
['Version', PHP_VERSION],
|
||||
['Architecture', (PHP_INT_SIZE * 8).' bits'],
|
||||
['Intl locale', class_exists('Locale', false) && \Locale::getDefault() ? \Locale::getDefault() : 'n/a'],
|
||||
['Timezone', date_default_timezone_get().' (<comment>'.(new \DateTime())->format(\DateTime::W3C).'</>)'],
|
||||
['OPcache', \extension_loaded('Zend OPcache') && filter_var(ini_get('opcache.enable'), FILTER_VALIDATE_BOOLEAN) ? 'true' : 'false'],
|
||||
['APCu', \extension_loaded('apcu') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? 'true' : 'false'],
|
||||
['Xdebug', \extension_loaded('xdebug') ? 'true' : 'false'],
|
||||
];
|
||||
|
||||
if ($dotenv = self::getDotenvVars()) {
|
||||
$rows = array_merge($rows, array(
|
||||
$rows = array_merge($rows, [
|
||||
new TableSeparator(),
|
||||
array('<info>Environment (.env)</>'),
|
||||
['<info>Environment (.env)</>'],
|
||||
new TableSeparator(),
|
||||
), array_map(function ($value, $name) {
|
||||
return array($name, $value);
|
||||
], array_map(function ($value, $name) {
|
||||
return [$name, $value];
|
||||
}, $dotenv, array_keys($dotenv)));
|
||||
}
|
||||
|
||||
$io->table(array(), $rows);
|
||||
$io->table([], $rows);
|
||||
}
|
||||
|
||||
private static function formatPath(string $path, string $baseDir): string
|
||||
|
@ -129,7 +129,7 @@ EOT
|
|||
|
||||
private static function getDotenvVars(): array
|
||||
{
|
||||
$vars = array();
|
||||
$vars = [];
|
||||
foreach (explode(',', getenv('SYMFONY_DOTENV_VARS')) as $name) {
|
||||
if ('' !== $name && false !== $value = getenv($name)) {
|
||||
$vars[$name] = $value;
|
||||
|
|
|
@ -48,7 +48,7 @@ class ContainerDebugCommand extends Command
|
|||
protected function configure()
|
||||
{
|
||||
$this
|
||||
->setDefinition(array(
|
||||
->setDefinition([
|
||||
new InputArgument('name', InputArgument::OPTIONAL, 'A service name (foo)'),
|
||||
new InputOption('show-private', null, InputOption::VALUE_NONE, 'Used to show public *and* private services (deprecated)'),
|
||||
new InputOption('show-arguments', null, InputOption::VALUE_NONE, 'Used to show arguments in services'),
|
||||
|
@ -60,7 +60,7 @@ class ContainerDebugCommand extends Command
|
|||
new InputOption('types', null, InputOption::VALUE_NONE, 'Displays types (classes/interfaces) available in the container'),
|
||||
new InputOption('format', null, InputOption::VALUE_REQUIRED, 'The output format (txt, xml, json, or md)', 'txt'),
|
||||
new InputOption('raw', null, InputOption::VALUE_NONE, 'To output raw description'),
|
||||
))
|
||||
])
|
||||
->setDescription('Displays current services for an application')
|
||||
->setHelp(<<<'EOF'
|
||||
The <info>%command.name%</info> command displays all configured <comment>public</comment> services:
|
||||
|
@ -117,26 +117,26 @@ EOF
|
|||
$object = $this->getContainerBuilder();
|
||||
|
||||
if ($input->getOption('types')) {
|
||||
$options = array();
|
||||
$options['filter'] = array($this, 'filterToServiceTypes');
|
||||
$options = [];
|
||||
$options['filter'] = [$this, 'filterToServiceTypes'];
|
||||
} elseif ($input->getOption('parameters')) {
|
||||
$parameters = array();
|
||||
$parameters = [];
|
||||
foreach ($object->getParameterBag()->all() as $k => $v) {
|
||||
$parameters[$k] = $object->resolveEnvPlaceholders($v);
|
||||
}
|
||||
$object = new ParameterBag($parameters);
|
||||
$options = array();
|
||||
$options = [];
|
||||
} elseif ($parameter = $input->getOption('parameter')) {
|
||||
$options = array('parameter' => $parameter);
|
||||
$options = ['parameter' => $parameter];
|
||||
} elseif ($input->getOption('tags')) {
|
||||
$options = array('group_by' => 'tags');
|
||||
$options = ['group_by' => 'tags'];
|
||||
} elseif ($tag = $input->getOption('tag')) {
|
||||
$options = array('tag' => $tag);
|
||||
$options = ['tag' => $tag];
|
||||
} elseif ($name = $input->getArgument('name')) {
|
||||
$name = $this->findProperServiceName($input, $errorIo, $object, $name, $input->getOption('show-hidden'));
|
||||
$options = array('id' => $name);
|
||||
$options = ['id' => $name];
|
||||
} else {
|
||||
$options = array();
|
||||
$options = [];
|
||||
}
|
||||
|
||||
$helper = new DescriptorHelper();
|
||||
|
@ -150,7 +150,7 @@ EOF
|
|||
$helper->describe($io, $object, $options);
|
||||
} catch (ServiceNotFoundException $e) {
|
||||
if ('' !== $e->getId() && '@' === $e->getId()[0]) {
|
||||
throw new ServiceNotFoundException($e->getId(), $e->getSourceId(), null, array(substr($e->getId(), 1)));
|
||||
throw new ServiceNotFoundException($e->getId(), $e->getSourceId(), null, [substr($e->getId(), 1)]);
|
||||
}
|
||||
|
||||
throw $e;
|
||||
|
@ -174,7 +174,7 @@ EOF
|
|||
*/
|
||||
protected function validateInput(InputInterface $input)
|
||||
{
|
||||
$options = array('tags', 'tag', 'parameters', 'parameter');
|
||||
$options = ['tags', 'tag', 'parameters', 'parameter'];
|
||||
|
||||
$optionsCount = 0;
|
||||
foreach ($options as $option) {
|
||||
|
@ -209,7 +209,7 @@ EOF
|
|||
if (!$kernel->isDebug() || !(new ConfigCache($kernel->getContainer()->getParameter('debug.container.dump'), true))->isFresh()) {
|
||||
$buildContainer = \Closure::bind(function () { return $this->buildContainer(); }, $kernel, \get_class($kernel));
|
||||
$container = $buildContainer();
|
||||
$container->getCompilerPassConfig()->setRemovingPasses(array());
|
||||
$container->getCompilerPassConfig()->setRemovingPasses([]);
|
||||
$container->compile();
|
||||
} else {
|
||||
(new XmlFileLoader($container = new ContainerBuilder(), new FileLocator()))->load($kernel->getContainer()->getParameter('debug.container.dump'));
|
||||
|
@ -239,7 +239,7 @@ EOF
|
|||
private function findServiceIdsContaining(ContainerBuilder $builder, string $name, bool $showHidden)
|
||||
{
|
||||
$serviceIds = $builder->getServiceIds();
|
||||
$foundServiceIds = $foundServiceIdsIgnoringBackslashes = array();
|
||||
$foundServiceIds = $foundServiceIdsIgnoringBackslashes = [];
|
||||
foreach ($serviceIds as $serviceId) {
|
||||
if (!$showHidden && 0 === strpos($serviceId, '.')) {
|
||||
continue;
|
||||
|
|
|
@ -35,10 +35,10 @@ class DebugAutowiringCommand extends ContainerDebugCommand
|
|||
protected function configure()
|
||||
{
|
||||
$this
|
||||
->setDefinition(array(
|
||||
->setDefinition([
|
||||
new InputArgument('search', InputArgument::OPTIONAL, 'A search filter'),
|
||||
new InputOption('all', null, InputOption::VALUE_NONE, 'Show also services that are not aliased'),
|
||||
))
|
||||
])
|
||||
->setDescription('Lists classes/interfaces you can use for autowiring')
|
||||
->setHelp(<<<'EOF'
|
||||
The <info>%command.name%</info> command displays the classes and interfaces that
|
||||
|
@ -65,7 +65,7 @@ EOF
|
|||
|
||||
$builder = $this->getContainerBuilder();
|
||||
$serviceIds = $builder->getServiceIds();
|
||||
$serviceIds = array_filter($serviceIds, array($this, 'filterToServiceTypes'));
|
||||
$serviceIds = array_filter($serviceIds, [$this, 'filterToServiceTypes']);
|
||||
|
||||
if ($search = $input->getArgument('search')) {
|
||||
$serviceIds = array_filter($serviceIds, function ($serviceId) use ($search) {
|
||||
|
@ -86,11 +86,11 @@ EOF
|
|||
if ($search) {
|
||||
$io->text(sprintf('(only showing classes/interfaces matching <comment>%s</comment>)', $search));
|
||||
}
|
||||
$hasAlias = array();
|
||||
$hasAlias = [];
|
||||
$all = $input->getOption('all');
|
||||
$previousId = '-';
|
||||
foreach ($serviceIds as $serviceId) {
|
||||
$text = array();
|
||||
$text = [];
|
||||
if (0 !== strpos($serviceId, $previousId)) {
|
||||
$text[] = '';
|
||||
if ('' !== $description = Descriptor::getClassDescription($serviceId, $serviceId)) {
|
||||
|
|
|
@ -74,14 +74,14 @@ class TranslationDebugCommand extends Command
|
|||
protected function configure()
|
||||
{
|
||||
$this
|
||||
->setDefinition(array(
|
||||
->setDefinition([
|
||||
new InputArgument('locale', InputArgument::REQUIRED, 'The locale'),
|
||||
new InputArgument('bundle', InputArgument::OPTIONAL, 'The bundle name or directory where to load the messages'),
|
||||
new InputOption('domain', null, InputOption::VALUE_OPTIONAL, 'The messages domain'),
|
||||
new InputOption('only-missing', null, InputOption::VALUE_NONE, 'Displays only missing messages'),
|
||||
new InputOption('only-unused', null, InputOption::VALUE_NONE, 'Displays only unused messages'),
|
||||
new InputOption('all', null, InputOption::VALUE_NONE, 'Load messages from all registered bundles'),
|
||||
))
|
||||
])
|
||||
->setDescription('Displays translation messages information')
|
||||
->setHelp(<<<'EOF'
|
||||
The <info>%command.name%</info> command helps finding unused or missing translation
|
||||
|
@ -131,7 +131,7 @@ EOF
|
|||
$rootDir = $kernel->getContainer()->getParameter('kernel.root_dir');
|
||||
|
||||
// Define Root Paths
|
||||
$transPaths = array();
|
||||
$transPaths = [];
|
||||
if (is_dir($dir = $rootDir.'/Resources/translations')) {
|
||||
if ($dir !== $this->defaultTransPath) {
|
||||
$notice = sprintf('Storing translations in the "%s" directory is deprecated since Symfony 4.2, ', $dir);
|
||||
|
@ -142,7 +142,7 @@ EOF
|
|||
if ($this->defaultTransPath) {
|
||||
$transPaths[] = $this->defaultTransPath;
|
||||
}
|
||||
$viewsPaths = array();
|
||||
$viewsPaths = [];
|
||||
if (is_dir($dir = $rootDir.'/Resources/views')) {
|
||||
if ($dir !== $this->defaultViewsPath) {
|
||||
$notice = sprintf('Storing templates in the "%s" directory is deprecated since Symfony 4.2, ', $dir);
|
||||
|
@ -158,7 +158,7 @@ EOF
|
|||
if (null !== $input->getArgument('bundle')) {
|
||||
try {
|
||||
$bundle = $kernel->getBundle($input->getArgument('bundle'));
|
||||
$transPaths = array($bundle->getPath().'/Resources/translations');
|
||||
$transPaths = [$bundle->getPath().'/Resources/translations'];
|
||||
if ($this->defaultTransPath) {
|
||||
$transPaths[] = $this->defaultTransPath;
|
||||
}
|
||||
|
@ -167,7 +167,7 @@ EOF
|
|||
$notice = sprintf('Storing translations files for "%s" in the "%s" directory is deprecated since Symfony 4.2, ', $dir, $bundle->getName());
|
||||
@trigger_error($notice.($this->defaultTransPath ? sprintf('use the "%s" directory instead.', $this->defaultTransPath) : 'configure and use "framework.translator.default_path" instead.'), E_USER_DEPRECATED);
|
||||
}
|
||||
$viewsPaths = array($bundle->getPath().'/Resources/views');
|
||||
$viewsPaths = [$bundle->getPath().'/Resources/views'];
|
||||
if ($this->defaultViewsPath) {
|
||||
$viewsPaths[] = $this->defaultViewsPath;
|
||||
}
|
||||
|
@ -180,7 +180,7 @@ EOF
|
|||
// such a bundle does not exist, so treat the argument as path
|
||||
$path = $input->getArgument('bundle');
|
||||
|
||||
$transPaths = array($path.'/translations');
|
||||
$transPaths = [$path.'/translations'];
|
||||
if (is_dir($dir = $path.'/Resources/translations')) {
|
||||
if ($dir !== $this->defaultTransPath) {
|
||||
@trigger_error(sprintf('Storing translations in the "%s" directory is deprecated since Symfony 4.2, use the "%s" directory instead.', $dir, $path.'/translations'), E_USER_DEPRECATED);
|
||||
|
@ -188,7 +188,7 @@ EOF
|
|||
$transPaths[] = $dir;
|
||||
}
|
||||
|
||||
$viewsPaths = array($path.'/templates');
|
||||
$viewsPaths = [$path.'/templates'];
|
||||
if (is_dir($dir = $path.'/Resources/views')) {
|
||||
if ($dir !== $this->defaultViewsPath) {
|
||||
@trigger_error(sprintf('Storing templates in the "%s" directory is deprecated since Symfony 4.2, use the "%s" directory instead.', $dir, $path.'/templates'), E_USER_DEPRECATED);
|
||||
|
@ -227,7 +227,7 @@ EOF
|
|||
$mergeOperation = new MergeOperation($extractedCatalogue, $currentCatalogue);
|
||||
$allMessages = $mergeOperation->getResult()->all($domain);
|
||||
if (null !== $domain) {
|
||||
$allMessages = array($domain => $allMessages);
|
||||
$allMessages = [$domain => $allMessages];
|
||||
}
|
||||
|
||||
// No defined or extracted messages
|
||||
|
@ -247,16 +247,16 @@ EOF
|
|||
$fallbackCatalogues = $this->loadFallbackCatalogues($locale, $transPaths);
|
||||
|
||||
// Display header line
|
||||
$headers = array('State', 'Domain', 'Id', sprintf('Message Preview (%s)', $locale));
|
||||
$headers = ['State', 'Domain', 'Id', sprintf('Message Preview (%s)', $locale)];
|
||||
foreach ($fallbackCatalogues as $fallbackCatalogue) {
|
||||
$headers[] = sprintf('Fallback Message Preview (%s)', $fallbackCatalogue->getLocale());
|
||||
}
|
||||
$rows = array();
|
||||
$rows = [];
|
||||
// Iterate all message ids and determine their state
|
||||
foreach ($allMessages as $domain => $messages) {
|
||||
foreach (array_keys($messages) as $messageId) {
|
||||
$value = $currentCatalogue->get($messageId, $domain);
|
||||
$states = array();
|
||||
$states = [];
|
||||
|
||||
if ($extractedCatalogue->defines($messageId, $domain)) {
|
||||
if (!$currentCatalogue->defines($messageId, $domain)) {
|
||||
|
@ -279,7 +279,7 @@ EOF
|
|||
}
|
||||
}
|
||||
|
||||
$row = array($this->formatStates($states), $domain, $this->formatId($messageId), $this->sanitizeString($value));
|
||||
$row = [$this->formatStates($states), $domain, $this->formatId($messageId), $this->sanitizeString($value)];
|
||||
foreach ($fallbackCatalogues as $fallbackCatalogue) {
|
||||
$row[] = $this->sanitizeString($fallbackCatalogue->get($messageId, $domain));
|
||||
}
|
||||
|
@ -310,7 +310,7 @@ EOF
|
|||
|
||||
private function formatStates(array $states): string
|
||||
{
|
||||
$result = array();
|
||||
$result = [];
|
||||
foreach ($states as $state) {
|
||||
$result[] = $this->formatState($state);
|
||||
}
|
||||
|
@ -367,7 +367,7 @@ EOF
|
|||
*/
|
||||
private function loadFallbackCatalogues(string $locale, array $transPaths): array
|
||||
{
|
||||
$fallbackCatalogues = array();
|
||||
$fallbackCatalogues = [];
|
||||
if ($this->translator instanceof Translator || $this->translator instanceof DataCollectorTranslator || $this->translator instanceof LoggingTranslator) {
|
||||
foreach ($this->translator->getFallbackLocales() as $fallbackLocale) {
|
||||
if ($fallbackLocale === $locale) {
|
||||
|
|
|
@ -63,7 +63,7 @@ class TranslationUpdateCommand extends Command
|
|||
protected function configure()
|
||||
{
|
||||
$this
|
||||
->setDefinition(array(
|
||||
->setDefinition([
|
||||
new InputArgument('locale', InputArgument::REQUIRED, 'The locale'),
|
||||
new InputArgument('bundle', InputArgument::OPTIONAL, 'The bundle name or directory where to load the messages'),
|
||||
new InputOption('prefix', null, InputOption::VALUE_OPTIONAL, 'Override the default prefix', '__'),
|
||||
|
@ -73,7 +73,7 @@ class TranslationUpdateCommand extends Command
|
|||
new InputOption('no-backup', null, InputOption::VALUE_NONE, 'Should backup be disabled'),
|
||||
new InputOption('clean', null, InputOption::VALUE_NONE, 'Should clean not found messages'),
|
||||
new InputOption('domain', null, InputOption::VALUE_OPTIONAL, 'Specify the domain to update'),
|
||||
))
|
||||
])
|
||||
->setDescription('Updates the translation file')
|
||||
->setHelp(<<<'EOF'
|
||||
The <info>%command.name%</info> command extracts translation strings from templates
|
||||
|
@ -112,7 +112,7 @@ EOF
|
|||
// check format
|
||||
$supportedFormats = $this->writer->getFormats();
|
||||
if (!\in_array($input->getOption('output-format'), $supportedFormats, true)) {
|
||||
$errorIo->error(array('Wrong output format', 'Supported formats are: '.implode(', ', $supportedFormats).'.'));
|
||||
$errorIo->error(['Wrong output format', 'Supported formats are: '.implode(', ', $supportedFormats).'.']);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -121,7 +121,7 @@ EOF
|
|||
$rootDir = $kernel->getContainer()->getParameter('kernel.root_dir');
|
||||
|
||||
// Define Root Paths
|
||||
$transPaths = array();
|
||||
$transPaths = [];
|
||||
if (is_dir($dir = $rootDir.'/Resources/translations')) {
|
||||
if ($dir !== $this->defaultTransPath) {
|
||||
$notice = sprintf('Storing translations in the "%s" directory is deprecated since Symfony 4.2, ', $dir);
|
||||
|
@ -132,7 +132,7 @@ EOF
|
|||
if ($this->defaultTransPath) {
|
||||
$transPaths[] = $this->defaultTransPath;
|
||||
}
|
||||
$viewsPaths = array();
|
||||
$viewsPaths = [];
|
||||
if (is_dir($dir = $rootDir.'/Resources/views')) {
|
||||
if ($dir !== $this->defaultViewsPath) {
|
||||
$notice = sprintf('Storing templates in the "%s" directory is deprecated since Symfony 4.2, ', $dir);
|
||||
|
@ -149,7 +149,7 @@ EOF
|
|||
if (null !== $input->getArgument('bundle')) {
|
||||
try {
|
||||
$foundBundle = $kernel->getBundle($input->getArgument('bundle'));
|
||||
$transPaths = array($foundBundle->getPath().'/Resources/translations');
|
||||
$transPaths = [$foundBundle->getPath().'/Resources/translations'];
|
||||
if ($this->defaultTransPath) {
|
||||
$transPaths[] = $this->defaultTransPath;
|
||||
}
|
||||
|
@ -158,7 +158,7 @@ EOF
|
|||
$notice = sprintf('Storing translations files for "%s" in the "%s" directory is deprecated since Symfony 4.2, ', $foundBundle->getName(), $dir);
|
||||
@trigger_error($notice.($this->defaultTransPath ? sprintf('use the "%s" directory instead.', $this->defaultTransPath) : 'configure and use "framework.translator.default_path" instead.'), E_USER_DEPRECATED);
|
||||
}
|
||||
$viewsPaths = array($foundBundle->getPath().'/Resources/views');
|
||||
$viewsPaths = [$foundBundle->getPath().'/Resources/views'];
|
||||
if ($this->defaultViewsPath) {
|
||||
$viewsPaths[] = $this->defaultViewsPath;
|
||||
}
|
||||
|
@ -172,7 +172,7 @@ EOF
|
|||
// such a bundle does not exist, so treat the argument as path
|
||||
$path = $input->getArgument('bundle');
|
||||
|
||||
$transPaths = array($path.'/translations');
|
||||
$transPaths = [$path.'/translations'];
|
||||
if (is_dir($dir = $path.'/Resources/translations')) {
|
||||
if ($dir !== $this->defaultTransPath) {
|
||||
@trigger_error(sprintf('Storing translations in the "%s" directory is deprecated since Symfony 4.2, use the "%s" directory instead.', $dir, $path.'/translations'), E_USER_DEPRECATED);
|
||||
|
@ -180,7 +180,7 @@ EOF
|
|||
$transPaths[] = $dir;
|
||||
}
|
||||
|
||||
$viewsPaths = array($path.'/templates');
|
||||
$viewsPaths = [$path.'/templates'];
|
||||
if (is_dir($dir = $path.'/Resources/views')) {
|
||||
if ($dir !== $this->defaultViewsPath) {
|
||||
@trigger_error(sprintf('Storing templates in the "%s" directory is deprecated since Symfony 4.2, use the "%s" directory instead.', $dir, $path.'/templates'), E_USER_DEPRECATED);
|
||||
|
@ -287,7 +287,7 @@ EOF
|
|||
$bundleTransPath = end($transPaths);
|
||||
}
|
||||
|
||||
$this->writer->write($operation->getResult(), $input->getOption('output-format'), array('path' => $bundleTransPath, 'default_locale' => $this->defaultLocale));
|
||||
$this->writer->write($operation->getResult(), $input->getOption('output-format'), ['path' => $bundleTransPath, 'default_locale' => $this->defaultLocale]);
|
||||
|
||||
if (true === $input->getOption('dump-messages')) {
|
||||
$resultMessage .= ' and translation files were updated';
|
||||
|
|
|
@ -36,24 +36,24 @@ class TextDescriptor extends Descriptor
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function describeRouteCollection(RouteCollection $routes, array $options = array())
|
||||
protected function describeRouteCollection(RouteCollection $routes, array $options = [])
|
||||
{
|
||||
$showControllers = isset($options['show_controllers']) && $options['show_controllers'];
|
||||
|
||||
$tableHeaders = array('Name', 'Method', 'Scheme', 'Host', 'Path');
|
||||
$tableHeaders = ['Name', 'Method', 'Scheme', 'Host', 'Path'];
|
||||
if ($showControllers) {
|
||||
$tableHeaders[] = 'Controller';
|
||||
}
|
||||
|
||||
$tableRows = array();
|
||||
$tableRows = [];
|
||||
foreach ($routes->all() as $name => $route) {
|
||||
$row = array(
|
||||
$row = [
|
||||
$name,
|
||||
$route->getMethods() ? implode('|', $route->getMethods()) : 'ANY',
|
||||
$route->getSchemes() ? implode('|', $route->getSchemes()) : 'ANY',
|
||||
'' !== $route->getHost() ? $route->getHost() : 'ANY',
|
||||
$route->getPath(),
|
||||
);
|
||||
];
|
||||
|
||||
if ($showControllers) {
|
||||
$controller = $route->getDefault('_controller');
|
||||
|
@ -75,22 +75,22 @@ class TextDescriptor extends Descriptor
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function describeRoute(Route $route, array $options = array())
|
||||
protected function describeRoute(Route $route, array $options = [])
|
||||
{
|
||||
$tableHeaders = array('Property', 'Value');
|
||||
$tableRows = array(
|
||||
array('Route Name', isset($options['name']) ? $options['name'] : ''),
|
||||
array('Path', $route->getPath()),
|
||||
array('Path Regex', $route->compile()->getRegex()),
|
||||
array('Host', ('' !== $route->getHost() ? $route->getHost() : 'ANY')),
|
||||
array('Host Regex', ('' !== $route->getHost() ? $route->compile()->getHostRegex() : '')),
|
||||
array('Scheme', ($route->getSchemes() ? implode('|', $route->getSchemes()) : 'ANY')),
|
||||
array('Method', ($route->getMethods() ? implode('|', $route->getMethods()) : 'ANY')),
|
||||
array('Requirements', ($route->getRequirements() ? $this->formatRouterConfig($route->getRequirements()) : 'NO CUSTOM')),
|
||||
array('Class', \get_class($route)),
|
||||
array('Defaults', $this->formatRouterConfig($route->getDefaults())),
|
||||
array('Options', $this->formatRouterConfig($route->getOptions())),
|
||||
);
|
||||
$tableHeaders = ['Property', 'Value'];
|
||||
$tableRows = [
|
||||
['Route Name', isset($options['name']) ? $options['name'] : ''],
|
||||
['Path', $route->getPath()],
|
||||
['Path Regex', $route->compile()->getRegex()],
|
||||
['Host', ('' !== $route->getHost() ? $route->getHost() : 'ANY')],
|
||||
['Host Regex', ('' !== $route->getHost() ? $route->compile()->getHostRegex() : '')],
|
||||
['Scheme', ($route->getSchemes() ? implode('|', $route->getSchemes()) : 'ANY')],
|
||||
['Method', ($route->getMethods() ? implode('|', $route->getMethods()) : 'ANY')],
|
||||
['Requirements', ($route->getRequirements() ? $this->formatRouterConfig($route->getRequirements()) : 'NO CUSTOM')],
|
||||
['Class', \get_class($route)],
|
||||
['Defaults', $this->formatRouterConfig($route->getDefaults())],
|
||||
['Options', $this->formatRouterConfig($route->getOptions())],
|
||||
];
|
||||
|
||||
$table = new Table($this->getOutput());
|
||||
$table->setHeaders($tableHeaders)->setRows($tableRows);
|
||||
|
@ -100,13 +100,13 @@ class TextDescriptor extends Descriptor
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function describeContainerParameters(ParameterBag $parameters, array $options = array())
|
||||
protected function describeContainerParameters(ParameterBag $parameters, array $options = [])
|
||||
{
|
||||
$tableHeaders = array('Parameter', 'Value');
|
||||
$tableHeaders = ['Parameter', 'Value'];
|
||||
|
||||
$tableRows = array();
|
||||
$tableRows = [];
|
||||
foreach ($this->sortParameters($parameters) as $parameter => $value) {
|
||||
$tableRows[] = array($parameter, $this->formatParameter($value));
|
||||
$tableRows[] = [$parameter, $this->formatParameter($value)];
|
||||
}
|
||||
|
||||
$options['output']->title('Symfony Container Parameters');
|
||||
|
@ -116,7 +116,7 @@ class TextDescriptor extends Descriptor
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function describeContainerTags(ContainerBuilder $builder, array $options = array())
|
||||
protected function describeContainerTags(ContainerBuilder $builder, array $options = [])
|
||||
{
|
||||
$showHidden = isset($options['show_hidden']) && $options['show_hidden'];
|
||||
|
||||
|
@ -135,7 +135,7 @@ class TextDescriptor extends Descriptor
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function describeContainerService($service, array $options = array(), ContainerBuilder $builder = null)
|
||||
protected function describeContainerService($service, array $options = [], ContainerBuilder $builder = null)
|
||||
{
|
||||
if (!isset($options['id'])) {
|
||||
throw new \InvalidArgumentException('An "id" option must be provided.');
|
||||
|
@ -148,10 +148,10 @@ class TextDescriptor extends Descriptor
|
|||
} else {
|
||||
$options['output']->title(sprintf('Information for Service "<info>%s</info>"', $options['id']));
|
||||
$options['output']->table(
|
||||
array('Service ID', 'Class'),
|
||||
array(
|
||||
array(isset($options['id']) ? $options['id'] : '-', \get_class($service)),
|
||||
)
|
||||
['Service ID', 'Class'],
|
||||
[
|
||||
[isset($options['id']) ? $options['id'] : '-', \get_class($service)],
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -159,7 +159,7 @@ class TextDescriptor extends Descriptor
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function describeContainerServices(ContainerBuilder $builder, array $options = array())
|
||||
protected function describeContainerServices(ContainerBuilder $builder, array $options = [])
|
||||
{
|
||||
$showHidden = isset($options['show_hidden']) && $options['show_hidden'];
|
||||
$showTag = isset($options['tag']) ? $options['tag'] : null;
|
||||
|
@ -177,7 +177,7 @@ class TextDescriptor extends Descriptor
|
|||
$options['output']->title($title);
|
||||
|
||||
$serviceIds = isset($options['tag']) && $options['tag'] ? array_keys($builder->findTaggedServiceIds($options['tag'])) : $builder->getServiceIds();
|
||||
$maxTags = array();
|
||||
$maxTags = [];
|
||||
|
||||
if (isset($options['filter'])) {
|
||||
$serviceIds = array_filter($serviceIds, $options['filter']);
|
||||
|
@ -212,8 +212,8 @@ class TextDescriptor extends Descriptor
|
|||
$tagsCount = \count($maxTags);
|
||||
$tagsNames = array_keys($maxTags);
|
||||
|
||||
$tableHeaders = array_merge(array('Service ID'), $tagsNames, array('Class name'));
|
||||
$tableRows = array();
|
||||
$tableHeaders = array_merge(['Service ID'], $tagsNames, ['Class name']);
|
||||
$tableRows = [];
|
||||
$rawOutput = isset($options['raw_text']) && $options['raw_text'];
|
||||
foreach ($this->sortServiceIds($serviceIds) as $serviceId) {
|
||||
$definition = $this->resolveServiceDefinition($builder, $serviceId);
|
||||
|
@ -222,24 +222,24 @@ class TextDescriptor extends Descriptor
|
|||
if ($definition instanceof Definition) {
|
||||
if ($showTag) {
|
||||
foreach ($definition->getTag($showTag) as $key => $tag) {
|
||||
$tagValues = array();
|
||||
$tagValues = [];
|
||||
foreach ($tagsNames as $tagName) {
|
||||
$tagValues[] = isset($tag[$tagName]) ? $tag[$tagName] : '';
|
||||
}
|
||||
if (0 === $key) {
|
||||
$tableRows[] = array_merge(array($serviceId), $tagValues, array($definition->getClass()));
|
||||
$tableRows[] = array_merge([$serviceId], $tagValues, [$definition->getClass()]);
|
||||
} else {
|
||||
$tableRows[] = array_merge(array(' "'), $tagValues, array(''));
|
||||
$tableRows[] = array_merge([' "'], $tagValues, ['']);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$tableRows[] = array($styledServiceId, $definition->getClass());
|
||||
$tableRows[] = [$styledServiceId, $definition->getClass()];
|
||||
}
|
||||
} elseif ($definition instanceof Alias) {
|
||||
$alias = $definition;
|
||||
$tableRows[] = array_merge(array($styledServiceId, sprintf('alias for "%s"', $alias)), $tagsCount ? array_fill(0, $tagsCount, '') : array());
|
||||
$tableRows[] = array_merge([$styledServiceId, sprintf('alias for "%s"', $alias)], $tagsCount ? array_fill(0, $tagsCount, '') : []);
|
||||
} else {
|
||||
$tableRows[] = array_merge(array($styledServiceId, \get_class($definition)), $tagsCount ? array_fill(0, $tagsCount, '') : array());
|
||||
$tableRows[] = array_merge([$styledServiceId, \get_class($definition)], $tagsCount ? array_fill(0, $tagsCount, '') : []);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -249,7 +249,7 @@ class TextDescriptor extends Descriptor
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function describeContainerDefinition(Definition $definition, array $options = array())
|
||||
protected function describeContainerDefinition(Definition $definition, array $options = [])
|
||||
{
|
||||
if (isset($options['id'])) {
|
||||
$options['output']->title(sprintf('Information for Service "<info>%s</info>"', $options['id']));
|
||||
|
@ -259,14 +259,14 @@ class TextDescriptor extends Descriptor
|
|||
$options['output']->text($classDescription."\n");
|
||||
}
|
||||
|
||||
$tableHeaders = array('Option', 'Value');
|
||||
$tableHeaders = ['Option', 'Value'];
|
||||
|
||||
$tableRows[] = array('Service ID', isset($options['id']) ? $options['id'] : '-');
|
||||
$tableRows[] = array('Class', $definition->getClass() ?: '-');
|
||||
$tableRows[] = ['Service ID', isset($options['id']) ? $options['id'] : '-'];
|
||||
$tableRows[] = ['Class', $definition->getClass() ?: '-'];
|
||||
|
||||
$omitTags = isset($options['omit_tags']) && $options['omit_tags'];
|
||||
if (!$omitTags && ($tags = $definition->getTags())) {
|
||||
$tagInformation = array();
|
||||
$tagInformation = [];
|
||||
foreach ($tags as $tagName => $tagData) {
|
||||
foreach ($tagData as $tagParameters) {
|
||||
$parameters = array_map(function ($key, $value) {
|
||||
|
@ -285,46 +285,46 @@ class TextDescriptor extends Descriptor
|
|||
} else {
|
||||
$tagInformation = '-';
|
||||
}
|
||||
$tableRows[] = array('Tags', $tagInformation);
|
||||
$tableRows[] = ['Tags', $tagInformation];
|
||||
|
||||
$calls = $definition->getMethodCalls();
|
||||
if (\count($calls) > 0) {
|
||||
$callInformation = array();
|
||||
$callInformation = [];
|
||||
foreach ($calls as $call) {
|
||||
$callInformation[] = $call[0];
|
||||
}
|
||||
$tableRows[] = array('Calls', implode(', ', $callInformation));
|
||||
$tableRows[] = ['Calls', implode(', ', $callInformation)];
|
||||
}
|
||||
|
||||
$tableRows[] = array('Public', $definition->isPublic() && !$definition->isPrivate() ? 'yes' : 'no');
|
||||
$tableRows[] = array('Synthetic', $definition->isSynthetic() ? 'yes' : 'no');
|
||||
$tableRows[] = array('Lazy', $definition->isLazy() ? 'yes' : 'no');
|
||||
$tableRows[] = array('Shared', $definition->isShared() ? 'yes' : 'no');
|
||||
$tableRows[] = array('Abstract', $definition->isAbstract() ? 'yes' : 'no');
|
||||
$tableRows[] = array('Autowired', $definition->isAutowired() ? 'yes' : 'no');
|
||||
$tableRows[] = array('Autoconfigured', $definition->isAutoconfigured() ? 'yes' : 'no');
|
||||
$tableRows[] = ['Public', $definition->isPublic() && !$definition->isPrivate() ? 'yes' : 'no'];
|
||||
$tableRows[] = ['Synthetic', $definition->isSynthetic() ? 'yes' : 'no'];
|
||||
$tableRows[] = ['Lazy', $definition->isLazy() ? 'yes' : 'no'];
|
||||
$tableRows[] = ['Shared', $definition->isShared() ? 'yes' : 'no'];
|
||||
$tableRows[] = ['Abstract', $definition->isAbstract() ? 'yes' : 'no'];
|
||||
$tableRows[] = ['Autowired', $definition->isAutowired() ? 'yes' : 'no'];
|
||||
$tableRows[] = ['Autoconfigured', $definition->isAutoconfigured() ? 'yes' : 'no'];
|
||||
|
||||
if ($definition->getFile()) {
|
||||
$tableRows[] = array('Required File', $definition->getFile() ?: '-');
|
||||
$tableRows[] = ['Required File', $definition->getFile() ?: '-'];
|
||||
}
|
||||
|
||||
if ($factory = $definition->getFactory()) {
|
||||
if (\is_array($factory)) {
|
||||
if ($factory[0] instanceof Reference) {
|
||||
$tableRows[] = array('Factory Service', $factory[0]);
|
||||
$tableRows[] = ['Factory Service', $factory[0]];
|
||||
} elseif ($factory[0] instanceof Definition) {
|
||||
throw new \InvalidArgumentException('Factory is not describable.');
|
||||
} else {
|
||||
$tableRows[] = array('Factory Class', $factory[0]);
|
||||
$tableRows[] = ['Factory Class', $factory[0]];
|
||||
}
|
||||
$tableRows[] = array('Factory Method', $factory[1]);
|
||||
$tableRows[] = ['Factory Method', $factory[1]];
|
||||
} else {
|
||||
$tableRows[] = array('Factory Function', $factory);
|
||||
$tableRows[] = ['Factory Function', $factory];
|
||||
}
|
||||
}
|
||||
|
||||
$showArguments = isset($options['show_arguments']) && $options['show_arguments'];
|
||||
$argumentsInformation = array();
|
||||
$argumentsInformation = [];
|
||||
if ($showArguments && ($arguments = $definition->getArguments())) {
|
||||
foreach ($arguments as $argument) {
|
||||
if ($argument instanceof ServiceClosureArgument) {
|
||||
|
@ -343,7 +343,7 @@ class TextDescriptor extends Descriptor
|
|||
}
|
||||
}
|
||||
|
||||
$tableRows[] = array('Arguments', implode("\n", $argumentsInformation));
|
||||
$tableRows[] = ['Arguments', implode("\n", $argumentsInformation)];
|
||||
}
|
||||
|
||||
$options['output']->table($tableHeaders, $tableRows);
|
||||
|
@ -352,7 +352,7 @@ class TextDescriptor extends Descriptor
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function describeContainerAlias(Alias $alias, array $options = array(), ContainerBuilder $builder = null)
|
||||
protected function describeContainerAlias(Alias $alias, array $options = [], ContainerBuilder $builder = null)
|
||||
{
|
||||
if ($alias->isPublic()) {
|
||||
$options['output']->comment(sprintf('This service is a <info>public</info> alias for the service <info>%s</info>', (string) $alias));
|
||||
|
@ -364,26 +364,26 @@ class TextDescriptor extends Descriptor
|
|||
return;
|
||||
}
|
||||
|
||||
return $this->describeContainerDefinition($builder->getDefinition((string) $alias), array_merge($options, array('id' => (string) $alias)));
|
||||
return $this->describeContainerDefinition($builder->getDefinition((string) $alias), array_merge($options, ['id' => (string) $alias]));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function describeContainerParameter($parameter, array $options = array())
|
||||
protected function describeContainerParameter($parameter, array $options = [])
|
||||
{
|
||||
$options['output']->table(
|
||||
array('Parameter', 'Value'),
|
||||
array(
|
||||
array($options['parameter'], $this->formatParameter($parameter),
|
||||
),
|
||||
));
|
||||
['Parameter', 'Value'],
|
||||
[
|
||||
[$options['parameter'], $this->formatParameter($parameter),
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function describeEventDispatcherListeners(EventDispatcherInterface $eventDispatcher, array $options = array())
|
||||
protected function describeEventDispatcherListeners(EventDispatcherInterface $eventDispatcher, array $options = [])
|
||||
{
|
||||
$event = array_key_exists('event', $options) ? $options['event'] : null;
|
||||
|
||||
|
@ -410,19 +410,19 @@ class TextDescriptor extends Descriptor
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function describeCallable($callable, array $options = array())
|
||||
protected function describeCallable($callable, array $options = [])
|
||||
{
|
||||
$this->writeText($this->formatCallable($callable), $options);
|
||||
}
|
||||
|
||||
private function renderEventListenerTable(EventDispatcherInterface $eventDispatcher, $event, array $eventListeners, SymfonyStyle $io)
|
||||
{
|
||||
$tableHeaders = array('Order', 'Callable', 'Priority');
|
||||
$tableRows = array();
|
||||
$tableHeaders = ['Order', 'Callable', 'Priority'];
|
||||
$tableRows = [];
|
||||
|
||||
$order = 1;
|
||||
foreach ($eventListeners as $order => $listener) {
|
||||
$tableRows[] = array(sprintf('#%d', $order + 1), $this->formatCallable($listener), $eventDispatcher->getListenerPriority($event, $listener));
|
||||
$tableRows[] = [sprintf('#%d', $order + 1), $this->formatCallable($listener), $eventDispatcher->getListenerPriority($event, $listener)];
|
||||
}
|
||||
|
||||
$io->table($tableHeaders, $tableRows);
|
||||
|
@ -477,7 +477,7 @@ class TextDescriptor extends Descriptor
|
|||
throw new \InvalidArgumentException('Callable is not describable.');
|
||||
}
|
||||
|
||||
private function writeText(string $content, array $options = array())
|
||||
private function writeText(string $content, array $options = [])
|
||||
{
|
||||
$this->write(
|
||||
isset($options['raw_text']) && $options['raw_text'] ? strip_tags($content) : $content,
|
||||
|
|
|
@ -419,7 +419,7 @@ trait ControllerTrait
|
|||
}
|
||||
|
||||
if (null === $linkProvider = $request->attributes->get('_links')) {
|
||||
$request->attributes->set('_links', new GenericLinkProvider(array($link)));
|
||||
$request->attributes->set('_links', new GenericLinkProvider([$link]));
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ class Configuration implements ConfigurationInterface
|
|||
->beforeNormalization()
|
||||
->ifTrue(function ($v) { return !isset($v['assets']) && isset($v['templating']) && class_exists(Package::class); })
|
||||
->then(function ($v) {
|
||||
$v['assets'] = array();
|
||||
$v['assets'] = [];
|
||||
|
||||
return $v;
|
||||
})
|
||||
|
@ -79,7 +79,7 @@ class Configuration implements ConfigurationInterface
|
|||
->booleanNode('test')->end()
|
||||
->scalarNode('default_locale')->defaultValue('en')->end()
|
||||
->arrayNode('trusted_hosts')
|
||||
->beforeNormalization()->ifString()->then(function ($v) { return array($v); })->end()
|
||||
->beforeNormalization()->ifString()->then(function ($v) { return [$v]; })->end()
|
||||
->prototype('scalar')->end()
|
||||
->end()
|
||||
->end()
|
||||
|
@ -117,9 +117,9 @@ class Configuration implements ConfigurationInterface
|
|||
$rootNode
|
||||
->children()
|
||||
->arrayNode('csrf_protection')
|
||||
->treatFalseLike(array('enabled' => false))
|
||||
->treatTrueLike(array('enabled' => true))
|
||||
->treatNullLike(array('enabled' => true))
|
||||
->treatFalseLike(['enabled' => false])
|
||||
->treatTrueLike(['enabled' => true])
|
||||
->treatNullLike(['enabled' => true])
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
// defaults to framework.session.enabled && !class_exists(FullStack::class) && interface_exists(CsrfTokenManagerInterface::class)
|
||||
|
@ -139,9 +139,9 @@ class Configuration implements ConfigurationInterface
|
|||
->{!class_exists(FullStack::class) && class_exists(Form::class) ? 'canBeDisabled' : 'canBeEnabled'}()
|
||||
->children()
|
||||
->arrayNode('csrf_protection')
|
||||
->treatFalseLike(array('enabled' => false))
|
||||
->treatTrueLike(array('enabled' => true))
|
||||
->treatNullLike(array('enabled' => true))
|
||||
->treatFalseLike(['enabled' => false])
|
||||
->treatTrueLike(['enabled' => true])
|
||||
->treatNullLike(['enabled' => true])
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
->booleanNode('enabled')->defaultNull()->end() // defaults to framework.csrf_protection.enabled
|
||||
|
@ -224,10 +224,10 @@ class Configuration implements ConfigurationInterface
|
|||
unset($workflows['enabled']);
|
||||
|
||||
if (1 === \count($workflows) && isset($workflows[0]['enabled']) && 1 === \count($workflows[0])) {
|
||||
$workflows = array();
|
||||
$workflows = [];
|
||||
}
|
||||
|
||||
if (1 === \count($workflows) && isset($workflows['workflows']) && array_keys($workflows['workflows']) !== range(0, \count($workflows) - 1) && !empty(array_diff(array_keys($workflows['workflows']), array('audit_trail', 'type', 'marking_store', 'supports', 'support_strategy', 'initial_place', 'places', 'transitions')))) {
|
||||
if (1 === \count($workflows) && isset($workflows['workflows']) && array_keys($workflows['workflows']) !== range(0, \count($workflows) - 1) && !empty(array_diff(array_keys($workflows['workflows']), ['audit_trail', 'type', 'marking_store', 'supports', 'support_strategy', 'initial_place', 'places', 'transitions']))) {
|
||||
$workflows = $workflows['workflows'];
|
||||
}
|
||||
|
||||
|
@ -239,10 +239,10 @@ class Configuration implements ConfigurationInterface
|
|||
unset($workflows[$key]['enabled']);
|
||||
}
|
||||
|
||||
$v = array(
|
||||
$v = [
|
||||
'enabled' => true,
|
||||
'workflows' => $workflows,
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
return $v;
|
||||
|
@ -260,19 +260,19 @@ class Configuration implements ConfigurationInterface
|
|||
->canBeEnabled()
|
||||
->end()
|
||||
->enumNode('type')
|
||||
->values(array('workflow', 'state_machine'))
|
||||
->values(['workflow', 'state_machine'])
|
||||
->defaultValue('state_machine')
|
||||
->end()
|
||||
->arrayNode('marking_store')
|
||||
->fixXmlConfig('argument')
|
||||
->children()
|
||||
->enumNode('type')
|
||||
->values(array('multiple_state', 'single_state'))
|
||||
->values(['multiple_state', 'single_state'])
|
||||
->end()
|
||||
->arrayNode('arguments')
|
||||
->beforeNormalization()
|
||||
->ifString()
|
||||
->then(function ($v) { return array($v); })
|
||||
->then(function ($v) { return [$v]; })
|
||||
->end()
|
||||
->requiresAtLeastOneElement()
|
||||
->prototype('scalar')
|
||||
|
@ -294,7 +294,7 @@ class Configuration implements ConfigurationInterface
|
|||
->arrayNode('supports')
|
||||
->beforeNormalization()
|
||||
->ifString()
|
||||
->then(function ($v) { return array($v); })
|
||||
->then(function ($v) { return [$v]; })
|
||||
->end()
|
||||
->prototype('scalar')
|
||||
->cannotBeEmpty()
|
||||
|
@ -317,7 +317,7 @@ class Configuration implements ConfigurationInterface
|
|||
// It's an indexed array of shape ['place1', 'place2']
|
||||
if (isset($places[0]) && \is_string($places[0])) {
|
||||
return array_map(function (string $place) {
|
||||
return array('name' => $place);
|
||||
return ['name' => $place];
|
||||
}, $places);
|
||||
}
|
||||
|
||||
|
@ -347,8 +347,8 @@ class Configuration implements ConfigurationInterface
|
|||
->end()
|
||||
->arrayNode('metadata')
|
||||
->normalizeKeys(false)
|
||||
->defaultValue(array())
|
||||
->example(array('color' => 'blue', 'description' => 'Workflow to manage article.'))
|
||||
->defaultValue([])
|
||||
->example(['color' => 'blue', 'description' => 'Workflow to manage article.'])
|
||||
->prototype('variable')
|
||||
->end()
|
||||
->end()
|
||||
|
@ -391,7 +391,7 @@ class Configuration implements ConfigurationInterface
|
|||
->arrayNode('from')
|
||||
->beforeNormalization()
|
||||
->ifString()
|
||||
->then(function ($v) { return array($v); })
|
||||
->then(function ($v) { return [$v]; })
|
||||
->end()
|
||||
->requiresAtLeastOneElement()
|
||||
->prototype('scalar')
|
||||
|
@ -401,7 +401,7 @@ class Configuration implements ConfigurationInterface
|
|||
->arrayNode('to')
|
||||
->beforeNormalization()
|
||||
->ifString()
|
||||
->then(function ($v) { return array($v); })
|
||||
->then(function ($v) { return [$v]; })
|
||||
->end()
|
||||
->requiresAtLeastOneElement()
|
||||
->prototype('scalar')
|
||||
|
@ -410,8 +410,8 @@ class Configuration implements ConfigurationInterface
|
|||
->end()
|
||||
->arrayNode('metadata')
|
||||
->normalizeKeys(false)
|
||||
->defaultValue(array())
|
||||
->example(array('color' => 'blue', 'description' => 'Workflow to manage article.'))
|
||||
->defaultValue([])
|
||||
->example(['color' => 'blue', 'description' => 'Workflow to manage article.'])
|
||||
->prototype('variable')
|
||||
->end()
|
||||
->end()
|
||||
|
@ -420,8 +420,8 @@ class Configuration implements ConfigurationInterface
|
|||
->end()
|
||||
->arrayNode('metadata')
|
||||
->normalizeKeys(false)
|
||||
->defaultValue(array())
|
||||
->example(array('color' => 'blue', 'description' => 'Workflow to manage article.'))
|
||||
->defaultValue([])
|
||||
->example(['color' => 'blue', 'description' => 'Workflow to manage article.'])
|
||||
->prototype('variable')
|
||||
->end()
|
||||
->end()
|
||||
|
@ -497,9 +497,9 @@ class Configuration implements ConfigurationInterface
|
|||
->scalarNode('cookie_lifetime')->end()
|
||||
->scalarNode('cookie_path')->end()
|
||||
->scalarNode('cookie_domain')->end()
|
||||
->enumNode('cookie_secure')->values(array(true, false, 'auto'))->end()
|
||||
->enumNode('cookie_secure')->values([true, false, 'auto'])->end()
|
||||
->booleanNode('cookie_httponly')->defaultTrue()->end()
|
||||
->enumNode('cookie_samesite')->values(array(null, Cookie::SAMESITE_LAX, Cookie::SAMESITE_STRICT))->defaultNull()->end()
|
||||
->enumNode('cookie_samesite')->values([null, Cookie::SAMESITE_LAX, Cookie::SAMESITE_STRICT])->defaultNull()->end()
|
||||
->booleanNode('use_cookies')->end()
|
||||
->scalarNode('gc_divisor')->end()
|
||||
->scalarNode('gc_probability')->defaultValue(1)->end()
|
||||
|
@ -533,7 +533,7 @@ class Configuration implements ConfigurationInterface
|
|||
->end()
|
||||
->beforeNormalization()
|
||||
->ifTrue(function ($v) { return !\is_array($v); })
|
||||
->then(function ($v) { return array($v); })
|
||||
->then(function ($v) { return [$v]; })
|
||||
->end()
|
||||
->prototype('scalar')->end()
|
||||
->end()
|
||||
|
@ -553,7 +553,7 @@ class Configuration implements ConfigurationInterface
|
|||
->canBeEnabled()
|
||||
->beforeNormalization()
|
||||
->ifTrue(function ($v) { return false === $v || \is_array($v) && false === $v['enabled']; })
|
||||
->then(function () { return array('enabled' => false, 'engines' => false); })
|
||||
->then(function () { return ['enabled' => false, 'engines' => false]; })
|
||||
->end()
|
||||
->children()
|
||||
->scalarNode('hinclude_default_template')->defaultNull()->end()
|
||||
|
@ -568,7 +568,7 @@ class Configuration implements ConfigurationInterface
|
|||
->validate()
|
||||
->ifTrue(function ($v) {return !\in_array('FrameworkBundle:Form', $v); })
|
||||
->then(function ($v) {
|
||||
return array_merge(array('FrameworkBundle:Form'), $v);
|
||||
return array_merge(['FrameworkBundle:Form'], $v);
|
||||
})
|
||||
->end()
|
||||
->end()
|
||||
|
@ -578,13 +578,13 @@ class Configuration implements ConfigurationInterface
|
|||
->fixXmlConfig('engine')
|
||||
->children()
|
||||
->arrayNode('engines')
|
||||
->example(array('twig'))
|
||||
->example(['twig'])
|
||||
->isRequired()
|
||||
->requiresAtLeastOneElement()
|
||||
->canBeUnset()
|
||||
->beforeNormalization()
|
||||
->ifTrue(function ($v) { return !\is_array($v) && false !== $v; })
|
||||
->then(function ($v) { return array($v); })
|
||||
->then(function ($v) { return [$v]; })
|
||||
->end()
|
||||
->prototype('scalar')->end()
|
||||
->end()
|
||||
|
@ -594,7 +594,7 @@ class Configuration implements ConfigurationInterface
|
|||
->arrayNode('loaders')
|
||||
->beforeNormalization()
|
||||
->ifTrue(function ($v) { return !\is_array($v); })
|
||||
->then(function ($v) { return array($v); })
|
||||
->then(function ($v) { return [$v]; })
|
||||
->end()
|
||||
->prototype('scalar')->end()
|
||||
->end()
|
||||
|
@ -622,7 +622,7 @@ class Configuration implements ConfigurationInterface
|
|||
->requiresAtLeastOneElement()
|
||||
->beforeNormalization()
|
||||
->ifTrue(function ($v) { return !\is_array($v); })
|
||||
->then(function ($v) { return array($v); })
|
||||
->then(function ($v) { return [$v]; })
|
||||
->end()
|
||||
->prototype('scalar')->end()
|
||||
->end()
|
||||
|
@ -666,7 +666,7 @@ class Configuration implements ConfigurationInterface
|
|||
->requiresAtLeastOneElement()
|
||||
->beforeNormalization()
|
||||
->ifTrue(function ($v) { return !\is_array($v); })
|
||||
->then(function ($v) { return array($v); })
|
||||
->then(function ($v) { return [$v]; })
|
||||
->end()
|
||||
->prototype('scalar')->end()
|
||||
->end()
|
||||
|
@ -708,9 +708,9 @@ class Configuration implements ConfigurationInterface
|
|||
->fixXmlConfig('path')
|
||||
->children()
|
||||
->arrayNode('fallbacks')
|
||||
->beforeNormalization()->ifString()->then(function ($v) { return array($v); })->end()
|
||||
->beforeNormalization()->ifString()->then(function ($v) { return [$v]; })->end()
|
||||
->prototype('scalar')->end()
|
||||
->defaultValue(array('en'))
|
||||
->defaultValue(['en'])
|
||||
->end()
|
||||
->booleanNode('logging')->defaultValue(false)->end()
|
||||
->scalarNode('formatter')->defaultValue('translator.formatter.default')->end()
|
||||
|
@ -759,9 +759,9 @@ class Configuration implements ConfigurationInterface
|
|||
->scalarNode('cache')->end()
|
||||
->booleanNode('enable_annotations')->{!class_exists(FullStack::class) && class_exists(Annotation::class) ? 'defaultTrue' : 'defaultFalse'}()->end()
|
||||
->arrayNode('static_method')
|
||||
->defaultValue(array('loadValidatorMetadata'))
|
||||
->defaultValue(['loadValidatorMetadata'])
|
||||
->prototype('scalar')->end()
|
||||
->treatFalseLike(array())
|
||||
->treatFalseLike([])
|
||||
->validate()
|
||||
->ifTrue(function ($v) { return !\is_array($v); })
|
||||
->then(function ($v) { return (array) $v; })
|
||||
|
@ -769,7 +769,7 @@ class Configuration implements ConfigurationInterface
|
|||
->end()
|
||||
->scalarNode('translation_domain')->defaultValue('validators')->end()
|
||||
->booleanNode('strict_email')->end()
|
||||
->enumNode('email_validation_mode')->values(array('html5', 'loose', 'strict'))->end()
|
||||
->enumNode('email_validation_mode')->values(['html5', 'loose', 'strict'])->end()
|
||||
->arrayNode('mapping')
|
||||
->addDefaultsIfNotSet()
|
||||
->fixXmlConfig('path')
|
||||
|
@ -946,7 +946,7 @@ class Configuration implements ConfigurationInterface
|
|||
->info('Lock configuration')
|
||||
->{!class_exists(FullStack::class) && class_exists(Lock::class) ? 'canBeDisabled' : 'canBeEnabled'}()
|
||||
->beforeNormalization()
|
||||
->ifString()->then(function ($v) { return array('enabled' => true, 'resources' => $v); })
|
||||
->ifString()->then(function ($v) { return ['enabled' => true, 'resources' => $v]; })
|
||||
->end()
|
||||
->beforeNormalization()
|
||||
->ifTrue(function ($v) { return \is_array($v) && !isset($v['resources']); })
|
||||
|
@ -954,7 +954,7 @@ class Configuration implements ConfigurationInterface
|
|||
$e = $v['enabled'];
|
||||
unset($v['enabled']);
|
||||
|
||||
return array('enabled' => $e, 'resources' => $v);
|
||||
return ['enabled' => $e, 'resources' => $v];
|
||||
})
|
||||
->end()
|
||||
->addDefaultsIfNotSet()
|
||||
|
@ -962,16 +962,16 @@ class Configuration implements ConfigurationInterface
|
|||
->children()
|
||||
->arrayNode('resources')
|
||||
->requiresAtLeastOneElement()
|
||||
->defaultValue(array('default' => array(class_exists(SemaphoreStore::class) && SemaphoreStore::isSupported() ? 'semaphore' : 'flock')))
|
||||
->defaultValue(['default' => [class_exists(SemaphoreStore::class) && SemaphoreStore::isSupported() ? 'semaphore' : 'flock']])
|
||||
->beforeNormalization()
|
||||
->ifString()->then(function ($v) { return array('default' => $v); })
|
||||
->ifString()->then(function ($v) { return ['default' => $v]; })
|
||||
->end()
|
||||
->beforeNormalization()
|
||||
->ifTrue(function ($v) { return \is_array($v) && array_keys($v) === range(0, \count($v) - 1); })
|
||||
->then(function ($v) { return array('default' => $v); })
|
||||
->then(function ($v) { return ['default' => $v]; })
|
||||
->end()
|
||||
->prototype('array')
|
||||
->beforeNormalization()->ifString()->then(function ($v) { return array($v); })->end()
|
||||
->beforeNormalization()->ifString()->then(function ($v) { return [$v]; })->end()
|
||||
->prototype('scalar')->end()
|
||||
->end()
|
||||
->end()
|
||||
|
@ -1009,16 +1009,16 @@ class Configuration implements ConfigurationInterface
|
|||
->always()
|
||||
->then(function ($config) {
|
||||
if (!\is_array($config)) {
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
$newConfig = array();
|
||||
$newConfig = [];
|
||||
foreach ($config as $k => $v) {
|
||||
if (!\is_int($k)) {
|
||||
$newConfig[$k] = array(
|
||||
'senders' => $v['senders'] ?? (\is_array($v) ? array_values($v) : array($v)),
|
||||
$newConfig[$k] = [
|
||||
'senders' => $v['senders'] ?? (\is_array($v) ? array_values($v) : [$v]),
|
||||
'send_and_handle' => $v['send_and_handle'] ?? false,
|
||||
);
|
||||
];
|
||||
} else {
|
||||
$newConfig[$v['message-class']]['senders'] = array_map(
|
||||
function ($a) {
|
||||
|
@ -1049,11 +1049,11 @@ class Configuration implements ConfigurationInterface
|
|||
->always()
|
||||
->then(function ($config) {
|
||||
if (false === $config) {
|
||||
return array('id' => null);
|
||||
return ['id' => null];
|
||||
}
|
||||
|
||||
if (\is_string($config)) {
|
||||
return array('id' => $config);
|
||||
return ['id' => $config];
|
||||
}
|
||||
|
||||
return $config;
|
||||
|
@ -1065,7 +1065,7 @@ class Configuration implements ConfigurationInterface
|
|||
->arrayNode('context')
|
||||
->normalizeKeys(false)
|
||||
->useAttributeAsKey('name')
|
||||
->defaultValue(array())
|
||||
->defaultValue([])
|
||||
->prototype('variable')->end()
|
||||
->end()
|
||||
->end()
|
||||
|
@ -1076,7 +1076,7 @@ class Configuration implements ConfigurationInterface
|
|||
->beforeNormalization()
|
||||
->ifString()
|
||||
->then(function (string $dsn) {
|
||||
return array('dsn' => $dsn);
|
||||
return ['dsn' => $dsn];
|
||||
})
|
||||
->end()
|
||||
->fixXmlConfig('option')
|
||||
|
@ -1084,7 +1084,7 @@ class Configuration implements ConfigurationInterface
|
|||
->scalarNode('dsn')->end()
|
||||
->arrayNode('options')
|
||||
->normalizeKeys(false)
|
||||
->defaultValue(array())
|
||||
->defaultValue([])
|
||||
->prototype('variable')
|
||||
->end()
|
||||
->end()
|
||||
|
@ -1093,27 +1093,27 @@ class Configuration implements ConfigurationInterface
|
|||
->end()
|
||||
->scalarNode('default_bus')->defaultNull()->end()
|
||||
->arrayNode('buses')
|
||||
->defaultValue(array('messenger.bus.default' => array('default_middleware' => true, 'middleware' => array())))
|
||||
->defaultValue(['messenger.bus.default' => ['default_middleware' => true, 'middleware' => []]])
|
||||
->useAttributeAsKey('name')
|
||||
->arrayPrototype()
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
->enumNode('default_middleware')
|
||||
->values(array(true, false, 'allow_no_handlers'))
|
||||
->values([true, false, 'allow_no_handlers'])
|
||||
->defaultTrue()
|
||||
->end()
|
||||
->arrayNode('middleware')
|
||||
->beforeNormalization()
|
||||
->ifTrue(function ($v) { return \is_string($v) || (\is_array($v) && !\is_int(key($v))); })
|
||||
->then(function ($v) { return array($v); })
|
||||
->then(function ($v) { return [$v]; })
|
||||
->end()
|
||||
->defaultValue(array())
|
||||
->defaultValue([])
|
||||
->arrayPrototype()
|
||||
->beforeNormalization()
|
||||
->always()
|
||||
->then(function ($middleware): array {
|
||||
if (!\is_array($middleware)) {
|
||||
return array('id' => $middleware);
|
||||
return ['id' => $middleware];
|
||||
}
|
||||
if (isset($middleware['id'])) {
|
||||
return $middleware;
|
||||
|
@ -1122,10 +1122,10 @@ class Configuration implements ConfigurationInterface
|
|||
throw new \InvalidArgumentException(sprintf('Invalid middleware at path "framework.messenger": a map with a single factory id as key and its arguments as value was expected, %s given.', json_encode($middleware)));
|
||||
}
|
||||
|
||||
return array(
|
||||
return [
|
||||
'id' => key($middleware),
|
||||
'arguments' => current($middleware),
|
||||
);
|
||||
];
|
||||
})
|
||||
->end()
|
||||
->fixXmlConfig('argument')
|
||||
|
@ -1133,7 +1133,7 @@ class Configuration implements ConfigurationInterface
|
|||
->scalarNode('id')->isRequired()->cannotBeEmpty()->end()
|
||||
->arrayNode('arguments')
|
||||
->normalizeKeys(false)
|
||||
->defaultValue(array())
|
||||
->defaultValue([])
|
||||
->prototype('variable')
|
||||
->end()
|
||||
->end()
|
||||
|
|
|
@ -180,7 +180,7 @@ class FrameworkExtension extends Extension
|
|||
|
||||
if (!$container->hasParameter('debug.file_link_format')) {
|
||||
if (!$container->hasParameter('templating.helper.code.file_link_format')) {
|
||||
$links = array(
|
||||
$links = [
|
||||
'textmate' => 'txmt://open?url=file://%%f&line=%%l',
|
||||
'macvim' => 'mvim://open?url=file://%%f&line=%%l',
|
||||
'emacs' => 'emacs://open?url=file://%%f&line=%%l',
|
||||
|
@ -188,7 +188,7 @@ class FrameworkExtension extends Extension
|
|||
'phpstorm' => 'phpstorm://open?file=%%f&line=%%l',
|
||||
'atom' => 'atom://core/open/file?filename=%%f&line=%%l',
|
||||
'vscode' => 'vscode://file/%%f:%%l',
|
||||
);
|
||||
];
|
||||
$ide = $config['ide'];
|
||||
|
||||
$container->setParameter('templating.helper.code.file_link_format', str_replace('%', '%%', ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format')) ?: (isset($links[$ide]) ? $links[$ide] : $ide));
|
||||
|
@ -301,13 +301,13 @@ class FrameworkExtension extends Extension
|
|||
$loader->load('web_link.xml');
|
||||
}
|
||||
|
||||
$this->addAnnotatedClassesToCompile(array(
|
||||
$this->addAnnotatedClassesToCompile([
|
||||
'**\\Controller\\',
|
||||
'**\\Entity\\',
|
||||
|
||||
// Added explicitly so that we don't rely on the class map being dumped to make it work
|
||||
'Symfony\\Bundle\\FrameworkBundle\\Controller\\AbstractController',
|
||||
));
|
||||
]);
|
||||
|
||||
$container->registerForAutoconfiguration(Command::class)
|
||||
->addTag('console.command');
|
||||
|
@ -340,11 +340,11 @@ class FrameworkExtension extends Extension
|
|||
$container->registerForAutoconfiguration(EventSubscriberInterface::class)
|
||||
->addTag('kernel.event_subscriber');
|
||||
$container->registerForAutoconfiguration(ResetInterface::class)
|
||||
->addTag('kernel.reset', array('method' => 'reset'));
|
||||
->addTag('kernel.reset', ['method' => 'reset']);
|
||||
|
||||
if (!interface_exists(MarshallerInterface::class)) {
|
||||
$container->registerForAutoconfiguration(ResettableInterface::class)
|
||||
->addTag('kernel.reset', array('method' => 'reset'));
|
||||
->addTag('kernel.reset', ['method' => 'reset']);
|
||||
}
|
||||
|
||||
$container->registerForAutoconfiguration(PropertyListExtractorInterface::class)
|
||||
|
@ -374,11 +374,11 @@ class FrameworkExtension extends Extension
|
|||
$container->registerForAutoconfiguration(TransportFactoryInterface::class)
|
||||
->addTag('messenger.transport_factory');
|
||||
$container->registerForAutoconfiguration(LoggerAwareInterface::class)
|
||||
->addMethodCall('setLogger', array(new Reference('logger')));
|
||||
->addMethodCall('setLogger', [new Reference('logger')]);
|
||||
|
||||
if (!$container->getParameter('kernel.debug')) {
|
||||
// remove tagged iterator argument for resource checkers
|
||||
$container->getDefinition('config_cache_factory')->setArguments(array());
|
||||
$container->getDefinition('config_cache_factory')->setArguments([]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -450,7 +450,7 @@ class FrameworkExtension extends Extension
|
|||
{
|
||||
if (!$this->isConfigEnabled($container, $config)) {
|
||||
// this is needed for the WebProfiler to work even if the profiler is disabled
|
||||
$container->setParameter('data_collector.templates', array());
|
||||
$container->setParameter('data_collector.templates', []);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -490,7 +490,7 @@ class FrameworkExtension extends Extension
|
|||
|
||||
$container->getDefinition('profiler')
|
||||
->addArgument($config['collect'])
|
||||
->addTag('kernel.reset', array('method' => 'reset'));
|
||||
->addTag('kernel.reset', ['method' => 'reset']);
|
||||
}
|
||||
|
||||
private function registerWorkflowConfiguration(array $config, ContainerBuilder $container, XmlFileLoader $loader)
|
||||
|
@ -514,11 +514,11 @@ class FrameworkExtension extends Extension
|
|||
$workflowId = sprintf('%s.%s', $type, $name);
|
||||
|
||||
// Process Metadata (workflow + places (transition is done in the "create transition" block))
|
||||
$metadataStoreDefinition = new Definition(Workflow\Metadata\InMemoryMetadataStore::class, array(array(), array(), null));
|
||||
$metadataStoreDefinition = new Definition(Workflow\Metadata\InMemoryMetadataStore::class, [[], [], null]);
|
||||
if ($workflow['metadata']) {
|
||||
$metadataStoreDefinition->replaceArgument(0, $workflow['metadata']);
|
||||
}
|
||||
$placesMetadata = array();
|
||||
$placesMetadata = [];
|
||||
foreach ($workflow['places'] as $place) {
|
||||
if ($place['metadata']) {
|
||||
$placesMetadata[$place['name']] = $place['metadata'];
|
||||
|
@ -529,14 +529,14 @@ class FrameworkExtension extends Extension
|
|||
}
|
||||
|
||||
// Create transitions
|
||||
$transitions = array();
|
||||
$guardsConfiguration = array();
|
||||
$transitions = [];
|
||||
$guardsConfiguration = [];
|
||||
$transitionsMetadataDefinition = new Definition(\SplObjectStorage::class);
|
||||
// Global transition counter per workflow
|
||||
$transitionCounter = 0;
|
||||
foreach ($workflow['transitions'] as $transition) {
|
||||
if ('workflow' === $type) {
|
||||
$transitionDefinition = new Definition(Workflow\Transition::class, array($transition['name'], $transition['from'], $transition['to']));
|
||||
$transitionDefinition = new Definition(Workflow\Transition::class, [$transition['name'], $transition['from'], $transition['to']]);
|
||||
$transitionDefinition->setPublic(false);
|
||||
$transitionId = sprintf('%s.transition.%s', $workflowId, $transitionCounter++);
|
||||
$container->setDefinition($transitionId, $transitionDefinition);
|
||||
|
@ -550,15 +550,15 @@ class FrameworkExtension extends Extension
|
|||
$guardsConfiguration[$eventName][] = $configuration;
|
||||
}
|
||||
if ($transition['metadata']) {
|
||||
$transitionsMetadataDefinition->addMethodCall('attach', array(
|
||||
$transitionsMetadataDefinition->addMethodCall('attach', [
|
||||
new Reference($transitionId),
|
||||
$transition['metadata'],
|
||||
));
|
||||
]);
|
||||
}
|
||||
} elseif ('state_machine' === $type) {
|
||||
foreach ($transition['from'] as $from) {
|
||||
foreach ($transition['to'] as $to) {
|
||||
$transitionDefinition = new Definition(Workflow\Transition::class, array($transition['name'], $from, $to));
|
||||
$transitionDefinition = new Definition(Workflow\Transition::class, [$transition['name'], $from, $to]);
|
||||
$transitionDefinition->setPublic(false);
|
||||
$transitionId = sprintf('%s.transition.%s', $workflowId, $transitionCounter++);
|
||||
$container->setDefinition($transitionId, $transitionDefinition);
|
||||
|
@ -572,10 +572,10 @@ class FrameworkExtension extends Extension
|
|||
$guardsConfiguration[$eventName][] = $configuration;
|
||||
}
|
||||
if ($transition['metadata']) {
|
||||
$transitionsMetadataDefinition->addMethodCall('attach', array(
|
||||
$transitionsMetadataDefinition->addMethodCall('attach', [
|
||||
new Reference($transitionId),
|
||||
$transition['metadata'],
|
||||
));
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -593,11 +593,11 @@ class FrameworkExtension extends Extension
|
|||
$definitionDefinition->addArgument($transitions);
|
||||
$definitionDefinition->addArgument($workflow['initial_place'] ?? null);
|
||||
$definitionDefinition->addArgument($metadataStoreDefinition);
|
||||
$definitionDefinition->addTag('workflow.definition', array(
|
||||
$definitionDefinition->addTag('workflow.definition', [
|
||||
'name' => $name,
|
||||
'type' => $type,
|
||||
'marking_store' => isset($workflow['marking_store']['type']) ? $workflow['marking_store']['type'] : null,
|
||||
));
|
||||
]);
|
||||
|
||||
// Create MarkingStore
|
||||
if (isset($workflow['marking_store']['type'])) {
|
||||
|
@ -625,22 +625,22 @@ class FrameworkExtension extends Extension
|
|||
// Add workflow to Registry
|
||||
if ($workflow['supports']) {
|
||||
foreach ($workflow['supports'] as $supportedClassName) {
|
||||
$strategyDefinition = new Definition(Workflow\SupportStrategy\InstanceOfSupportStrategy::class, array($supportedClassName));
|
||||
$strategyDefinition = new Definition(Workflow\SupportStrategy\InstanceOfSupportStrategy::class, [$supportedClassName]);
|
||||
$strategyDefinition->setPublic(false);
|
||||
$registryDefinition->addMethodCall('addWorkflow', array(new Reference($workflowId), $strategyDefinition));
|
||||
$registryDefinition->addMethodCall('addWorkflow', [new Reference($workflowId), $strategyDefinition]);
|
||||
}
|
||||
} elseif (isset($workflow['support_strategy'])) {
|
||||
$registryDefinition->addMethodCall('addWorkflow', array(new Reference($workflowId), new Reference($workflow['support_strategy'])));
|
||||
$registryDefinition->addMethodCall('addWorkflow', [new Reference($workflowId), new Reference($workflow['support_strategy'])]);
|
||||
}
|
||||
|
||||
// Enable the AuditTrail
|
||||
if ($workflow['audit_trail']['enabled']) {
|
||||
$listener = new Definition(Workflow\EventListener\AuditTrailListener::class);
|
||||
$listener->setPrivate(true);
|
||||
$listener->addTag('monolog.logger', array('channel' => 'workflow'));
|
||||
$listener->addTag('kernel.event_listener', array('event' => sprintf('workflow.%s.leave', $name), 'method' => 'onLeave'));
|
||||
$listener->addTag('kernel.event_listener', array('event' => sprintf('workflow.%s.transition', $name), 'method' => 'onTransition'));
|
||||
$listener->addTag('kernel.event_listener', array('event' => sprintf('workflow.%s.enter', $name), 'method' => 'onEnter'));
|
||||
$listener->addTag('monolog.logger', ['channel' => 'workflow']);
|
||||
$listener->addTag('kernel.event_listener', ['event' => sprintf('workflow.%s.leave', $name), 'method' => 'onLeave']);
|
||||
$listener->addTag('kernel.event_listener', ['event' => sprintf('workflow.%s.transition', $name), 'method' => 'onTransition']);
|
||||
$listener->addTag('kernel.event_listener', ['event' => sprintf('workflow.%s.enter', $name), 'method' => 'onEnter']);
|
||||
$listener->addArgument(new Reference('logger'));
|
||||
$container->setDefinition(sprintf('%s.listener.audit_trail', $workflowId), $listener);
|
||||
}
|
||||
|
@ -658,7 +658,7 @@ class FrameworkExtension extends Extension
|
|||
$guard = new Definition(Workflow\EventListener\GuardListener::class);
|
||||
$guard->setPrivate(true);
|
||||
|
||||
$guard->setArguments(array(
|
||||
$guard->setArguments([
|
||||
$guardsConfiguration,
|
||||
new Reference('workflow.security.expression_language'),
|
||||
new Reference('security.token_storage'),
|
||||
|
@ -666,9 +666,9 @@ class FrameworkExtension extends Extension
|
|||
new Reference('security.authentication.trust_resolver'),
|
||||
new Reference('security.role_hierarchy'),
|
||||
new Reference('validator', ContainerInterface::NULL_ON_INVALID_REFERENCE),
|
||||
));
|
||||
]);
|
||||
foreach ($guardsConfiguration as $eventName => $config) {
|
||||
$guard->addTag('kernel.event_listener', array('event' => $eventName, 'method' => 'onTransition'));
|
||||
$guard->addTag('kernel.event_listener', ['event' => $eventName, 'method' => 'onTransition']);
|
||||
}
|
||||
|
||||
$container->setDefinition(sprintf('%s.listener.guard', $workflowId), $guard);
|
||||
|
@ -685,7 +685,7 @@ class FrameworkExtension extends Extension
|
|||
$container->register('debug.stopwatch', Stopwatch::class)
|
||||
->addArgument(true)
|
||||
->setPrivate(true)
|
||||
->addTag('kernel.reset', array('method' => 'reset'));
|
||||
->addTag('kernel.reset', ['method' => 'reset']);
|
||||
$container->setAlias(Stopwatch::class, new Alias('debug.stopwatch', false));
|
||||
}
|
||||
|
||||
|
@ -734,7 +734,7 @@ class FrameworkExtension extends Extension
|
|||
$loader->load('routing.xml');
|
||||
|
||||
if ($config['utf8']) {
|
||||
$container->getDefinition('routing.loader')->replaceArgument(2, array('utf8' => true));
|
||||
$container->getDefinition('routing.loader')->replaceArgument(2, ['utf8' => true]);
|
||||
}
|
||||
|
||||
$container->setParameter('router.resource', $config['resource']);
|
||||
|
@ -753,24 +753,24 @@ class FrameworkExtension extends Extension
|
|||
if ($this->annotationsConfigEnabled) {
|
||||
$container->register('routing.loader.annotation', AnnotatedRouteControllerLoader::class)
|
||||
->setPublic(false)
|
||||
->addTag('routing.loader', array('priority' => -10))
|
||||
->addTag('routing.loader', ['priority' => -10])
|
||||
->addArgument(new Reference('annotation_reader'));
|
||||
|
||||
$container->register('routing.loader.annotation.directory', AnnotationDirectoryLoader::class)
|
||||
->setPublic(false)
|
||||
->addTag('routing.loader', array('priority' => -10))
|
||||
->setArguments(array(
|
||||
->addTag('routing.loader', ['priority' => -10])
|
||||
->setArguments([
|
||||
new Reference('file_locator'),
|
||||
new Reference('routing.loader.annotation'),
|
||||
));
|
||||
]);
|
||||
|
||||
$container->register('routing.loader.annotation.file', AnnotationFileLoader::class)
|
||||
->setPublic(false)
|
||||
->addTag('routing.loader', array('priority' => -10))
|
||||
->setArguments(array(
|
||||
->addTag('routing.loader', ['priority' => -10])
|
||||
->setArguments([
|
||||
new Reference('file_locator'),
|
||||
new Reference('routing.loader.annotation'),
|
||||
));
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -780,8 +780,8 @@ class FrameworkExtension extends Extension
|
|||
|
||||
// session storage
|
||||
$container->setAlias('session.storage', $config['storage_id'])->setPrivate(true);
|
||||
$options = array('cache_limiter' => '0');
|
||||
foreach (array('name', 'cookie_lifetime', 'cookie_path', 'cookie_domain', 'cookie_secure', 'cookie_httponly', 'cookie_samesite', 'use_cookies', 'gc_maxlifetime', 'gc_probability', 'gc_divisor') as $key) {
|
||||
$options = ['cache_limiter' => '0'];
|
||||
foreach (['name', 'cookie_lifetime', 'cookie_path', 'cookie_domain', 'cookie_secure', 'cookie_httponly', 'cookie_samesite', 'use_cookies', 'gc_maxlifetime', 'gc_probability', 'gc_divisor'] as $key) {
|
||||
if (isset($config[$key])) {
|
||||
$options[$key] = $config[$key];
|
||||
}
|
||||
|
@ -789,10 +789,10 @@ class FrameworkExtension extends Extension
|
|||
|
||||
if ('auto' === ($options['cookie_secure'] ?? null)) {
|
||||
$locator = $container->getDefinition('session_listener')->getArgument(0);
|
||||
$locator->setValues($locator->getValues() + array(
|
||||
$locator->setValues($locator->getValues() + [
|
||||
'session_storage' => new Reference('session.storage', ContainerInterface::IGNORE_ON_INVALID_REFERENCE),
|
||||
'request_stack' => new Reference('request_stack'),
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
$container->setParameter('session.storage.options', $options);
|
||||
|
@ -831,11 +831,11 @@ class FrameworkExtension extends Extension
|
|||
$logger = new Reference('logger', ContainerInterface::IGNORE_ON_INVALID_REFERENCE);
|
||||
|
||||
$container->getDefinition('templating.loader.cache')
|
||||
->addTag('monolog.logger', array('channel' => 'templating'))
|
||||
->addMethodCall('setLogger', array($logger));
|
||||
->addTag('monolog.logger', ['channel' => 'templating'])
|
||||
->addMethodCall('setLogger', [$logger]);
|
||||
$container->getDefinition('templating.loader.chain')
|
||||
->addTag('monolog.logger', array('channel' => 'templating'))
|
||||
->addMethodCall('setLogger', array($logger));
|
||||
->addTag('monolog.logger', ['channel' => 'templating'])
|
||||
->addMethodCall('setLogger', [$logger]);
|
||||
}
|
||||
|
||||
if (!empty($config['loaders'])) {
|
||||
|
@ -869,13 +869,13 @@ class FrameworkExtension extends Extension
|
|||
} else {
|
||||
$templateEngineDefinition = $container->getDefinition('templating.engine.delegating');
|
||||
foreach ($engines as $engine) {
|
||||
$templateEngineDefinition->addMethodCall('addEngine', array($engine));
|
||||
$templateEngineDefinition->addMethodCall('addEngine', [$engine]);
|
||||
}
|
||||
$container->setAlias('templating', 'templating.engine.delegating')->setPublic(true);
|
||||
}
|
||||
|
||||
$container->getDefinition('fragment.renderer.hinclude')
|
||||
->addTag('kernel.fragment_renderer', array('alias' => 'hinclude'))
|
||||
->addTag('kernel.fragment_renderer', ['alias' => 'hinclude'])
|
||||
->replaceArgument(0, new Reference('templating'))
|
||||
;
|
||||
|
||||
|
@ -915,7 +915,7 @@ class FrameworkExtension extends Extension
|
|||
$defaultPackage = $this->createPackageDefinition($config['base_path'], $config['base_urls'], $defaultVersion);
|
||||
$container->setDefinition('assets._default_package', $defaultPackage);
|
||||
|
||||
$namedPackages = array();
|
||||
$namedPackages = [];
|
||||
foreach ($config['packages'] as $name => $package) {
|
||||
if (null !== $package['version_strategy']) {
|
||||
$version = new Reference($package['version_strategy']);
|
||||
|
@ -998,13 +998,13 @@ class FrameworkExtension extends Extension
|
|||
$container->setAlias('translator', 'translator.default')->setPublic(true);
|
||||
$container->setAlias('translator.formatter', new Alias($config['formatter'], false));
|
||||
$translator = $container->findDefinition('translator.default');
|
||||
$translator->addMethodCall('setFallbackLocales', array($config['fallbacks']));
|
||||
$translator->addMethodCall('setFallbackLocales', [$config['fallbacks']]);
|
||||
|
||||
$container->setParameter('translator.logging', $config['logging']);
|
||||
$container->setParameter('translator.default_path', $config['default_path']);
|
||||
|
||||
// Discover translation directories
|
||||
$dirs = array();
|
||||
$dirs = [];
|
||||
if (class_exists('Symfony\Component\Validator\Validation')) {
|
||||
$r = new \ReflectionClass('Symfony\Component\Validator\Validation');
|
||||
|
||||
|
@ -1054,7 +1054,7 @@ class FrameworkExtension extends Extension
|
|||
|
||||
// Register translation resources
|
||||
if ($dirs) {
|
||||
$files = array();
|
||||
$files = [];
|
||||
$finder = Finder::create()
|
||||
->followLinks()
|
||||
->files()
|
||||
|
@ -1068,7 +1068,7 @@ class FrameworkExtension extends Extension
|
|||
foreach ($finder as $file) {
|
||||
list(, $locale) = explode('.', $file->getBasename(), 3);
|
||||
if (!isset($files[$locale])) {
|
||||
$files[$locale] = array();
|
||||
$files[$locale] = [];
|
||||
}
|
||||
|
||||
$files[$locale][] = (string) $file;
|
||||
|
@ -1076,7 +1076,7 @@ class FrameworkExtension extends Extension
|
|||
|
||||
$options = array_merge(
|
||||
$translator->getArgument(4),
|
||||
array('resource_files' => $files)
|
||||
['resource_files' => $files]
|
||||
);
|
||||
|
||||
$translator->replaceArgument(4, $options);
|
||||
|
@ -1103,15 +1103,15 @@ class FrameworkExtension extends Extension
|
|||
|
||||
$container->setParameter('validator.translation_domain', $config['translation_domain']);
|
||||
|
||||
$files = array('xml' => array(), 'yml' => array());
|
||||
$files = ['xml' => [], 'yml' => []];
|
||||
$this->registerValidatorMapping($container, $config, $files);
|
||||
|
||||
if (!empty($files['xml'])) {
|
||||
$validatorBuilder->addMethodCall('addXmlMappings', array($files['xml']));
|
||||
$validatorBuilder->addMethodCall('addXmlMappings', [$files['xml']]);
|
||||
}
|
||||
|
||||
if (!empty($files['yml'])) {
|
||||
$validatorBuilder->addMethodCall('addYamlMappings', array($files['yml']));
|
||||
$validatorBuilder->addMethodCall('addYamlMappings', [$files['yml']]);
|
||||
}
|
||||
|
||||
$definition = $container->findDefinition('validator.email');
|
||||
|
@ -1122,17 +1122,17 @@ class FrameworkExtension extends Extension
|
|||
throw new \LogicException('"enable_annotations" on the validator cannot be set as Annotations support is disabled.');
|
||||
}
|
||||
|
||||
$validatorBuilder->addMethodCall('enableAnnotationMapping', array(new Reference('annotation_reader')));
|
||||
$validatorBuilder->addMethodCall('enableAnnotationMapping', [new Reference('annotation_reader')]);
|
||||
}
|
||||
|
||||
if (array_key_exists('static_method', $config) && $config['static_method']) {
|
||||
foreach ($config['static_method'] as $methodName) {
|
||||
$validatorBuilder->addMethodCall('addMethodMapping', array($methodName));
|
||||
$validatorBuilder->addMethodCall('addMethodMapping', [$methodName]);
|
||||
}
|
||||
}
|
||||
|
||||
if (!$container->getParameter('kernel.debug')) {
|
||||
$validatorBuilder->addMethodCall('setMetadataCache', array(new Reference('validator.mapping.cache.symfony')));
|
||||
$validatorBuilder->addMethodCall('setMetadataCache', [new Reference('validator.mapping.cache.symfony')]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1212,7 +1212,7 @@ class FrameworkExtension extends Extension
|
|||
|
||||
if (!method_exists(AnnotationRegistry::class, 'registerUniqueLoader')) {
|
||||
$container->getDefinition('annotations.dummy_registry')
|
||||
->setMethodCalls(array(array('registerLoader', array('class_exists'))));
|
||||
->setMethodCalls([['registerLoader', ['class_exists']]]);
|
||||
}
|
||||
|
||||
if ('none' !== $config['cache']) {
|
||||
|
@ -1323,7 +1323,7 @@ class FrameworkExtension extends Extension
|
|||
$container->removeDefinition('serializer.encoder.yaml');
|
||||
}
|
||||
|
||||
$serializerLoaders = array();
|
||||
$serializerLoaders = [];
|
||||
if (isset($config['enable_annotations']) && $config['enable_annotations']) {
|
||||
if (!$this->annotationsConfigEnabled) {
|
||||
throw new \LogicException('"enable_annotations" on the serializer cannot be set as Annotations support is disabled.');
|
||||
|
@ -1331,7 +1331,7 @@ class FrameworkExtension extends Extension
|
|||
|
||||
$annotationLoader = new Definition(
|
||||
'Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader',
|
||||
array(new Reference('annotation_reader'))
|
||||
[new Reference('annotation_reader')]
|
||||
);
|
||||
$annotationLoader->setPublic(false);
|
||||
|
||||
|
@ -1339,7 +1339,7 @@ class FrameworkExtension extends Extension
|
|||
}
|
||||
|
||||
$fileRecorder = function ($extension, $path) use (&$serializerLoaders) {
|
||||
$definition = new Definition(\in_array($extension, array('yaml', 'yml')) ? 'Symfony\Component\Serializer\Mapping\Loader\YamlFileLoader' : 'Symfony\Component\Serializer\Mapping\Loader\XmlFileLoader', array($path));
|
||||
$definition = new Definition(\in_array($extension, ['yaml', 'yml']) ? 'Symfony\Component\Serializer\Mapping\Loader\YamlFileLoader' : 'Symfony\Component\Serializer\Mapping\Loader\XmlFileLoader', [$path]);
|
||||
$definition->setPublic(false);
|
||||
$serializerLoaders[] = $definition;
|
||||
};
|
||||
|
@ -1376,10 +1376,10 @@ class FrameworkExtension extends Extension
|
|||
if (!$container->getParameter('kernel.debug')) {
|
||||
$cacheMetadataFactory = new Definition(
|
||||
CacheClassMetadataFactory::class,
|
||||
array(
|
||||
[
|
||||
new Reference('serializer.mapping.cache_class_metadata_factory.inner'),
|
||||
new Reference('serializer.mapping.cache.symfony'),
|
||||
)
|
||||
]
|
||||
);
|
||||
$cacheMetadataFactory->setPublic(false);
|
||||
$cacheMetadataFactory->setDecoratedService('serializer.mapping.class_metadata_factory');
|
||||
|
@ -1392,11 +1392,11 @@ class FrameworkExtension extends Extension
|
|||
}
|
||||
|
||||
if (isset($config['circular_reference_handler']) && $config['circular_reference_handler']) {
|
||||
$container->getDefinition('serializer.normalizer.object')->addMethodCall('setCircularReferenceHandler', array(new Reference($config['circular_reference_handler'])));
|
||||
$container->getDefinition('serializer.normalizer.object')->addMethodCall('setCircularReferenceHandler', [new Reference($config['circular_reference_handler'])]);
|
||||
}
|
||||
|
||||
if ($config['max_depth_handler'] ?? false) {
|
||||
$container->getDefinition('serializer.normalizer.object')->addMethodCall('setMaxDepthHandler', array(new Reference($config['max_depth_handler'])));
|
||||
$container->getDefinition('serializer.normalizer.object')->addMethodCall('setMaxDepthHandler', [new Reference($config['max_depth_handler'])]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1411,8 +1411,8 @@ class FrameworkExtension extends Extension
|
|||
if (interface_exists('phpDocumentor\Reflection\DocBlockFactoryInterface')) {
|
||||
$definition = $container->register('property_info.php_doc_extractor', 'Symfony\Component\PropertyInfo\Extractor\PhpDocExtractor');
|
||||
$definition->setPrivate(true);
|
||||
$definition->addTag('property_info.description_extractor', array('priority' => -1000));
|
||||
$definition->addTag('property_info.type_extractor', array('priority' => -1001));
|
||||
$definition->addTag('property_info.description_extractor', ['priority' => -1000]);
|
||||
$definition->addTag('property_info.type_extractor', ['priority' => -1001]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1426,7 +1426,7 @@ class FrameworkExtension extends Extension
|
|||
}
|
||||
|
||||
// Generate stores
|
||||
$storeDefinitions = array();
|
||||
$storeDefinitions = [];
|
||||
foreach ($resourceStores as $storeDsn) {
|
||||
$storeDsn = $container->resolveEnvPlaceholders($storeDsn, null, $usedEnvs);
|
||||
switch (true) {
|
||||
|
@ -1448,15 +1448,15 @@ class FrameworkExtension extends Extension
|
|||
if (!$container->hasDefinition($connectionDefinitionId = '.lock_connection.'.$container->hash($storeDsn))) {
|
||||
$connectionDefinition = new Definition(\stdClass::class);
|
||||
$connectionDefinition->setPublic(false);
|
||||
$connectionDefinition->setFactory(array(AbstractAdapter::class, 'createConnection'));
|
||||
$connectionDefinition->setArguments(array($storeDsn, array('lazy' => true)));
|
||||
$connectionDefinition->setFactory([AbstractAdapter::class, 'createConnection']);
|
||||
$connectionDefinition->setArguments([$storeDsn, ['lazy' => true]]);
|
||||
$container->setDefinition($connectionDefinitionId, $connectionDefinition);
|
||||
}
|
||||
|
||||
$storeDefinition = new Definition(StoreInterface::class);
|
||||
$storeDefinition->setPublic(false);
|
||||
$storeDefinition->setFactory(array(StoreFactory::class, 'createStore'));
|
||||
$storeDefinition->setArguments(array(new Reference($connectionDefinitionId)));
|
||||
$storeDefinition->setFactory([StoreFactory::class, 'createStore']);
|
||||
$storeDefinition->setArguments([new Reference($connectionDefinitionId)]);
|
||||
|
||||
$container->setDefinition($storeDefinitionId = '.lock.'.$resourceName.'.store.'.$container->hash($storeDsn), $storeDefinition);
|
||||
|
||||
|
@ -1486,8 +1486,8 @@ class FrameworkExtension extends Extension
|
|||
// Generate services for lock instances
|
||||
$lockDefinition = new Definition(Lock::class);
|
||||
$lockDefinition->setPublic(false);
|
||||
$lockDefinition->setFactory(array(new Reference('lock.'.$resourceName.'.factory'), 'createLock'));
|
||||
$lockDefinition->setArguments(array($resourceName));
|
||||
$lockDefinition->setFactory([new Reference('lock.'.$resourceName.'.factory'), 'createLock']);
|
||||
$lockDefinition->setArguments([$resourceName]);
|
||||
$container->setDefinition('lock.'.$resourceName, $lockDefinition);
|
||||
|
||||
// provide alias for default resource
|
||||
|
@ -1539,16 +1539,16 @@ class FrameworkExtension extends Extension
|
|||
$config['default_bus'] = key($config['buses']);
|
||||
}
|
||||
|
||||
$defaultMiddleware = array(
|
||||
'before' => array(array('id' => 'logging')),
|
||||
'after' => array(array('id' => 'send_message'), array('id' => 'handle_message')),
|
||||
);
|
||||
$defaultMiddleware = [
|
||||
'before' => [['id' => 'logging']],
|
||||
'after' => [['id' => 'send_message'], ['id' => 'handle_message']],
|
||||
];
|
||||
foreach ($config['buses'] as $busId => $bus) {
|
||||
$middleware = $bus['middleware'];
|
||||
|
||||
if ($bus['default_middleware']) {
|
||||
if ('allow_no_handlers' === $bus['default_middleware']) {
|
||||
$defaultMiddleware['after'][1]['arguments'] = array(true);
|
||||
$defaultMiddleware['after'][1]['arguments'] = [true];
|
||||
} else {
|
||||
unset($defaultMiddleware['after'][1]['arguments']);
|
||||
}
|
||||
|
@ -1556,17 +1556,17 @@ class FrameworkExtension extends Extension
|
|||
}
|
||||
|
||||
foreach ($middleware as $middlewareItem) {
|
||||
if (!$validationConfig['enabled'] && \in_array($middlewareItem['id'], array('validation', 'messenger.middleware.validation'), true)) {
|
||||
if (!$validationConfig['enabled'] && \in_array($middlewareItem['id'], ['validation', 'messenger.middleware.validation'], true)) {
|
||||
throw new LogicException('The Validation middleware is only available when the Validator component is installed and enabled. Try running "composer require symfony/validator".');
|
||||
}
|
||||
}
|
||||
|
||||
if ($container->getParameter('kernel.debug') && class_exists(Stopwatch::class)) {
|
||||
array_unshift($middleware, array('id' => 'traceable', 'arguments' => array($busId)));
|
||||
array_unshift($middleware, ['id' => 'traceable', 'arguments' => [$busId]]);
|
||||
}
|
||||
|
||||
$container->setParameter($busId.'.middleware', $middleware);
|
||||
$container->register($busId, MessageBus::class)->addArgument(array())->addTag('messenger.bus');
|
||||
$container->register($busId, MessageBus::class)->addArgument([])->addTag('messenger.bus');
|
||||
|
||||
if ($busId === $config['default_bus']) {
|
||||
$container->setAlias('message_bus', $busId)->setPublic(true);
|
||||
|
@ -1576,28 +1576,28 @@ class FrameworkExtension extends Extension
|
|||
}
|
||||
}
|
||||
|
||||
$senderAliases = array();
|
||||
$senderAliases = [];
|
||||
foreach ($config['transports'] as $name => $transport) {
|
||||
if (0 === strpos($transport['dsn'], 'amqp://') && !$container->hasDefinition('messenger.transport.amqp.factory')) {
|
||||
throw new LogicException('The default AMQP transport is not available. Make sure you have installed and enabled the Serializer component. Try enabling it or running "composer require symfony/serializer-pack".');
|
||||
}
|
||||
|
||||
$transportDefinition = (new Definition(TransportInterface::class))
|
||||
->setFactory(array(new Reference('messenger.transport_factory'), 'createTransport'))
|
||||
->setArguments(array($transport['dsn'], $transport['options']))
|
||||
->addTag('messenger.receiver', array('alias' => $name))
|
||||
->setFactory([new Reference('messenger.transport_factory'), 'createTransport'])
|
||||
->setArguments([$transport['dsn'], $transport['options']])
|
||||
->addTag('messenger.receiver', ['alias' => $name])
|
||||
;
|
||||
$container->setDefinition($transportId = 'messenger.transport.'.$name, $transportDefinition);
|
||||
$senderAliases[$name] = $transportId;
|
||||
}
|
||||
|
||||
$messageToSendersMapping = array();
|
||||
$messagesToSendAndHandle = array();
|
||||
$messageToSendersMapping = [];
|
||||
$messagesToSendAndHandle = [];
|
||||
foreach ($config['routing'] as $message => $messageConfiguration) {
|
||||
if ('*' !== $message && !class_exists($message) && !interface_exists($message, false)) {
|
||||
throw new LogicException(sprintf('Invalid Messenger routing configuration: class or interface "%s" not found.', $message));
|
||||
}
|
||||
$senders = array();
|
||||
$senders = [];
|
||||
foreach ($messageConfiguration['senders'] as $sender) {
|
||||
$senders[$sender] = new Reference($senderAliases[$sender] ?? $sender);
|
||||
}
|
||||
|
@ -1630,24 +1630,24 @@ class FrameworkExtension extends Extension
|
|||
// Inline any env vars referenced in the parameter
|
||||
$container->setParameter('cache.prefix.seed', $container->resolveEnvPlaceholders($container->getParameter('cache.prefix.seed'), true));
|
||||
}
|
||||
foreach (array('doctrine', 'psr6', 'redis', 'memcached', 'pdo') as $name) {
|
||||
foreach (['doctrine', 'psr6', 'redis', 'memcached', 'pdo'] as $name) {
|
||||
if (isset($config[$name = 'default_'.$name.'_provider'])) {
|
||||
$container->setAlias('cache.'.$name, new Alias(CachePoolPass::getServiceProvider($container, $config[$name]), false));
|
||||
}
|
||||
}
|
||||
foreach (array('app', 'system') as $name) {
|
||||
$config['pools']['cache.'.$name] = array(
|
||||
foreach (['app', 'system'] as $name) {
|
||||
$config['pools']['cache.'.$name] = [
|
||||
'adapter' => $config[$name],
|
||||
'public' => true,
|
||||
'tags' => false,
|
||||
);
|
||||
];
|
||||
}
|
||||
foreach ($config['pools'] as $name => $pool) {
|
||||
if ($config['pools'][$pool['adapter']]['tags'] ?? false) {
|
||||
$pool['adapter'] = '.'.$pool['adapter'].'.inner';
|
||||
}
|
||||
$definition = new ChildDefinition($pool['adapter']);
|
||||
if (!\in_array($name, array('cache.app', 'cache.system'), true)) {
|
||||
if (!\in_array($name, ['cache.app', 'cache.system'], true)) {
|
||||
$container->registerAliasForArgument($name, CacheInterface::class);
|
||||
$container->registerAliasForArgument($name, CacheItemPoolInterface::class);
|
||||
}
|
||||
|
@ -1678,13 +1678,13 @@ class FrameworkExtension extends Extension
|
|||
$propertyAccessDefinition->setPublic(false);
|
||||
|
||||
if (!$container->getParameter('kernel.debug')) {
|
||||
$propertyAccessDefinition->setFactory(array(PropertyAccessor::class, 'createCache'));
|
||||
$propertyAccessDefinition->setArguments(array(null, null, $version, new Reference('logger', ContainerInterface::IGNORE_ON_INVALID_REFERENCE)));
|
||||
$propertyAccessDefinition->addTag('cache.pool', array('clearer' => 'cache.system_clearer'));
|
||||
$propertyAccessDefinition->addTag('monolog.logger', array('channel' => 'cache'));
|
||||
$propertyAccessDefinition->setFactory([PropertyAccessor::class, 'createCache']);
|
||||
$propertyAccessDefinition->setArguments([null, null, $version, new Reference('logger', ContainerInterface::IGNORE_ON_INVALID_REFERENCE)]);
|
||||
$propertyAccessDefinition->addTag('cache.pool', ['clearer' => 'cache.system_clearer']);
|
||||
$propertyAccessDefinition->addTag('monolog.logger', ['channel' => 'cache']);
|
||||
} else {
|
||||
$propertyAccessDefinition->setClass(ArrayAdapter::class);
|
||||
$propertyAccessDefinition->setArguments(array(0, false));
|
||||
$propertyAccessDefinition->setArguments([0, false]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ class DelegatingLoader extends BaseDelegatingLoader
|
|||
* @param ControllerNameParser $parser A ControllerNameParser instance
|
||||
* @param LoaderResolverInterface $resolver A LoaderResolverInterface instance
|
||||
*/
|
||||
public function __construct(ControllerNameParser $parser, LoaderResolverInterface $resolver, array $defaultOptions = array())
|
||||
public function __construct(ControllerNameParser $parser, LoaderResolverInterface $resolver, array $defaultOptions = [])
|
||||
{
|
||||
$this->parser = $parser;
|
||||
$this->defaultOptions = $defaultOptions;
|
||||
|
|
|
@ -33,7 +33,7 @@ class StopwatchHelper extends Helper
|
|||
return 'stopwatch';
|
||||
}
|
||||
|
||||
public function __call($method, $arguments = array())
|
||||
public function __call($method, $arguments = [])
|
||||
{
|
||||
if (null !== $this->stopwatch) {
|
||||
if (method_exists($this->stopwatch, $method)) {
|
||||
|
|
|
@ -61,10 +61,10 @@ class TranslatorHelper extends Helper
|
|||
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.2, use the trans() one instead with a "%count%" parameter.', __METHOD__), E_USER_DEPRECATED);
|
||||
|
||||
if (null === $this->translator) {
|
||||
return $this->doTrans($id, array('%count%' => $number) + $parameters, $domain, $locale);
|
||||
return $this->doTrans($id, ['%count%' => $number] + $parameters, $domain, $locale);
|
||||
}
|
||||
if ($this->translator instanceof TranslatorInterface) {
|
||||
return $this->translator->trans($id, array('%count%' => $number) + $parameters, $domain, $locale);
|
||||
return $this->translator->trans($id, ['%count%' => $number] + $parameters, $domain, $locale);
|
||||
}
|
||||
|
||||
return $this->translator->transChoice($id, $number, $parameters, $domain, $locale);
|
||||
|
|
|
@ -27,10 +27,10 @@ class SerializerCacheWarmerTest extends TestCase
|
|||
$this->markTestSkipped('The Serializer default cache warmer has been introduced in the Serializer Component version 3.2.');
|
||||
}
|
||||
|
||||
$loaders = array(
|
||||
$loaders = [
|
||||
new XmlFileLoader(__DIR__.'/../Fixtures/Serialization/Resources/person.xml'),
|
||||
new YamlFileLoader(__DIR__.'/../Fixtures/Serialization/Resources/author.yml'),
|
||||
);
|
||||
];
|
||||
|
||||
$file = sys_get_temp_dir().'/cache-serializer.php';
|
||||
@unlink($file);
|
||||
|
@ -55,7 +55,7 @@ class SerializerCacheWarmerTest extends TestCase
|
|||
$file = sys_get_temp_dir().'/cache-serializer-without-loader.php';
|
||||
@unlink($file);
|
||||
|
||||
$warmer = new SerializerCacheWarmer(array(), $file);
|
||||
$warmer = new SerializerCacheWarmer([], $file);
|
||||
$warmer->warmUp(\dirname($file));
|
||||
|
||||
$this->assertFileExists($file);
|
||||
|
|
|
@ -26,24 +26,24 @@ class TranslationDebugCommandTest extends TestCase
|
|||
|
||||
public function testDebugMissingMessages()
|
||||
{
|
||||
$tester = $this->createCommandTester(array('foo' => 'foo'));
|
||||
$tester->execute(array('locale' => 'en', 'bundle' => 'foo'));
|
||||
$tester = $this->createCommandTester(['foo' => 'foo']);
|
||||
$tester->execute(['locale' => 'en', 'bundle' => 'foo']);
|
||||
|
||||
$this->assertRegExp('/missing/', $tester->getDisplay());
|
||||
}
|
||||
|
||||
public function testDebugUnusedMessages()
|
||||
{
|
||||
$tester = $this->createCommandTester(array(), array('foo' => 'foo'));
|
||||
$tester->execute(array('locale' => 'en', 'bundle' => 'foo'));
|
||||
$tester = $this->createCommandTester([], ['foo' => 'foo']);
|
||||
$tester->execute(['locale' => 'en', 'bundle' => 'foo']);
|
||||
|
||||
$this->assertRegExp('/unused/', $tester->getDisplay());
|
||||
}
|
||||
|
||||
public function testDebugFallbackMessages()
|
||||
{
|
||||
$tester = $this->createCommandTester(array(), array('foo' => 'foo'));
|
||||
$tester->execute(array('locale' => 'fr', 'bundle' => 'foo'));
|
||||
$tester = $this->createCommandTester([], ['foo' => 'foo']);
|
||||
$tester->execute(['locale' => 'fr', 'bundle' => 'foo']);
|
||||
|
||||
$this->assertRegExp('/fallback/', $tester->getDisplay());
|
||||
}
|
||||
|
@ -51,15 +51,15 @@ class TranslationDebugCommandTest extends TestCase
|
|||
public function testNoDefinedMessages()
|
||||
{
|
||||
$tester = $this->createCommandTester();
|
||||
$tester->execute(array('locale' => 'fr', 'bundle' => 'test'));
|
||||
$tester->execute(['locale' => 'fr', 'bundle' => 'test']);
|
||||
|
||||
$this->assertRegExp('/No defined or extracted messages for locale "fr"/', $tester->getDisplay());
|
||||
}
|
||||
|
||||
public function testDebugDefaultDirectory()
|
||||
{
|
||||
$tester = $this->createCommandTester(array('foo' => 'foo'), array('bar' => 'bar'));
|
||||
$tester->execute(array('locale' => 'en'));
|
||||
$tester = $this->createCommandTester(['foo' => 'foo'], ['bar' => 'bar']);
|
||||
$tester->execute(['locale' => 'en']);
|
||||
|
||||
$this->assertRegExp('/missing/', $tester->getDisplay());
|
||||
$this->assertRegExp('/unused/', $tester->getDisplay());
|
||||
|
@ -75,8 +75,8 @@ class TranslationDebugCommandTest extends TestCase
|
|||
$this->fs->mkdir($this->translationDir.'/Resources/translations');
|
||||
$this->fs->mkdir($this->translationDir.'/Resources/views');
|
||||
|
||||
$tester = $this->createCommandTester(array('foo' => 'foo'), array('bar' => 'bar'));
|
||||
$tester->execute(array('locale' => 'en'));
|
||||
$tester = $this->createCommandTester(['foo' => 'foo'], ['bar' => 'bar']);
|
||||
$tester->execute(['locale' => 'en']);
|
||||
|
||||
$this->assertRegExp('/missing/', $tester->getDisplay());
|
||||
$this->assertRegExp('/unused/', $tester->getDisplay());
|
||||
|
@ -90,8 +90,8 @@ class TranslationDebugCommandTest extends TestCase
|
|||
$this->fs->mkdir($this->translationDir.'/translations');
|
||||
$this->fs->mkdir($this->translationDir.'/templates');
|
||||
|
||||
$tester = $this->createCommandTester(array('foo' => 'foo'), array('bar' => 'bar'));
|
||||
$tester->execute(array('locale' => 'en'));
|
||||
$tester = $this->createCommandTester(['foo' => 'foo'], ['bar' => 'bar']);
|
||||
$tester->execute(['locale' => 'en']);
|
||||
|
||||
$this->assertRegExp('/missing/', $tester->getDisplay());
|
||||
$this->assertRegExp('/unused/', $tester->getDisplay());
|
||||
|
@ -107,8 +107,8 @@ class TranslationDebugCommandTest extends TestCase
|
|||
->with($this->equalTo($this->translationDir.'/customDir'))
|
||||
->willThrowException(new \InvalidArgumentException());
|
||||
|
||||
$tester = $this->createCommandTester(array('foo' => 'foo'), array('bar' => 'bar'), $kernel);
|
||||
$tester->execute(array('locale' => 'en', 'bundle' => $this->translationDir.'/customDir'));
|
||||
$tester = $this->createCommandTester(['foo' => 'foo'], ['bar' => 'bar'], $kernel);
|
||||
$tester->execute(['locale' => 'en', 'bundle' => $this->translationDir.'/customDir']);
|
||||
|
||||
$this->assertRegExp('/missing/', $tester->getDisplay());
|
||||
$this->assertRegExp('/unused/', $tester->getDisplay());
|
||||
|
@ -125,8 +125,8 @@ class TranslationDebugCommandTest extends TestCase
|
|||
->with($this->equalTo('dir'))
|
||||
->willThrowException(new \InvalidArgumentException());
|
||||
|
||||
$tester = $this->createCommandTester(array(), array(), $kernel);
|
||||
$tester->execute(array('locale' => 'en', 'bundle' => 'dir'));
|
||||
$tester = $this->createCommandTester([], [], $kernel);
|
||||
$tester->execute(['locale' => 'en', 'bundle' => 'dir']);
|
||||
}
|
||||
|
||||
protected function setUp()
|
||||
|
@ -145,7 +145,7 @@ class TranslationDebugCommandTest extends TestCase
|
|||
/**
|
||||
* @return CommandTester
|
||||
*/
|
||||
private function createCommandTester($extractedMessages = array(), $loadedMessages = array(), $kernel = null)
|
||||
private function createCommandTester($extractedMessages = [], $loadedMessages = [], $kernel = null)
|
||||
{
|
||||
$translator = $this->getMockBuilder('Symfony\Component\Translation\Translator')
|
||||
->disableOriginalConstructor()
|
||||
|
@ -154,7 +154,7 @@ class TranslationDebugCommandTest extends TestCase
|
|||
$translator
|
||||
->expects($this->any())
|
||||
->method('getFallbackLocales')
|
||||
->will($this->returnValue(array('en')));
|
||||
->will($this->returnValue(['en']));
|
||||
|
||||
$extractor = $this->getMockBuilder('Symfony\Component\Translation\Extractor\ExtractorInterface')->getMock();
|
||||
$extractor
|
||||
|
@ -177,15 +177,15 @@ class TranslationDebugCommandTest extends TestCase
|
|||
);
|
||||
|
||||
if (null === $kernel) {
|
||||
$returnValues = array(
|
||||
array('foo', $this->getBundle($this->translationDir)),
|
||||
array('test', $this->getBundle('test')),
|
||||
);
|
||||
$returnValues = [
|
||||
['foo', $this->getBundle($this->translationDir)],
|
||||
['test', $this->getBundle('test')],
|
||||
];
|
||||
if (HttpKernel\Kernel::VERSION_ID < 40000) {
|
||||
$returnValues = array(
|
||||
array('foo', true, $this->getBundle($this->translationDir)),
|
||||
array('test', true, $this->getBundle('test')),
|
||||
);
|
||||
$returnValues = [
|
||||
['foo', true, $this->getBundle($this->translationDir)],
|
||||
['test', true, $this->getBundle('test')],
|
||||
];
|
||||
}
|
||||
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock();
|
||||
$kernel
|
||||
|
@ -197,7 +197,7 @@ class TranslationDebugCommandTest extends TestCase
|
|||
$kernel
|
||||
->expects($this->any())
|
||||
->method('getBundles')
|
||||
->will($this->returnValue(array()));
|
||||
->will($this->returnValue([]));
|
||||
|
||||
$container = new Container();
|
||||
$container->setParameter('kernel.root_dir', $this->translationDir);
|
||||
|
|
|
@ -93,8 +93,8 @@ class TranslationUpdateCommandTest extends TestCase
|
|||
$this->fs->mkdir($this->translationDir.'/Resources/translations');
|
||||
$this->fs->mkdir($this->translationDir.'/Resources/views');
|
||||
|
||||
$tester = $this->createCommandTester(array('messages' => array('foo' => 'foo')));
|
||||
$tester->execute(array('command' => 'translation:update', 'locale' => 'en', '--force' => true));
|
||||
$tester = $this->createCommandTester(['messages' => ['foo' => 'foo']]);
|
||||
$tester->execute(['command' => 'translation:update', 'locale' => 'en', '--force' => true]);
|
||||
$this->assertRegExp('/Translation files were successfully updated./', $tester->getDisplay());
|
||||
}
|
||||
|
||||
|
|
|
@ -203,12 +203,12 @@ abstract class AbstractDescriptorTest extends TestCase
|
|||
|
||||
public function getClassDescriptionTestData()
|
||||
{
|
||||
return array(
|
||||
array(ClassWithDocCommentOnMultipleLines::class, 'This is the first line of the description. This is the second line.'),
|
||||
array(ClassWithDocCommentWithoutInitialSpace::class, 'Foo.'),
|
||||
array(ClassWithoutDocComment::class, ''),
|
||||
array(ClassWithDocComment::class, 'This is a class with a doc comment.'),
|
||||
);
|
||||
return [
|
||||
[ClassWithDocCommentOnMultipleLines::class, 'This is the first line of the description. This is the second line.'],
|
||||
[ClassWithDocCommentWithoutInitialSpace::class, 'Foo.'],
|
||||
[ClassWithoutDocComment::class, ''],
|
||||
[ClassWithDocComment::class, 'This is a class with a doc comment.'],
|
||||
];
|
||||
}
|
||||
|
||||
abstract protected function getDescriptor();
|
||||
|
|
|
@ -98,10 +98,10 @@ class ObjectsProvider
|
|||
|
||||
public static function getContainerDefinitionsWithExistingClasses()
|
||||
{
|
||||
return array(
|
||||
return [
|
||||
'existing_class_def_1' => new Definition(ClassWithDocComment::class),
|
||||
'existing_class_def_2' => new Definition(ClassWithoutDocComment::class),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
public static function getContainerDefinitions()
|
||||
|
|
|
@ -37,18 +37,18 @@ class CachePoolClearerPassTest extends TestCase
|
|||
|
||||
$publicPool = new Definition();
|
||||
$publicPool->addArgument('namespace');
|
||||
$publicPool->addTag('cache.pool', array('clearer' => 'clearer_alias'));
|
||||
$publicPool->addTag('cache.pool', ['clearer' => 'clearer_alias']);
|
||||
$container->setDefinition('public.pool', $publicPool);
|
||||
|
||||
$publicPool = new Definition();
|
||||
$publicPool->addArgument('namespace');
|
||||
$publicPool->addTag('cache.pool', array('clearer' => 'clearer_alias', 'name' => 'pool2'));
|
||||
$publicPool->addTag('cache.pool', ['clearer' => 'clearer_alias', 'name' => 'pool2']);
|
||||
$container->setDefinition('public.pool2', $publicPool);
|
||||
|
||||
$privatePool = new Definition();
|
||||
$privatePool->setPublic(false);
|
||||
$privatePool->addArgument('namespace');
|
||||
$privatePool->addTag('cache.pool', array('clearer' => 'clearer_alias'));
|
||||
$privatePool->addTag('cache.pool', ['clearer' => 'clearer_alias']);
|
||||
$container->setDefinition('private.pool', $privatePool);
|
||||
|
||||
$clearer = new Definition();
|
||||
|
@ -58,18 +58,18 @@ class CachePoolClearerPassTest extends TestCase
|
|||
$pass = new RemoveUnusedDefinitionsPass();
|
||||
foreach ($container->getCompiler()->getPassConfig()->getRemovingPasses() as $removingPass) {
|
||||
if ($removingPass instanceof RepeatedPass) {
|
||||
$pass->setRepeatedPass(new RepeatedPass(array($pass)));
|
||||
$pass->setRepeatedPass(new RepeatedPass([$pass]));
|
||||
break;
|
||||
}
|
||||
}
|
||||
foreach (array(new CachePoolPass(), $pass, new CachePoolClearerPass()) as $pass) {
|
||||
foreach ([new CachePoolPass(), $pass, new CachePoolClearerPass()] as $pass) {
|
||||
$pass->process($container);
|
||||
}
|
||||
|
||||
$expected = array(array(
|
||||
$expected = [[
|
||||
'public.pool' => new Reference('public.pool'),
|
||||
'pool2' => new Reference('public.pool2'),
|
||||
));
|
||||
]];
|
||||
$this->assertEquals($expected, $clearer->getArguments());
|
||||
$this->assertEquals($expected, $globalClearer->getArguments());
|
||||
}
|
||||
|
|
|
@ -97,10 +97,10 @@ class CachePoolPassTest extends TestCase
|
|||
$container->setParameter('kernel.container_class', 'app');
|
||||
$container->setParameter('cache.prefix.seed', 'foo');
|
||||
$cachePool = new Definition();
|
||||
$cachePool->addTag('cache.pool', array(
|
||||
$cachePool->addTag('cache.pool', [
|
||||
'name' => 'foobar',
|
||||
'provider' => 'foobar',
|
||||
));
|
||||
]);
|
||||
$cachePool->addArgument(null);
|
||||
$cachePool->addArgument(null);
|
||||
$cachePool->addArgument(null);
|
||||
|
|
|
@ -33,11 +33,11 @@ class DataCollectorTranslatorPassTest extends TestCase
|
|||
$this->container->register('translator.data_collector', 'Symfony\Component\Translation\DataCollectorTranslator')
|
||||
->setPublic(false)
|
||||
->setDecoratedService('translator')
|
||||
->setArguments(array(new Reference('translator.data_collector.inner')))
|
||||
->setArguments([new Reference('translator.data_collector.inner')])
|
||||
;
|
||||
|
||||
$this->container->register('data_collector.translation', 'Symfony\Component\Translation\DataCollector\TranslationDataCollector')
|
||||
->setArguments(array(new Reference('translator.data_collector')))
|
||||
->setArguments([new Reference('translator.data_collector')])
|
||||
;
|
||||
}
|
||||
|
||||
|
@ -67,10 +67,10 @@ class DataCollectorTranslatorPassTest extends TestCase
|
|||
|
||||
public function getImplementingTranslatorBagInterfaceTranslatorClassNames()
|
||||
{
|
||||
return array(
|
||||
array('Symfony\Component\Translation\Translator'),
|
||||
array('%translator_implementing_bag%'),
|
||||
);
|
||||
return [
|
||||
['Symfony\Component\Translation\Translator'],
|
||||
['%translator_implementing_bag%'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -99,16 +99,16 @@ class DataCollectorTranslatorPassTest extends TestCase
|
|||
|
||||
public function getNotImplementingTranslatorBagInterfaceTranslatorClassNames()
|
||||
{
|
||||
return array(
|
||||
array('Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler\TranslatorWithTranslatorBag'),
|
||||
array('%translator_not_implementing_bag%'),
|
||||
);
|
||||
return [
|
||||
['Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler\TranslatorWithTranslatorBag'],
|
||||
['%translator_not_implementing_bag%'],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
class TranslatorWithTranslatorBag implements TranslatorInterface
|
||||
{
|
||||
public function trans($id, array $parameters = array(), $domain = null, $locale = null)
|
||||
public function trans($id, array $parameters = [], $domain = null, $locale = null)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,35 +26,35 @@ class ConfigurationTest extends TestCase
|
|||
public function testDefaultConfig()
|
||||
{
|
||||
$processor = new Processor();
|
||||
$config = $processor->processConfiguration(new Configuration(true), array(array('secret' => 's3cr3t')));
|
||||
$config = $processor->processConfiguration(new Configuration(true), [['secret' => 's3cr3t']]);
|
||||
|
||||
$this->assertEquals(
|
||||
array_merge(array('secret' => 's3cr3t', 'trusted_hosts' => array()), self::getBundleDefaultConfig()),
|
||||
array_merge(['secret' => 's3cr3t', 'trusted_hosts' => []], self::getBundleDefaultConfig()),
|
||||
$config
|
||||
);
|
||||
}
|
||||
|
||||
public function testDoNoDuplicateDefaultFormResources()
|
||||
{
|
||||
$input = array('templating' => array(
|
||||
'form' => array('resources' => array('FrameworkBundle:Form')),
|
||||
'engines' => array('php'),
|
||||
));
|
||||
$input = ['templating' => [
|
||||
'form' => ['resources' => ['FrameworkBundle:Form']],
|
||||
'engines' => ['php'],
|
||||
]];
|
||||
|
||||
$processor = new Processor();
|
||||
$config = $processor->processConfiguration(new Configuration(true), array($input));
|
||||
$config = $processor->processConfiguration(new Configuration(true), [$input]);
|
||||
|
||||
$this->assertEquals(array('FrameworkBundle:Form'), $config['templating']['form']['resources']);
|
||||
$this->assertEquals(['FrameworkBundle:Form'], $config['templating']['form']['resources']);
|
||||
}
|
||||
|
||||
public function getTestValidSessionName()
|
||||
{
|
||||
return array(
|
||||
array(null),
|
||||
array('PHPSESSID'),
|
||||
array('a&b'),
|
||||
array(',_-!@#$%^*(){}:<>/?'),
|
||||
);
|
||||
return [
|
||||
[null],
|
||||
['PHPSESSID'],
|
||||
['a&b'],
|
||||
[',_-!@#$%^*(){}:<>/?'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -66,38 +66,38 @@ class ConfigurationTest extends TestCase
|
|||
$processor = new Processor();
|
||||
$processor->processConfiguration(
|
||||
new Configuration(true),
|
||||
array(array('session' => array('name' => $sessionName)))
|
||||
[['session' => ['name' => $sessionName]]]
|
||||
);
|
||||
}
|
||||
|
||||
public function getTestInvalidSessionName()
|
||||
{
|
||||
return array(
|
||||
array('a.b'),
|
||||
array('a['),
|
||||
array('a[]'),
|
||||
array('a[b]'),
|
||||
array('a=b'),
|
||||
array('a+b'),
|
||||
);
|
||||
return [
|
||||
['a.b'],
|
||||
['a['],
|
||||
['a[]'],
|
||||
['a[b]'],
|
||||
['a=b'],
|
||||
['a+b'],
|
||||
];
|
||||
}
|
||||
|
||||
public function testAssetsCanBeEnabled()
|
||||
{
|
||||
$processor = new Processor();
|
||||
$configuration = new Configuration(true);
|
||||
$config = $processor->processConfiguration($configuration, array(array('assets' => null)));
|
||||
$config = $processor->processConfiguration($configuration, [['assets' => null]]);
|
||||
|
||||
$defaultConfig = array(
|
||||
$defaultConfig = [
|
||||
'enabled' => true,
|
||||
'version_strategy' => null,
|
||||
'version' => null,
|
||||
'version_format' => '%%s?%%s',
|
||||
'base_path' => '',
|
||||
'base_urls' => array(),
|
||||
'packages' => array(),
|
||||
'base_urls' => [],
|
||||
'packages' => [],
|
||||
'json_manifest_path' => null,
|
||||
);
|
||||
];
|
||||
|
||||
$this->assertEquals($defaultConfig, $config['assets']);
|
||||
}
|
||||
|
@ -116,120 +116,120 @@ class ConfigurationTest extends TestCase
|
|||
|
||||
$processor = new Processor();
|
||||
$configuration = new Configuration(true);
|
||||
$processor->processConfiguration($configuration, array(
|
||||
array(
|
||||
$processor->processConfiguration($configuration, [
|
||||
[
|
||||
'assets' => $assetConfig,
|
||||
),
|
||||
));
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
public function provideInvalidAssetConfigurationTests()
|
||||
{
|
||||
// helper to turn config into embedded package config
|
||||
$createPackageConfig = function (array $packageConfig) {
|
||||
return array(
|
||||
return [
|
||||
'base_urls' => '//example.com',
|
||||
'version' => 1,
|
||||
'packages' => array(
|
||||
'packages' => [
|
||||
'foo' => $packageConfig,
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
};
|
||||
|
||||
$config = array(
|
||||
$config = [
|
||||
'version' => 1,
|
||||
'version_strategy' => 'foo',
|
||||
);
|
||||
yield array($config, 'You cannot use both "version_strategy" and "version" at the same time under "assets".');
|
||||
yield array($createPackageConfig($config), 'You cannot use both "version_strategy" and "version" at the same time under "assets" packages.');
|
||||
];
|
||||
yield [$config, 'You cannot use both "version_strategy" and "version" at the same time under "assets".'];
|
||||
yield [$createPackageConfig($config), 'You cannot use both "version_strategy" and "version" at the same time under "assets" packages.'];
|
||||
|
||||
$config = array(
|
||||
$config = [
|
||||
'json_manifest_path' => '/foo.json',
|
||||
'version_strategy' => 'foo',
|
||||
);
|
||||
yield array($config, 'You cannot use both "version_strategy" and "json_manifest_path" at the same time under "assets".');
|
||||
yield array($createPackageConfig($config), 'You cannot use both "version_strategy" and "json_manifest_path" at the same time under "assets" packages.');
|
||||
];
|
||||
yield [$config, 'You cannot use both "version_strategy" and "json_manifest_path" at the same time under "assets".'];
|
||||
yield [$createPackageConfig($config), 'You cannot use both "version_strategy" and "json_manifest_path" at the same time under "assets" packages.'];
|
||||
|
||||
$config = array(
|
||||
$config = [
|
||||
'json_manifest_path' => '/foo.json',
|
||||
'version' => '1',
|
||||
);
|
||||
yield array($config, 'You cannot use both "version" and "json_manifest_path" at the same time under "assets".');
|
||||
yield array($createPackageConfig($config), 'You cannot use both "version" and "json_manifest_path" at the same time under "assets" packages.');
|
||||
];
|
||||
yield [$config, 'You cannot use both "version" and "json_manifest_path" at the same time under "assets".'];
|
||||
yield [$createPackageConfig($config), 'You cannot use both "version" and "json_manifest_path" at the same time under "assets" packages.'];
|
||||
}
|
||||
|
||||
protected static function getBundleDefaultConfig()
|
||||
{
|
||||
return array(
|
||||
return [
|
||||
'http_method_override' => true,
|
||||
'ide' => null,
|
||||
'default_locale' => 'en',
|
||||
'csrf_protection' => array(
|
||||
'csrf_protection' => [
|
||||
'enabled' => false,
|
||||
),
|
||||
'form' => array(
|
||||
],
|
||||
'form' => [
|
||||
'enabled' => !class_exists(FullStack::class),
|
||||
'csrf_protection' => array(
|
||||
'csrf_protection' => [
|
||||
'enabled' => null, // defaults to csrf_protection.enabled
|
||||
'field_name' => '_token',
|
||||
),
|
||||
),
|
||||
'esi' => array('enabled' => false),
|
||||
'ssi' => array('enabled' => false),
|
||||
'fragments' => array(
|
||||
],
|
||||
],
|
||||
'esi' => ['enabled' => false],
|
||||
'ssi' => ['enabled' => false],
|
||||
'fragments' => [
|
||||
'enabled' => false,
|
||||
'path' => '/_fragment',
|
||||
),
|
||||
'profiler' => array(
|
||||
],
|
||||
'profiler' => [
|
||||
'enabled' => false,
|
||||
'only_exceptions' => false,
|
||||
'only_master_requests' => false,
|
||||
'dsn' => 'file:%kernel.cache_dir%/profiler',
|
||||
'collect' => true,
|
||||
),
|
||||
'translator' => array(
|
||||
],
|
||||
'translator' => [
|
||||
'enabled' => !class_exists(FullStack::class),
|
||||
'fallbacks' => array('en'),
|
||||
'fallbacks' => ['en'],
|
||||
'logging' => false,
|
||||
'formatter' => 'translator.formatter.default',
|
||||
'paths' => array(),
|
||||
'paths' => [],
|
||||
'default_path' => '%kernel.project_dir%/translations',
|
||||
),
|
||||
'validation' => array(
|
||||
],
|
||||
'validation' => [
|
||||
'enabled' => !class_exists(FullStack::class),
|
||||
'enable_annotations' => !class_exists(FullStack::class),
|
||||
'static_method' => array('loadValidatorMetadata'),
|
||||
'static_method' => ['loadValidatorMetadata'],
|
||||
'translation_domain' => 'validators',
|
||||
'mapping' => array(
|
||||
'paths' => array(),
|
||||
),
|
||||
),
|
||||
'annotations' => array(
|
||||
'mapping' => [
|
||||
'paths' => [],
|
||||
],
|
||||
],
|
||||
'annotations' => [
|
||||
'cache' => 'php_array',
|
||||
'file_cache_dir' => '%kernel.cache_dir%/annotations',
|
||||
'debug' => true,
|
||||
'enabled' => true,
|
||||
),
|
||||
'serializer' => array(
|
||||
],
|
||||
'serializer' => [
|
||||
'enabled' => !class_exists(FullStack::class),
|
||||
'enable_annotations' => !class_exists(FullStack::class),
|
||||
'mapping' => array('paths' => array()),
|
||||
),
|
||||
'property_access' => array(
|
||||
'mapping' => ['paths' => []],
|
||||
],
|
||||
'property_access' => [
|
||||
'magic_call' => false,
|
||||
'throw_exception_on_invalid_index' => false,
|
||||
),
|
||||
'property_info' => array(
|
||||
],
|
||||
'property_info' => [
|
||||
'enabled' => !class_exists(FullStack::class),
|
||||
),
|
||||
'router' => array(
|
||||
],
|
||||
'router' => [
|
||||
'enabled' => false,
|
||||
'http_port' => 80,
|
||||
'https_port' => 443,
|
||||
'strict_requirements' => true,
|
||||
'utf8' => false,
|
||||
),
|
||||
'session' => array(
|
||||
],
|
||||
'session' => [
|
||||
'enabled' => false,
|
||||
'storage_id' => 'session.storage.native',
|
||||
'handler_id' => 'session.handler.native_file',
|
||||
|
@ -238,70 +238,70 @@ class ConfigurationTest extends TestCase
|
|||
'gc_probability' => 1,
|
||||
'save_path' => '%kernel.cache_dir%/sessions',
|
||||
'metadata_update_threshold' => 0,
|
||||
),
|
||||
'request' => array(
|
||||
],
|
||||
'request' => [
|
||||
'enabled' => false,
|
||||
'formats' => array(),
|
||||
),
|
||||
'templating' => array(
|
||||
'formats' => [],
|
||||
],
|
||||
'templating' => [
|
||||
'enabled' => false,
|
||||
'hinclude_default_template' => null,
|
||||
'form' => array(
|
||||
'resources' => array('FrameworkBundle:Form'),
|
||||
),
|
||||
'engines' => array(),
|
||||
'loaders' => array(),
|
||||
),
|
||||
'assets' => array(
|
||||
'form' => [
|
||||
'resources' => ['FrameworkBundle:Form'],
|
||||
],
|
||||
'engines' => [],
|
||||
'loaders' => [],
|
||||
],
|
||||
'assets' => [
|
||||
'enabled' => !class_exists(FullStack::class),
|
||||
'version_strategy' => null,
|
||||
'version' => null,
|
||||
'version_format' => '%%s?%%s',
|
||||
'base_path' => '',
|
||||
'base_urls' => array(),
|
||||
'packages' => array(),
|
||||
'base_urls' => [],
|
||||
'packages' => [],
|
||||
'json_manifest_path' => null,
|
||||
),
|
||||
'cache' => array(
|
||||
'pools' => array(),
|
||||
],
|
||||
'cache' => [
|
||||
'pools' => [],
|
||||
'app' => 'cache.adapter.filesystem',
|
||||
'system' => 'cache.adapter.system',
|
||||
'directory' => '%kernel.cache_dir%/pools',
|
||||
'default_redis_provider' => 'redis://localhost',
|
||||
'default_memcached_provider' => 'memcached://localhost',
|
||||
'default_pdo_provider' => class_exists(Connection::class) ? 'database_connection' : null,
|
||||
),
|
||||
'workflows' => array(
|
||||
],
|
||||
'workflows' => [
|
||||
'enabled' => false,
|
||||
'workflows' => array(),
|
||||
),
|
||||
'php_errors' => array(
|
||||
'workflows' => [],
|
||||
],
|
||||
'php_errors' => [
|
||||
'log' => true,
|
||||
'throw' => true,
|
||||
),
|
||||
'web_link' => array(
|
||||
],
|
||||
'web_link' => [
|
||||
'enabled' => !class_exists(FullStack::class),
|
||||
),
|
||||
'lock' => array(
|
||||
],
|
||||
'lock' => [
|
||||
'enabled' => !class_exists(FullStack::class),
|
||||
'resources' => array(
|
||||
'default' => array(
|
||||
'resources' => [
|
||||
'default' => [
|
||||
class_exists(SemaphoreStore::class) && SemaphoreStore::isSupported() ? 'semaphore' : 'flock',
|
||||
),
|
||||
),
|
||||
),
|
||||
'messenger' => array(
|
||||
],
|
||||
],
|
||||
],
|
||||
'messenger' => [
|
||||
'enabled' => !class_exists(FullStack::class) && interface_exists(MessageBusInterface::class),
|
||||
'routing' => array(),
|
||||
'transports' => array(),
|
||||
'serializer' => array(
|
||||
'routing' => [],
|
||||
'transports' => [],
|
||||
'serializer' => [
|
||||
'id' => !class_exists(FullStack::class) && class_exists(Serializer::class) ? 'messenger.transport.symfony_serializer' : null,
|
||||
'format' => 'json',
|
||||
'context' => array(),
|
||||
),
|
||||
'context' => [],
|
||||
],
|
||||
'default_bus' => null,
|
||||
'buses' => array('messenger.bus.default' => array('default_middleware' => true, 'middleware' => array())),
|
||||
),
|
||||
);
|
||||
'buses' => ['messenger.bus.default' => ['default_middleware' => true, 'middleware' => []]],
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
<?php
|
||||
|
||||
$container->loadFromExtension('framework', array(
|
||||
'messenger' => array(
|
||||
$container->loadFromExtension('framework', [
|
||||
'messenger' => [
|
||||
'serializer' => false,
|
||||
'transports' => array(
|
||||
'transports' => [
|
||||
'default' => 'amqp://localhost/%2f/messages',
|
||||
),
|
||||
),
|
||||
));
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
<?php
|
||||
|
||||
$container->loadFromExtension('framework', array(
|
||||
'messenger' => array(
|
||||
$container->loadFromExtension('framework', [
|
||||
'messenger' => [
|
||||
'default_bus' => 'messenger.bus.commands',
|
||||
'buses' => array(
|
||||
'buses' => [
|
||||
'messenger.bus.commands' => null,
|
||||
'messenger.bus.events' => array(
|
||||
'middleware' => array(
|
||||
array('with_factory' => array('foo', true, array('bar' => 'baz'))),
|
||||
),
|
||||
),
|
||||
'messenger.bus.queries' => array(
|
||||
'messenger.bus.events' => [
|
||||
'middleware' => [
|
||||
['with_factory' => ['foo', true, ['bar' => 'baz']]],
|
||||
],
|
||||
],
|
||||
'messenger.bus.queries' => [
|
||||
'default_middleware' => false,
|
||||
'middleware' => array(
|
||||
'middleware' => [
|
||||
'send_message',
|
||||
'handle_message',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
));
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
<?php
|
||||
|
||||
$container->loadFromExtension('framework', array(
|
||||
$container->loadFromExtension('framework', [
|
||||
'serializer' => true,
|
||||
'messenger' => array(
|
||||
'messenger' => [
|
||||
'serializer' => 'messenger.transport.symfony_serializer',
|
||||
'routing' => array(
|
||||
'Symfony\Component\Messenger\Tests\Fixtures\DummyMessage' => array('amqp', 'audit'),
|
||||
'Symfony\Component\Messenger\Tests\Fixtures\SecondMessage' => array(
|
||||
'senders' => array('amqp', 'audit'),
|
||||
'routing' => [
|
||||
'Symfony\Component\Messenger\Tests\Fixtures\DummyMessage' => ['amqp', 'audit'],
|
||||
'Symfony\Component\Messenger\Tests\Fixtures\SecondMessage' => [
|
||||
'senders' => ['amqp', 'audit'],
|
||||
'send_and_handle' => true,
|
||||
),
|
||||
],
|
||||
'*' => 'amqp',
|
||||
),
|
||||
'transports' => array(
|
||||
],
|
||||
'transports' => [
|
||||
'amqp' => 'amqp://localhost/%2f/messages',
|
||||
),
|
||||
),
|
||||
));
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
<?php
|
||||
|
||||
$container->loadFromExtension('framework', array(
|
||||
$container->loadFromExtension('framework', [
|
||||
'serializer' => true,
|
||||
'messenger' => array(
|
||||
'serializer' => array(
|
||||
'messenger' => [
|
||||
'serializer' => [
|
||||
'id' => 'messenger.transport.symfony_serializer',
|
||||
'format' => 'csv',
|
||||
'context' => array('enable_max_depth' => true),
|
||||
),
|
||||
'transports' => array(
|
||||
'context' => ['enable_max_depth' => true],
|
||||
],
|
||||
'transports' => [
|
||||
'default' => 'amqp://localhost/%2f/messages',
|
||||
),
|
||||
),
|
||||
));
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
<?php
|
||||
|
||||
$container->loadFromExtension('framework', array(
|
||||
'serializer' => array(
|
||||
$container->loadFromExtension('framework', [
|
||||
'serializer' => [
|
||||
'enabled' => false,
|
||||
),
|
||||
'messenger' => array(
|
||||
],
|
||||
'messenger' => [
|
||||
'serializer' => 'messenger.transport.symfony_serializer',
|
||||
'transports' => array(
|
||||
'transports' => [
|
||||
'default' => 'amqp://localhost/%2f/messages',
|
||||
),
|
||||
),
|
||||
));
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
<?php
|
||||
|
||||
$container->loadFromExtension('framework', array(
|
||||
$container->loadFromExtension('framework', [
|
||||
'serializer' => true,
|
||||
'messenger' => array(
|
||||
'messenger' => [
|
||||
'serializer' => 'messenger.transport.symfony_serializer',
|
||||
'transports' => array(
|
||||
'transports' => [
|
||||
'default' => 'amqp://localhost/%2f/messages',
|
||||
'customised' => array(
|
||||
'customised' => [
|
||||
'dsn' => 'amqp://localhost/%2f/messages?exchange_name=exchange_name',
|
||||
'options' => array('queue' => array('name' => 'Queue')),
|
||||
),
|
||||
),
|
||||
),
|
||||
));
|
||||
'options' => ['queue' => ['name' => 'Queue']],
|
||||
],
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
$container->loadFromExtension('framework', array(
|
||||
'serializer' => array(
|
||||
$container->loadFromExtension('framework', [
|
||||
'serializer' => [
|
||||
'enabled' => false,
|
||||
),
|
||||
));
|
||||
],
|
||||
]);
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<?php
|
||||
|
||||
$container->loadFromExtension('framework', array(
|
||||
'session' => array(
|
||||
$container->loadFromExtension('framework', [
|
||||
'session' => [
|
||||
'handler_id' => null,
|
||||
'cookie_secure' => 'auto',
|
||||
),
|
||||
));
|
||||
],
|
||||
]);
|
||||
|
|
|
@ -54,7 +54,7 @@ use Symfony\Component\Workflow;
|
|||
|
||||
abstract class FrameworkExtensionTest extends TestCase
|
||||
{
|
||||
private static $containerCache = array();
|
||||
private static $containerCache = [];
|
||||
|
||||
abstract protected function loadFromFile(ContainerBuilder $container, $file);
|
||||
|
||||
|
@ -96,13 +96,13 @@ abstract class FrameworkExtensionTest extends TestCase
|
|||
}
|
||||
|
||||
$cache = $container->getDefinition('cache.property_access');
|
||||
$this->assertSame(array(PropertyAccessor::class, 'createCache'), $cache->getFactory(), 'PropertyAccessor::createCache() should be used in non-debug mode');
|
||||
$this->assertSame([PropertyAccessor::class, 'createCache'], $cache->getFactory(), 'PropertyAccessor::createCache() should be used in non-debug mode');
|
||||
$this->assertSame(AdapterInterface::class, $cache->getClass());
|
||||
}
|
||||
|
||||
public function testPropertyAccessCacheWithDebug()
|
||||
{
|
||||
$container = $this->createContainerFromFile('property_accessor', array('kernel.debug' => true));
|
||||
$container = $this->createContainerFromFile('property_accessor', ['kernel.debug' => true]);
|
||||
|
||||
if (!method_exists(PropertyAccessor::class, 'createCache')) {
|
||||
return $this->assertFalse($container->hasDefinition('cache.property_access'));
|
||||
|
@ -204,18 +204,18 @@ abstract class FrameworkExtensionTest extends TestCase
|
|||
$workflowDefinition = $container->getDefinition('workflow.article.definition');
|
||||
|
||||
$this->assertSame(
|
||||
array(
|
||||
[
|
||||
'draft',
|
||||
'wait_for_journalist',
|
||||
'approved_by_journalist',
|
||||
'wait_for_spellchecker',
|
||||
'approved_by_spellchecker',
|
||||
'published',
|
||||
),
|
||||
],
|
||||
$workflowDefinition->getArgument(0),
|
||||
'Places are passed to the workflow definition'
|
||||
);
|
||||
$this->assertSame(array('workflow.definition' => array(array('name' => 'article', 'type' => 'workflow', 'marking_store' => 'multiple_state'))), $workflowDefinition->getTags());
|
||||
$this->assertSame(['workflow.definition' => [['name' => 'article', 'type' => 'workflow', 'marking_store' => 'multiple_state']]], $workflowDefinition->getTags());
|
||||
$this->assertCount(4, $workflowDefinition->getArgument(1));
|
||||
$this->assertSame('draft', $workflowDefinition->getArgument(2));
|
||||
|
||||
|
@ -226,18 +226,18 @@ abstract class FrameworkExtensionTest extends TestCase
|
|||
$stateMachineDefinition = $container->getDefinition('state_machine.pull_request.definition');
|
||||
|
||||
$this->assertSame(
|
||||
array(
|
||||
[
|
||||
'start',
|
||||
'coding',
|
||||
'travis',
|
||||
'review',
|
||||
'merged',
|
||||
'closed',
|
||||
),
|
||||
],
|
||||
$stateMachineDefinition->getArgument(0),
|
||||
'Places are passed to the state machine definition'
|
||||
);
|
||||
$this->assertSame(array('workflow.definition' => array(array('name' => 'pull_request', 'type' => 'state_machine', 'marking_store' => 'single_state'))), $stateMachineDefinition->getTags());
|
||||
$this->assertSame(['workflow.definition' => [['name' => 'pull_request', 'type' => 'state_machine', 'marking_store' => 'single_state']]], $stateMachineDefinition->getTags());
|
||||
$this->assertCount(9, $stateMachineDefinition->getArgument(1));
|
||||
$this->assertSame('start', $stateMachineDefinition->getArgument(2));
|
||||
|
||||
|
@ -246,11 +246,11 @@ abstract class FrameworkExtensionTest extends TestCase
|
|||
$this->assertSame(Workflow\Metadata\InMemoryMetadataStore::class, $metadataStoreDefinition->getClass());
|
||||
|
||||
$workflowMetadata = $metadataStoreDefinition->getArgument(0);
|
||||
$this->assertSame(array('title' => 'workflow title'), $workflowMetadata);
|
||||
$this->assertSame(['title' => 'workflow title'], $workflowMetadata);
|
||||
|
||||
$placesMetadata = $metadataStoreDefinition->getArgument(1);
|
||||
$this->assertArrayHasKey('start', $placesMetadata);
|
||||
$this->assertSame(array('title' => 'place start title'), $placesMetadata['start']);
|
||||
$this->assertSame(['title' => 'place start title'], $placesMetadata['start']);
|
||||
|
||||
$transitionsMetadata = $metadataStoreDefinition->getArgument(2);
|
||||
$this->assertSame(\SplObjectStorage::class, $transitionsMetadata->getClass());
|
||||
|
@ -322,60 +322,60 @@ abstract class FrameworkExtensionTest extends TestCase
|
|||
$this->assertCount(5, $transitions);
|
||||
|
||||
$this->assertSame('workflow.article.transition.0', (string) $transitions[0]);
|
||||
$this->assertSame(array(
|
||||
$this->assertSame([
|
||||
'request_review',
|
||||
array(
|
||||
[
|
||||
'draft',
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'wait_for_journalist', 'wait_for_spellchecker',
|
||||
),
|
||||
), $container->getDefinition($transitions[0])->getArguments());
|
||||
],
|
||||
], $container->getDefinition($transitions[0])->getArguments());
|
||||
|
||||
$this->assertSame('workflow.article.transition.1', (string) $transitions[1]);
|
||||
$this->assertSame(array(
|
||||
$this->assertSame([
|
||||
'journalist_approval',
|
||||
array(
|
||||
[
|
||||
'wait_for_journalist',
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'approved_by_journalist',
|
||||
),
|
||||
), $container->getDefinition($transitions[1])->getArguments());
|
||||
],
|
||||
], $container->getDefinition($transitions[1])->getArguments());
|
||||
|
||||
$this->assertSame('workflow.article.transition.2', (string) $transitions[2]);
|
||||
$this->assertSame(array(
|
||||
$this->assertSame([
|
||||
'spellchecker_approval',
|
||||
array(
|
||||
[
|
||||
'wait_for_spellchecker',
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'approved_by_spellchecker',
|
||||
),
|
||||
), $container->getDefinition($transitions[2])->getArguments());
|
||||
],
|
||||
], $container->getDefinition($transitions[2])->getArguments());
|
||||
|
||||
$this->assertSame('workflow.article.transition.3', (string) $transitions[3]);
|
||||
$this->assertSame(array(
|
||||
$this->assertSame([
|
||||
'publish',
|
||||
array(
|
||||
[
|
||||
'approved_by_journalist',
|
||||
'approved_by_spellchecker',
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'published',
|
||||
),
|
||||
), $container->getDefinition($transitions[3])->getArguments());
|
||||
],
|
||||
], $container->getDefinition($transitions[3])->getArguments());
|
||||
|
||||
$this->assertSame('workflow.article.transition.4', (string) $transitions[4]);
|
||||
$this->assertSame(array(
|
||||
$this->assertSame([
|
||||
'publish',
|
||||
array(
|
||||
[
|
||||
'draft',
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'published',
|
||||
),
|
||||
), $container->getDefinition($transitions[4])->getArguments());
|
||||
],
|
||||
], $container->getDefinition($transitions[4])->getArguments());
|
||||
}
|
||||
|
||||
public function testGuardExpressions()
|
||||
|
@ -386,12 +386,12 @@ abstract class FrameworkExtensionTest extends TestCase
|
|||
$this->assertTrue($container->hasParameter('workflow.has_guard_listeners'), 'Workflow guard listeners parameter exists');
|
||||
$this->assertTrue(true === $container->getParameter('workflow.has_guard_listeners'), 'Workflow guard listeners parameter is enabled');
|
||||
$guardDefinition = $container->getDefinition('workflow.article.listener.guard');
|
||||
$this->assertSame(array(
|
||||
array(
|
||||
$this->assertSame([
|
||||
[
|
||||
'event' => 'workflow.article.guard.publish',
|
||||
'method' => 'onTransition',
|
||||
),
|
||||
), $guardDefinition->getTag('kernel.event_listener'));
|
||||
],
|
||||
], $guardDefinition->getTag('kernel.event_listener'));
|
||||
$guardsConfiguration = $guardDefinition->getArgument(0);
|
||||
$this->assertTrue(1 === \count($guardsConfiguration), 'Workflow guard configuration contains one element per transition name');
|
||||
$transitionGuardExpressions = $guardsConfiguration['workflow.article.guard.publish'];
|
||||
|
@ -470,7 +470,7 @@ abstract class FrameworkExtensionTest extends TestCase
|
|||
{
|
||||
$container = $this->createContainer();
|
||||
$loader = new FrameworkExtension();
|
||||
$loader->load(array(array('router' => true)), $container);
|
||||
$loader->load([['router' => true]], $container);
|
||||
}
|
||||
|
||||
public function testSession()
|
||||
|
@ -505,7 +505,7 @@ abstract class FrameworkExtensionTest extends TestCase
|
|||
$this->assertNull($container->getDefinition('session.storage.native')->getArgument(1));
|
||||
$this->assertNull($container->getDefinition('session.storage.php_bridge')->getArgument(0));
|
||||
|
||||
$expected = array('session', 'initialized_session');
|
||||
$expected = ['session', 'initialized_session'];
|
||||
$this->assertEquals($expected, array_keys($container->getDefinition('session_listener')->getArgument(0)->getValues()));
|
||||
}
|
||||
|
||||
|
@ -515,7 +515,7 @@ abstract class FrameworkExtensionTest extends TestCase
|
|||
|
||||
$this->assertTrue($container->hasDefinition('request.add_request_formats_listener'), '->registerRequestConfiguration() loads request.xml');
|
||||
$listenerDef = $container->getDefinition('request.add_request_formats_listener');
|
||||
$this->assertEquals(array('csv' => array('text/csv', 'text/plain'), 'pdf' => array('application/pdf')), $listenerDef->getArgument(0));
|
||||
$this->assertEquals(['csv' => ['text/csv', 'text/plain'], 'pdf' => ['application/pdf']], $listenerDef->getArgument(0));
|
||||
}
|
||||
|
||||
public function testEmptyRequestFormats()
|
||||
|
@ -540,9 +540,9 @@ abstract class FrameworkExtensionTest extends TestCase
|
|||
$this->assertEquals('%templating.loader.cache.path%', $container->getDefinition('templating.loader.cache')->getArgument(1));
|
||||
$this->assertEquals('/path/to/cache', $container->getParameter('templating.loader.cache.path'));
|
||||
|
||||
$this->assertEquals(array('php', 'twig'), $container->getParameter('templating.engines'), '->registerTemplatingConfiguration() sets a templating.engines parameter');
|
||||
$this->assertEquals(['php', 'twig'], $container->getParameter('templating.engines'), '->registerTemplatingConfiguration() sets a templating.engines parameter');
|
||||
|
||||
$this->assertEquals(array('FrameworkBundle:Form', 'theme1', 'theme2'), $container->getParameter('templating.helper.form.resources'), '->registerTemplatingConfiguration() registers the theme and adds the base theme');
|
||||
$this->assertEquals(['FrameworkBundle:Form', 'theme1', 'theme2'], $container->getParameter('templating.helper.form.resources'), '->registerTemplatingConfiguration() registers the theme and adds the base theme');
|
||||
$this->assertEquals('global_hinclude_template', $container->getParameter('fragment.renderer.hinclude.global_template'), '->registerTemplatingConfiguration() registers the global hinclude.js template');
|
||||
}
|
||||
|
||||
|
@ -560,7 +560,7 @@ abstract class FrameworkExtensionTest extends TestCase
|
|||
|
||||
// default package
|
||||
$defaultPackage = $container->getDefinition((string) $packages->getArgument(0));
|
||||
$this->assertUrlPackage($container, $defaultPackage, array('http://cdn.example.com'), 'SomeVersionScheme', '%%s?version=%%s');
|
||||
$this->assertUrlPackage($container, $defaultPackage, ['http://cdn.example.com'], 'SomeVersionScheme', '%%s?version=%%s');
|
||||
|
||||
// packages
|
||||
$packages = $packages->getArgument(1);
|
||||
|
@ -570,13 +570,13 @@ abstract class FrameworkExtensionTest extends TestCase
|
|||
$this->assertPathPackage($container, $package, '/foo', 'SomeVersionScheme', '%%s?version=%%s');
|
||||
|
||||
$package = $container->getDefinition((string) $packages['images']);
|
||||
$this->assertUrlPackage($container, $package, array('http://images1.example.com', 'http://images2.example.com'), '1.0.0', '%%s?version=%%s');
|
||||
$this->assertUrlPackage($container, $package, ['http://images1.example.com', 'http://images2.example.com'], '1.0.0', '%%s?version=%%s');
|
||||
|
||||
$package = $container->getDefinition((string) $packages['foo']);
|
||||
$this->assertPathPackage($container, $package, '', '1.0.0', '%%s-%%s');
|
||||
|
||||
$package = $container->getDefinition((string) $packages['bar']);
|
||||
$this->assertUrlPackage($container, $package, array('https://bar2.example.com'), 'SomeVersionScheme', '%%s?version=%%s');
|
||||
$this->assertUrlPackage($container, $package, ['https://bar2.example.com'], 'SomeVersionScheme', '%%s?version=%%s');
|
||||
|
||||
$package = $container->getDefinition((string) $packages['bar_version_strategy']);
|
||||
$this->assertEquals('assets.custom_version_strategy', (string) $package->getArgument(1));
|
||||
|
@ -625,16 +625,16 @@ abstract class FrameworkExtensionTest extends TestCase
|
|||
$container = $this->createContainerFromFile('messenger_transports');
|
||||
$this->assertTrue($container->hasDefinition('messenger.transport.default'));
|
||||
$this->assertTrue($container->getDefinition('messenger.transport.default')->hasTag('messenger.receiver'));
|
||||
$this->assertEquals(array(array('alias' => 'default')), $container->getDefinition('messenger.transport.default')->getTag('messenger.receiver'));
|
||||
$this->assertEquals([['alias' => 'default']], $container->getDefinition('messenger.transport.default')->getTag('messenger.receiver'));
|
||||
|
||||
$this->assertTrue($container->hasDefinition('messenger.transport.customised'));
|
||||
$transportFactory = $container->getDefinition('messenger.transport.customised')->getFactory();
|
||||
$transportArguments = $container->getDefinition('messenger.transport.customised')->getArguments();
|
||||
|
||||
$this->assertEquals(array(new Reference('messenger.transport_factory'), 'createTransport'), $transportFactory);
|
||||
$this->assertEquals([new Reference('messenger.transport_factory'), 'createTransport'], $transportFactory);
|
||||
$this->assertCount(2, $transportArguments);
|
||||
$this->assertSame('amqp://localhost/%2f/messages?exchange_name=exchange_name', $transportArguments[0]);
|
||||
$this->assertSame(array('queue' => array('name' => 'Queue')), $transportArguments[1]);
|
||||
$this->assertSame(['queue' => ['name' => 'Queue']], $transportArguments[1]);
|
||||
|
||||
$this->assertTrue($container->hasDefinition('messenger.transport.amqp.factory'));
|
||||
}
|
||||
|
@ -644,18 +644,18 @@ abstract class FrameworkExtensionTest extends TestCase
|
|||
$container = $this->createContainerFromFile('messenger_routing');
|
||||
$senderLocatorDefinition = $container->getDefinition('messenger.senders_locator');
|
||||
|
||||
$messageToSendAndHandleMapping = array(
|
||||
$messageToSendAndHandleMapping = [
|
||||
DummyMessage::class => false,
|
||||
SecondMessage::class => true,
|
||||
'*' => false,
|
||||
);
|
||||
];
|
||||
|
||||
$this->assertSame($messageToSendAndHandleMapping, $senderLocatorDefinition->getArgument(1));
|
||||
$sendersMapping = $senderLocatorDefinition->getArgument(0);
|
||||
$this->assertEquals(array(
|
||||
$this->assertEquals([
|
||||
'amqp' => new Reference('messenger.transport.amqp'),
|
||||
'audit' => new Reference('audit'),
|
||||
), $sendersMapping[DummyMessage::class]->getValues());
|
||||
], $sendersMapping[DummyMessage::class]->getValues());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -684,7 +684,7 @@ abstract class FrameworkExtensionTest extends TestCase
|
|||
|
||||
$serializerTransportDefinition = $container->getDefinition('messenger.transport.symfony_serializer');
|
||||
$this->assertSame('csv', $serializerTransportDefinition->getArgument(1));
|
||||
$this->assertSame(array('enable_max_depth' => true), $serializerTransportDefinition->getArgument(2));
|
||||
$this->assertSame(['enable_max_depth' => true], $serializerTransportDefinition->getArgument(2));
|
||||
}
|
||||
|
||||
public function testMessengerWithMultipleBuses()
|
||||
|
@ -692,26 +692,26 @@ abstract class FrameworkExtensionTest extends TestCase
|
|||
$container = $this->createContainerFromFile('messenger_multiple_buses');
|
||||
|
||||
$this->assertTrue($container->has('messenger.bus.commands'));
|
||||
$this->assertSame(array(), $container->getDefinition('messenger.bus.commands')->getArgument(0));
|
||||
$this->assertEquals(array(
|
||||
array('id' => 'logging'),
|
||||
array('id' => 'send_message'),
|
||||
array('id' => 'handle_message'),
|
||||
), $container->getParameter('messenger.bus.commands.middleware'));
|
||||
$this->assertSame([], $container->getDefinition('messenger.bus.commands')->getArgument(0));
|
||||
$this->assertEquals([
|
||||
['id' => 'logging'],
|
||||
['id' => 'send_message'],
|
||||
['id' => 'handle_message'],
|
||||
], $container->getParameter('messenger.bus.commands.middleware'));
|
||||
$this->assertTrue($container->has('messenger.bus.events'));
|
||||
$this->assertSame(array(), $container->getDefinition('messenger.bus.events')->getArgument(0));
|
||||
$this->assertEquals(array(
|
||||
array('id' => 'logging'),
|
||||
array('id' => 'with_factory', 'arguments' => array('foo', true, array('bar' => 'baz'))),
|
||||
array('id' => 'send_message'),
|
||||
array('id' => 'handle_message'),
|
||||
), $container->getParameter('messenger.bus.events.middleware'));
|
||||
$this->assertSame([], $container->getDefinition('messenger.bus.events')->getArgument(0));
|
||||
$this->assertEquals([
|
||||
['id' => 'logging'],
|
||||
['id' => 'with_factory', 'arguments' => ['foo', true, ['bar' => 'baz']]],
|
||||
['id' => 'send_message'],
|
||||
['id' => 'handle_message'],
|
||||
], $container->getParameter('messenger.bus.events.middleware'));
|
||||
$this->assertTrue($container->has('messenger.bus.queries'));
|
||||
$this->assertSame(array(), $container->getDefinition('messenger.bus.queries')->getArgument(0));
|
||||
$this->assertEquals(array(
|
||||
array('id' => 'send_message', 'arguments' => array()),
|
||||
array('id' => 'handle_message', 'arguments' => array()),
|
||||
), $container->getParameter('messenger.bus.queries.middleware'));
|
||||
$this->assertSame([], $container->getDefinition('messenger.bus.queries')->getArgument(0));
|
||||
$this->assertEquals([
|
||||
['id' => 'send_message', 'arguments' => []],
|
||||
['id' => 'handle_message', 'arguments' => []],
|
||||
], $container->getParameter('messenger.bus.queries.middleware'));
|
||||
|
||||
$this->assertTrue($container->hasAlias('message_bus'));
|
||||
$this->assertSame('messenger.bus.commands', (string) $container->getAlias('message_bus'));
|
||||
|
@ -764,7 +764,7 @@ abstract class FrameworkExtensionTest extends TestCase
|
|||
);
|
||||
|
||||
$calls = $container->getDefinition('translator.default')->getMethodCalls();
|
||||
$this->assertEquals(array('fr'), $calls[1][1][0]);
|
||||
$this->assertEquals(['fr'], $calls[1][1][0]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -773,7 +773,7 @@ abstract class FrameworkExtensionTest extends TestCase
|
|||
*/
|
||||
public function testLegacyTranslationsDirectory()
|
||||
{
|
||||
$container = $this->createContainerFromFile('full', array('kernel.root_dir' => __DIR__.'/Fixtures'));
|
||||
$container = $this->createContainerFromFile('full', ['kernel.root_dir' => __DIR__.'/Fixtures']);
|
||||
$options = $container->getDefinition('translator.default')->getArgument(4);
|
||||
$files = array_map('realpath', $options['resource_files']['en']);
|
||||
|
||||
|
@ -786,7 +786,7 @@ abstract class FrameworkExtensionTest extends TestCase
|
|||
$container = $this->createContainerFromFile('translator_fallbacks');
|
||||
|
||||
$calls = $container->getDefinition('translator.default')->getMethodCalls();
|
||||
$this->assertEquals(array('en', 'fr'), $calls[1][1][0]);
|
||||
$this->assertEquals(['en', 'fr'], $calls[1][1][0]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -796,7 +796,7 @@ abstract class FrameworkExtensionTest extends TestCase
|
|||
{
|
||||
$container = $this->createContainer();
|
||||
$loader = new FrameworkExtension();
|
||||
$loader->load(array(array('templating' => null)), $container);
|
||||
$loader->load([['templating' => null]], $container);
|
||||
}
|
||||
|
||||
public function testValidation()
|
||||
|
@ -805,10 +805,10 @@ abstract class FrameworkExtensionTest extends TestCase
|
|||
$projectDir = $container->getParameter('kernel.project_dir');
|
||||
|
||||
$ref = new \ReflectionClass('Symfony\Component\Form\Form');
|
||||
$xmlMappings = array(
|
||||
$xmlMappings = [
|
||||
\dirname($ref->getFileName()).'/Resources/config/validation.xml',
|
||||
strtr($projectDir.'/config/validator/foo.xml', '/', \DIRECTORY_SEPARATOR),
|
||||
);
|
||||
];
|
||||
|
||||
$calls = $container->getDefinition('validator.builder')->getMethodCalls();
|
||||
|
||||
|
@ -816,33 +816,33 @@ abstract class FrameworkExtensionTest extends TestCase
|
|||
|
||||
$this->assertCount($annotations ? 7 : 6, $calls);
|
||||
$this->assertSame('setConstraintValidatorFactory', $calls[0][0]);
|
||||
$this->assertEquals(array(new Reference('validator.validator_factory')), $calls[0][1]);
|
||||
$this->assertEquals([new Reference('validator.validator_factory')], $calls[0][1]);
|
||||
$this->assertSame('setTranslator', $calls[1][0]);
|
||||
$this->assertEquals(array(new Reference('translator')), $calls[1][1]);
|
||||
$this->assertEquals([new Reference('translator')], $calls[1][1]);
|
||||
$this->assertSame('setTranslationDomain', $calls[2][0]);
|
||||
$this->assertSame(array('%validator.translation_domain%'), $calls[2][1]);
|
||||
$this->assertSame(['%validator.translation_domain%'], $calls[2][1]);
|
||||
$this->assertSame('addXmlMappings', $calls[3][0]);
|
||||
$this->assertSame(array($xmlMappings), $calls[3][1]);
|
||||
$this->assertSame([$xmlMappings], $calls[3][1]);
|
||||
$i = 3;
|
||||
if ($annotations) {
|
||||
$this->assertSame('enableAnnotationMapping', $calls[++$i][0]);
|
||||
}
|
||||
$this->assertSame('addMethodMapping', $calls[++$i][0]);
|
||||
$this->assertSame(array('loadValidatorMetadata'), $calls[$i][1]);
|
||||
$this->assertSame(['loadValidatorMetadata'], $calls[$i][1]);
|
||||
$this->assertSame('setMetadataCache', $calls[++$i][0]);
|
||||
$this->assertEquals(array(new Reference('validator.mapping.cache.symfony')), $calls[$i][1]);
|
||||
$this->assertEquals([new Reference('validator.mapping.cache.symfony')], $calls[$i][1]);
|
||||
}
|
||||
|
||||
public function testValidationService()
|
||||
{
|
||||
$container = $this->createContainerFromFile('validation_annotations', array('kernel.charset' => 'UTF-8'), false);
|
||||
$container = $this->createContainerFromFile('validation_annotations', ['kernel.charset' => 'UTF-8'], false);
|
||||
|
||||
$this->assertInstanceOf('Symfony\Component\Validator\Validator\ValidatorInterface', $container->get('validator'));
|
||||
}
|
||||
|
||||
public function testAnnotations()
|
||||
{
|
||||
$container = $this->createContainerFromFile('full', array(), true, false);
|
||||
$container = $this->createContainerFromFile('full', [], true, false);
|
||||
$container->addCompilerPass(new TestAnnotationsPass());
|
||||
$container->compile();
|
||||
|
||||
|
@ -869,11 +869,11 @@ abstract class FrameworkExtensionTest extends TestCase
|
|||
|
||||
$this->assertCount(7, $calls);
|
||||
$this->assertSame('enableAnnotationMapping', $calls[4][0]);
|
||||
$this->assertEquals(array(new Reference('annotation_reader')), $calls[4][1]);
|
||||
$this->assertEquals([new Reference('annotation_reader')], $calls[4][1]);
|
||||
$this->assertSame('addMethodMapping', $calls[5][0]);
|
||||
$this->assertSame(array('loadValidatorMetadata'), $calls[5][1]);
|
||||
$this->assertSame(['loadValidatorMetadata'], $calls[5][1]);
|
||||
$this->assertSame('setMetadataCache', $calls[6][0]);
|
||||
$this->assertEquals(array(new Reference('validator.mapping.cache.symfony')), $calls[6][1]);
|
||||
$this->assertEquals([new Reference('validator.mapping.cache.symfony')], $calls[6][1]);
|
||||
// no cache this time
|
||||
}
|
||||
|
||||
|
@ -881,10 +881,10 @@ abstract class FrameworkExtensionTest extends TestCase
|
|||
{
|
||||
require_once __DIR__.'/Fixtures/TestBundle/TestBundle.php';
|
||||
|
||||
$container = $this->createContainerFromFile('validation_annotations', array(
|
||||
'kernel.bundles' => array('TestBundle' => 'Symfony\\Bundle\\FrameworkBundle\\Tests\\TestBundle'),
|
||||
'kernel.bundles_metadata' => array('TestBundle' => array('namespace' => 'Symfony\\Bundle\\FrameworkBundle\\Tests', 'path' => __DIR__.'/Fixtures/TestBundle')),
|
||||
));
|
||||
$container = $this->createContainerFromFile('validation_annotations', [
|
||||
'kernel.bundles' => ['TestBundle' => 'Symfony\\Bundle\\FrameworkBundle\\Tests\\TestBundle'],
|
||||
'kernel.bundles_metadata' => ['TestBundle' => ['namespace' => 'Symfony\\Bundle\\FrameworkBundle\\Tests', 'path' => __DIR__.'/Fixtures/TestBundle']],
|
||||
]);
|
||||
|
||||
$calls = $container->getDefinition('validator.builder')->getMethodCalls();
|
||||
|
||||
|
@ -893,9 +893,9 @@ abstract class FrameworkExtensionTest extends TestCase
|
|||
$this->assertSame('addYamlMappings', $calls[4][0]);
|
||||
$this->assertSame('enableAnnotationMapping', $calls[5][0]);
|
||||
$this->assertSame('addMethodMapping', $calls[6][0]);
|
||||
$this->assertSame(array('loadValidatorMetadata'), $calls[6][1]);
|
||||
$this->assertSame(['loadValidatorMetadata'], $calls[6][1]);
|
||||
$this->assertSame('setMetadataCache', $calls[7][0]);
|
||||
$this->assertEquals(array(new Reference('validator.mapping.cache.symfony')), $calls[7][1]);
|
||||
$this->assertEquals([new Reference('validator.mapping.cache.symfony')], $calls[7][1]);
|
||||
|
||||
$xmlMappings = $calls[3][1][0];
|
||||
$this->assertCount(3, $xmlMappings);
|
||||
|
@ -917,10 +917,10 @@ abstract class FrameworkExtensionTest extends TestCase
|
|||
{
|
||||
require_once __DIR__.'/Fixtures/CustomPathBundle/src/CustomPathBundle.php';
|
||||
|
||||
$container = $this->createContainerFromFile('validation_annotations', array(
|
||||
'kernel.bundles' => array('CustomPathBundle' => 'Symfony\\Bundle\\FrameworkBundle\\Tests\\CustomPathBundle'),
|
||||
'kernel.bundles_metadata' => array('TestBundle' => array('namespace' => 'Symfony\\Bundle\\FrameworkBundle\\Tests', 'path' => __DIR__.'/Fixtures/CustomPathBundle')),
|
||||
));
|
||||
$container = $this->createContainerFromFile('validation_annotations', [
|
||||
'kernel.bundles' => ['CustomPathBundle' => 'Symfony\\Bundle\\FrameworkBundle\\Tests\\CustomPathBundle'],
|
||||
'kernel.bundles_metadata' => ['TestBundle' => ['namespace' => 'Symfony\\Bundle\\FrameworkBundle\\Tests', 'path' => __DIR__.'/Fixtures/CustomPathBundle']],
|
||||
]);
|
||||
|
||||
$calls = $container->getDefinition('validator.builder')->getMethodCalls();
|
||||
$xmlMappings = $calls[3][1][0];
|
||||
|
@ -955,7 +955,7 @@ abstract class FrameworkExtensionTest extends TestCase
|
|||
$this->assertSame('enableAnnotationMapping', $calls[++$i][0]);
|
||||
}
|
||||
$this->assertSame('setMetadataCache', $calls[++$i][0]);
|
||||
$this->assertEquals(array(new Reference('validator.mapping.cache.symfony')), $calls[$i][1]);
|
||||
$this->assertEquals([new Reference('validator.mapping.cache.symfony')], $calls[$i][1]);
|
||||
// no cache, no annotations, no static methods
|
||||
}
|
||||
|
||||
|
@ -1031,19 +1031,19 @@ abstract class FrameworkExtensionTest extends TestCase
|
|||
|
||||
public function testStopwatchEnabledWithDebugModeEnabled()
|
||||
{
|
||||
$container = $this->createContainerFromFile('default_config', array(
|
||||
$container = $this->createContainerFromFile('default_config', [
|
||||
'kernel.container_class' => 'foo',
|
||||
'kernel.debug' => true,
|
||||
));
|
||||
]);
|
||||
|
||||
$this->assertTrue($container->has('debug.stopwatch'));
|
||||
}
|
||||
|
||||
public function testStopwatchEnabledWithDebugModeDisabled()
|
||||
{
|
||||
$container = $this->createContainerFromFile('default_config', array(
|
||||
$container = $this->createContainerFromFile('default_config', [
|
||||
'kernel.container_class' => 'foo',
|
||||
));
|
||||
]);
|
||||
|
||||
$this->assertTrue($container->has('debug.stopwatch'));
|
||||
}
|
||||
|
@ -1066,8 +1066,8 @@ abstract class FrameworkExtensionTest extends TestCase
|
|||
$this->assertNull($container->getDefinition('serializer.mapping.class_metadata_factory')->getArgument(1));
|
||||
$this->assertEquals(new Reference('serializer.name_converter.camel_case_to_snake_case'), $container->getDefinition('serializer.name_converter.metadata_aware')->getArgument(1));
|
||||
$this->assertEquals(new Reference('property_info', ContainerBuilder::IGNORE_ON_INVALID_REFERENCE), $container->getDefinition('serializer.normalizer.object')->getArgument(3));
|
||||
$this->assertEquals(array('setCircularReferenceHandler', array(new Reference('my.circular.reference.handler'))), $container->getDefinition('serializer.normalizer.object')->getMethodCalls()[0]);
|
||||
$this->assertEquals(array('setMaxDepthHandler', array(new Reference('my.max.depth.handler'))), $container->getDefinition('serializer.normalizer.object')->getMethodCalls()[1]);
|
||||
$this->assertEquals(['setCircularReferenceHandler', [new Reference('my.circular.reference.handler')]], $container->getDefinition('serializer.normalizer.object')->getMethodCalls()[0]);
|
||||
$this->assertEquals(['setMaxDepthHandler', [new Reference('my.max.depth.handler')]], $container->getDefinition('serializer.normalizer.object')->getMethodCalls()[1]);
|
||||
}
|
||||
|
||||
public function testRegisterSerializerExtractor()
|
||||
|
@ -1079,7 +1079,7 @@ abstract class FrameworkExtensionTest extends TestCase
|
|||
$this->assertEquals('serializer.mapping.class_metadata_factory', $serializerExtractorDefinition->getArgument(0)->__toString());
|
||||
$this->assertFalse($serializerExtractorDefinition->isPublic());
|
||||
$tag = $serializerExtractorDefinition->getTag('property_info.list_extractor');
|
||||
$this->assertEquals(array('priority' => -999), $tag[0]);
|
||||
$this->assertEquals(['priority' => -999], $tag[0]);
|
||||
}
|
||||
|
||||
public function testDataUriNormalizerRegistered()
|
||||
|
@ -1153,25 +1153,25 @@ abstract class FrameworkExtensionTest extends TestCase
|
|||
|
||||
public function testSerializerCacheDisabled()
|
||||
{
|
||||
$container = $this->createContainerFromFile('serializer_enabled', array('kernel.debug' => true, 'kernel.container_class' => __CLASS__));
|
||||
$container = $this->createContainerFromFile('serializer_enabled', ['kernel.debug' => true, 'kernel.container_class' => __CLASS__]);
|
||||
$this->assertFalse($container->hasDefinition('serializer.mapping.cache_class_metadata_factory'));
|
||||
}
|
||||
|
||||
public function testSerializerMapping()
|
||||
{
|
||||
$container = $this->createContainerFromFile('serializer_mapping', array('kernel.bundles_metadata' => array('TestBundle' => array('namespace' => 'Symfony\\Bundle\\FrameworkBundle\\Tests', 'path' => __DIR__.'/Fixtures/TestBundle'))));
|
||||
$container = $this->createContainerFromFile('serializer_mapping', ['kernel.bundles_metadata' => ['TestBundle' => ['namespace' => 'Symfony\\Bundle\\FrameworkBundle\\Tests', 'path' => __DIR__.'/Fixtures/TestBundle']]]);
|
||||
$projectDir = $container->getParameter('kernel.project_dir');
|
||||
$configDir = __DIR__.'/Fixtures/TestBundle/Resources/config';
|
||||
$expectedLoaders = array(
|
||||
new Definition(AnnotationLoader::class, array(new Reference('annotation_reader'))),
|
||||
new Definition(XmlFileLoader::class, array($configDir.'/serialization.xml')),
|
||||
new Definition(YamlFileLoader::class, array($configDir.'/serialization.yml')),
|
||||
new Definition(YamlFileLoader::class, array($projectDir.'/config/serializer/foo.yml')),
|
||||
new Definition(XmlFileLoader::class, array($configDir.'/serializer_mapping/files/foo.xml')),
|
||||
new Definition(YamlFileLoader::class, array($configDir.'/serializer_mapping/files/foo.yml')),
|
||||
new Definition(YamlFileLoader::class, array($configDir.'/serializer_mapping/serialization.yml')),
|
||||
new Definition(YamlFileLoader::class, array($configDir.'/serializer_mapping/serialization.yaml')),
|
||||
);
|
||||
$expectedLoaders = [
|
||||
new Definition(AnnotationLoader::class, [new Reference('annotation_reader')]),
|
||||
new Definition(XmlFileLoader::class, [$configDir.'/serialization.xml']),
|
||||
new Definition(YamlFileLoader::class, [$configDir.'/serialization.yml']),
|
||||
new Definition(YamlFileLoader::class, [$projectDir.'/config/serializer/foo.yml']),
|
||||
new Definition(XmlFileLoader::class, [$configDir.'/serializer_mapping/files/foo.xml']),
|
||||
new Definition(YamlFileLoader::class, [$configDir.'/serializer_mapping/files/foo.yml']),
|
||||
new Definition(YamlFileLoader::class, [$configDir.'/serializer_mapping/serialization.yml']),
|
||||
new Definition(YamlFileLoader::class, [$configDir.'/serializer_mapping/serialization.yaml']),
|
||||
];
|
||||
|
||||
foreach ($expectedLoaders as $definition) {
|
||||
if (is_file($arg = $definition->getArgument(0))) {
|
||||
|
@ -1241,9 +1241,9 @@ abstract class FrameworkExtensionTest extends TestCase
|
|||
|
||||
public function testEventDispatcherService()
|
||||
{
|
||||
$container = $this->createContainer(array('kernel.charset' => 'UTF-8', 'kernel.secret' => 'secret'));
|
||||
$container = $this->createContainer(['kernel.charset' => 'UTF-8', 'kernel.secret' => 'secret']);
|
||||
$container->registerExtension(new FrameworkExtension());
|
||||
$container->getCompilerPassConfig()->setBeforeOptimizationPasses(array(new LoggerPass()));
|
||||
$container->getCompilerPassConfig()->setBeforeOptimizationPasses([new LoggerPass()]);
|
||||
$this->loadFromFile($container, 'default_config');
|
||||
$container
|
||||
->register('foo', \stdClass::class)
|
||||
|
@ -1294,18 +1294,18 @@ abstract class FrameworkExtensionTest extends TestCase
|
|||
|
||||
public function testRemovesResourceCheckerConfigCacheFactoryArgumentOnlyIfNoDebug()
|
||||
{
|
||||
$container = $this->createContainer(array('kernel.debug' => true));
|
||||
(new FrameworkExtension())->load(array(), $container);
|
||||
$container = $this->createContainer(['kernel.debug' => true]);
|
||||
(new FrameworkExtension())->load([], $container);
|
||||
$this->assertCount(1, $container->getDefinition('config_cache_factory')->getArguments());
|
||||
|
||||
$container = $this->createContainer(array('kernel.debug' => false));
|
||||
(new FrameworkExtension())->load(array(), $container);
|
||||
$container = $this->createContainer(['kernel.debug' => false]);
|
||||
(new FrameworkExtension())->load([], $container);
|
||||
$this->assertEmpty($container->getDefinition('config_cache_factory')->getArguments());
|
||||
}
|
||||
|
||||
public function testLoggerAwareRegistration()
|
||||
{
|
||||
$container = $this->createContainerFromFile('full', array(), true, false);
|
||||
$container = $this->createContainerFromFile('full', [], true, false);
|
||||
$container->addCompilerPass(new ResolveInstanceofConditionalsPass());
|
||||
$container->register('foo', LoggerAwareInterface::class)
|
||||
->setAutoconfigured(true);
|
||||
|
@ -1323,15 +1323,15 @@ abstract class FrameworkExtensionTest extends TestCase
|
|||
{
|
||||
$container = $this->createContainerFromFile('session_cookie_secure_auto');
|
||||
|
||||
$expected = array('session', 'initialized_session', 'session_storage', 'request_stack');
|
||||
$expected = ['session', 'initialized_session', 'session_storage', 'request_stack'];
|
||||
$this->assertEquals($expected, array_keys($container->getDefinition('session_listener')->getArgument(0)->getValues()));
|
||||
}
|
||||
|
||||
protected function createContainer(array $data = array())
|
||||
protected function createContainer(array $data = [])
|
||||
{
|
||||
return new ContainerBuilder(new ParameterBag(array_merge(array(
|
||||
'kernel.bundles' => array('FrameworkBundle' => 'Symfony\\Bundle\\FrameworkBundle\\FrameworkBundle'),
|
||||
'kernel.bundles_metadata' => array('FrameworkBundle' => array('namespace' => 'Symfony\\Bundle\\FrameworkBundle', 'path' => __DIR__.'/../..')),
|
||||
return new ContainerBuilder(new ParameterBag(array_merge([
|
||||
'kernel.bundles' => ['FrameworkBundle' => 'Symfony\\Bundle\\FrameworkBundle\\FrameworkBundle'],
|
||||
'kernel.bundles_metadata' => ['FrameworkBundle' => ['namespace' => 'Symfony\\Bundle\\FrameworkBundle', 'path' => __DIR__.'/../..']],
|
||||
'kernel.cache_dir' => __DIR__,
|
||||
'kernel.project_dir' => __DIR__,
|
||||
'kernel.debug' => false,
|
||||
|
@ -1342,10 +1342,10 @@ abstract class FrameworkExtensionTest extends TestCase
|
|||
'container.build_hash' => 'Abc1234',
|
||||
'container.build_id' => hash('crc32', 'Abc123423456789'),
|
||||
'container.build_time' => 23456789,
|
||||
), $data)));
|
||||
], $data)));
|
||||
}
|
||||
|
||||
protected function createContainerFromFile($file, $data = array(), $resetCompilerPasses = true, $compile = true)
|
||||
protected function createContainerFromFile($file, $data = [], $resetCompilerPasses = true, $compile = true)
|
||||
{
|
||||
$cacheKey = md5(\get_class($this).$file.serialize($data));
|
||||
if ($compile && isset(self::$containerCache[$cacheKey])) {
|
||||
|
@ -1356,12 +1356,12 @@ abstract class FrameworkExtensionTest extends TestCase
|
|||
$this->loadFromFile($container, $file);
|
||||
|
||||
if ($resetCompilerPasses) {
|
||||
$container->getCompilerPassConfig()->setOptimizationPasses(array());
|
||||
$container->getCompilerPassConfig()->setRemovingPasses(array());
|
||||
$container->getCompilerPassConfig()->setOptimizationPasses([]);
|
||||
$container->getCompilerPassConfig()->setRemovingPasses([]);
|
||||
}
|
||||
$container->getCompilerPassConfig()->setBeforeOptimizationPasses(array(new LoggerPass()));
|
||||
$container->getCompilerPassConfig()->setBeforeRemovingPasses(array(new AddConstraintValidatorsPass(), new TranslatorPass('translator.default', 'translation.reader')));
|
||||
$container->getCompilerPassConfig()->setAfterRemovingPasses(array(new AddAnnotationsCachedReaderPass()));
|
||||
$container->getCompilerPassConfig()->setBeforeOptimizationPasses([new LoggerPass()]);
|
||||
$container->getCompilerPassConfig()->setBeforeRemovingPasses([new AddConstraintValidatorsPass(), new TranslatorPass('translator.default', 'translation.reader')]);
|
||||
$container->getCompilerPassConfig()->setAfterRemovingPasses([new AddAnnotationsCachedReaderPass()]);
|
||||
|
||||
if (!$compile) {
|
||||
return $container;
|
||||
|
@ -1371,15 +1371,15 @@ abstract class FrameworkExtensionTest extends TestCase
|
|||
return self::$containerCache[$cacheKey] = $container;
|
||||
}
|
||||
|
||||
protected function createContainerFromClosure($closure, $data = array())
|
||||
protected function createContainerFromClosure($closure, $data = [])
|
||||
{
|
||||
$container = $this->createContainer($data);
|
||||
$container->registerExtension(new FrameworkExtension());
|
||||
$loader = new ClosureLoader($container);
|
||||
$loader->load($closure);
|
||||
|
||||
$container->getCompilerPassConfig()->setOptimizationPasses(array());
|
||||
$container->getCompilerPassConfig()->setRemovingPasses(array());
|
||||
$container->getCompilerPassConfig()->setOptimizationPasses([]);
|
||||
$container->getCompilerPassConfig()->setRemovingPasses([]);
|
||||
$container->compile();
|
||||
|
||||
return $container;
|
||||
|
|
|
@ -70,21 +70,21 @@ class ContainerDebugCommandTest extends WebTestCase
|
|||
*/
|
||||
public function testIgnoreBackslashWhenFindingService(string $validServiceId)
|
||||
{
|
||||
static::bootKernel(array('test_case' => 'ContainerDebug', 'root_config' => 'config.yml'));
|
||||
static::bootKernel(['test_case' => 'ContainerDebug', 'root_config' => 'config.yml']);
|
||||
|
||||
$application = new Application(static::$kernel);
|
||||
$application->setAutoExit(false);
|
||||
|
||||
$tester = new ApplicationTester($application);
|
||||
$tester->run(array('command' => 'debug:container', 'name' => $validServiceId));
|
||||
$tester->run(['command' => 'debug:container', 'name' => $validServiceId]);
|
||||
$this->assertNotContains('No services found', $tester->getDisplay());
|
||||
}
|
||||
|
||||
public function provideIgnoreBackslashWhenFindingService()
|
||||
{
|
||||
return array(
|
||||
array(BackslashClass::class),
|
||||
array('FixturesBackslashClass'),
|
||||
);
|
||||
return [
|
||||
[BackslashClass::class],
|
||||
['FixturesBackslashClass'],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,13 +49,13 @@ class DebugAutowiringCommandTest extends WebTestCase
|
|||
|
||||
public function testSearchIgnoreBackslashWhenFindingService()
|
||||
{
|
||||
static::bootKernel(array('test_case' => 'ContainerDebug', 'root_config' => 'config.yml'));
|
||||
static::bootKernel(['test_case' => 'ContainerDebug', 'root_config' => 'config.yml']);
|
||||
|
||||
$application = new Application(static::$kernel);
|
||||
$application->setAutoExit(false);
|
||||
|
||||
$tester = new ApplicationTester($application);
|
||||
$tester->run(array('command' => 'debug:autowiring', 'search' => 'HttpKernelHttpKernelInterface'));
|
||||
$tester->run(['command' => 'debug:autowiring', 'search' => 'HttpKernelHttpKernelInterface']);
|
||||
$this->assertContains('Symfony\Component\HttpKernel\HttpKernelInterface', $tester->getDisplay());
|
||||
}
|
||||
|
||||
|
|
|
@ -39,29 +39,29 @@ class DelegatingLoaderTest extends TestCase
|
|||
->willReturn($loader);
|
||||
|
||||
$routeCollection = new RouteCollection();
|
||||
$routeCollection->add('foo', new Route('/', array(), array(), array('utf8' => false)));
|
||||
$routeCollection->add('bar', new Route('/', array(), array(), array('foo' => 123)));
|
||||
$routeCollection->add('foo', new Route('/', [], [], ['utf8' => false]));
|
||||
$routeCollection->add('bar', new Route('/', [], [], ['foo' => 123]));
|
||||
|
||||
$loader->expects($this->once())
|
||||
->method('load')
|
||||
->willReturn($routeCollection);
|
||||
|
||||
$delegatingLoader = new DelegatingLoader($controllerNameParser, $loaderResolver, array('utf8' => true));
|
||||
$delegatingLoader = new DelegatingLoader($controllerNameParser, $loaderResolver, ['utf8' => true]);
|
||||
|
||||
$loadedRouteCollection = $delegatingLoader->load('foo');
|
||||
$this->assertCount(2, $loadedRouteCollection);
|
||||
|
||||
$expected = array(
|
||||
$expected = [
|
||||
'compiler_class' => 'Symfony\Component\Routing\RouteCompiler',
|
||||
'utf8' => false,
|
||||
);
|
||||
];
|
||||
$this->assertSame($expected, $routeCollection->get('foo')->getOptions());
|
||||
|
||||
$expected = array(
|
||||
$expected = [
|
||||
'compiler_class' => 'Symfony\Component\Routing\RouteCompiler',
|
||||
'foo' => 123,
|
||||
'utf8' => true,
|
||||
);
|
||||
];
|
||||
$this->assertSame($expected, $routeCollection->get('bar')->getOptions());
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ use Symfony\Contracts\Translation\TranslatorInterface;
|
|||
|
||||
class StubTranslator implements TranslatorInterface
|
||||
{
|
||||
public function trans($id, array $parameters = array(), $domain = null, $locale = null)
|
||||
public function trans($id, array $parameters = [], $domain = null, $locale = null)
|
||||
{
|
||||
return '[trans]'.$id.'[/trans]';
|
||||
}
|
||||
|
|
|
@ -35,19 +35,19 @@ class FormHelperDivLayoutTest extends AbstractDivLayoutTest
|
|||
$root = realpath(\dirname($reflClass->getFileName()).'/Resources/views');
|
||||
$rootTheme = realpath(__DIR__.'/Resources');
|
||||
$templateNameParser = new StubTemplateNameParser($root, $rootTheme);
|
||||
$loader = new FilesystemLoader(array());
|
||||
$loader = new FilesystemLoader([]);
|
||||
|
||||
$this->engine = new PhpEngine($templateNameParser, $loader);
|
||||
$this->engine->addGlobal('global', '');
|
||||
$this->engine->setHelpers(array(
|
||||
$this->engine->setHelpers([
|
||||
new TranslatorHelper(new StubTranslator()),
|
||||
));
|
||||
]);
|
||||
|
||||
return array_merge(parent::getExtensions(), array(
|
||||
new TemplatingExtension($this->engine, $this->csrfTokenManager, array(
|
||||
return array_merge(parent::getExtensions(), [
|
||||
new TemplatingExtension($this->engine, $this->csrfTokenManager, [
|
||||
'FrameworkBundle:Form',
|
||||
)),
|
||||
));
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
|
@ -59,10 +59,10 @@ class FormHelperDivLayoutTest extends AbstractDivLayoutTest
|
|||
|
||||
public function testStartTagHasNoActionAttributeWhenActionIsEmpty()
|
||||
{
|
||||
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array(
|
||||
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, [
|
||||
'method' => 'get',
|
||||
'action' => '',
|
||||
));
|
||||
]);
|
||||
|
||||
$html = $this->renderStart($form->createView());
|
||||
|
||||
|
@ -71,10 +71,10 @@ class FormHelperDivLayoutTest extends AbstractDivLayoutTest
|
|||
|
||||
public function testStartTagHasActionAttributeWhenActionIsZero()
|
||||
{
|
||||
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array(
|
||||
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, [
|
||||
'method' => 'get',
|
||||
'action' => '0',
|
||||
));
|
||||
]);
|
||||
|
||||
$html = $this->renderStart($form->createView());
|
||||
|
||||
|
@ -95,12 +95,12 @@ class FormHelperDivLayoutTest extends AbstractDivLayoutTest
|
|||
|
||||
public function testHelpAttr()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, array(
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [
|
||||
'help' => 'Help text test!',
|
||||
'help_attr' => array(
|
||||
'help_attr' => [
|
||||
'class' => 'class-test',
|
||||
),
|
||||
));
|
||||
],
|
||||
]);
|
||||
$view = $form->createView();
|
||||
$html = $this->renderHelp($view);
|
||||
|
||||
|
@ -113,12 +113,12 @@ class FormHelperDivLayoutTest extends AbstractDivLayoutTest
|
|||
);
|
||||
}
|
||||
|
||||
protected function renderForm(FormView $view, array $vars = array())
|
||||
protected function renderForm(FormView $view, array $vars = [])
|
||||
{
|
||||
return (string) $this->engine->get('form')->form($view, $vars);
|
||||
}
|
||||
|
||||
protected function renderLabel(FormView $view, $label = null, array $vars = array())
|
||||
protected function renderLabel(FormView $view, $label = null, array $vars = [])
|
||||
{
|
||||
return (string) $this->engine->get('form')->label($view, $label, $vars);
|
||||
}
|
||||
|
@ -133,27 +133,27 @@ class FormHelperDivLayoutTest extends AbstractDivLayoutTest
|
|||
return (string) $this->engine->get('form')->errors($view);
|
||||
}
|
||||
|
||||
protected function renderWidget(FormView $view, array $vars = array())
|
||||
protected function renderWidget(FormView $view, array $vars = [])
|
||||
{
|
||||
return (string) $this->engine->get('form')->widget($view, $vars);
|
||||
}
|
||||
|
||||
protected function renderRow(FormView $view, array $vars = array())
|
||||
protected function renderRow(FormView $view, array $vars = [])
|
||||
{
|
||||
return (string) $this->engine->get('form')->row($view, $vars);
|
||||
}
|
||||
|
||||
protected function renderRest(FormView $view, array $vars = array())
|
||||
protected function renderRest(FormView $view, array $vars = [])
|
||||
{
|
||||
return (string) $this->engine->get('form')->rest($view, $vars);
|
||||
}
|
||||
|
||||
protected function renderStart(FormView $view, array $vars = array())
|
||||
protected function renderStart(FormView $view, array $vars = [])
|
||||
{
|
||||
return (string) $this->engine->get('form')->start($view, $vars);
|
||||
}
|
||||
|
||||
protected function renderEnd(FormView $view, array $vars = array())
|
||||
protected function renderEnd(FormView $view, array $vars = [])
|
||||
{
|
||||
return (string) $this->engine->get('form')->end($view, $vars);
|
||||
}
|
||||
|
@ -165,15 +165,15 @@ class FormHelperDivLayoutTest extends AbstractDivLayoutTest
|
|||
|
||||
public static function themeBlockInheritanceProvider()
|
||||
{
|
||||
return array(
|
||||
array(array('TestBundle:Parent')),
|
||||
);
|
||||
return [
|
||||
[['TestBundle:Parent']],
|
||||
];
|
||||
}
|
||||
|
||||
public static function themeInheritanceProvider()
|
||||
{
|
||||
return array(
|
||||
array(array('TestBundle:Parent'), array('TestBundle:Child')),
|
||||
);
|
||||
return [
|
||||
[['TestBundle:Parent'], ['TestBundle:Child']],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,12 +53,12 @@ class FormHelperTableLayoutTest extends AbstractTableLayoutTest
|
|||
|
||||
public function testHelpAttr()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, array(
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [
|
||||
'help' => 'Help text test!',
|
||||
'help_attr' => array(
|
||||
'help_attr' => [
|
||||
'class' => 'class-test',
|
||||
),
|
||||
));
|
||||
],
|
||||
]);
|
||||
$view = $form->createView();
|
||||
$html = $this->renderHelp($view);
|
||||
|
||||
|
|
|
@ -52,10 +52,10 @@ class TranslatorTest extends TestCase
|
|||
$this->assertEquals('foo (FR)', $translator->trans('foo'));
|
||||
$this->assertEquals('bar (EN)', $translator->trans('bar'));
|
||||
$this->assertEquals('foobar (ES)', $translator->trans('foobar'));
|
||||
$this->assertEquals('choice 0 (EN)', $translator->trans('choice', array('%count%' => 0)));
|
||||
$this->assertEquals('choice 0 (EN)', $translator->trans('choice', ['%count%' => 0]));
|
||||
$this->assertEquals('no translation', $translator->trans('no translation'));
|
||||
$this->assertEquals('foobarfoo (PT-PT)', $translator->trans('foobarfoo'));
|
||||
$this->assertEquals('other choice 1 (PT-BR)', $translator->trans('other choice', array('%count%' => 1)));
|
||||
$this->assertEquals('other choice 1 (PT-BR)', $translator->trans('other choice', ['%count%' => 1]));
|
||||
$this->assertEquals('foobarbaz (fr.UTF-8)', $translator->trans('foobarbaz'));
|
||||
$this->assertEquals('foobarbax (sr@latin)', $translator->trans('foobarbax'));
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ class TranslatorTest extends TestCase
|
|||
{
|
||||
$translator = $this->getTranslator($this->getLoader());
|
||||
$translator->setLocale('fr');
|
||||
$translator->setFallbackLocales(array('en', 'es', 'pt-PT', 'pt_BR', 'fr.UTF-8', 'sr@latin'));
|
||||
$translator->setFallbackLocales(['en', 'es', 'pt-PT', 'pt_BR', 'fr.UTF-8', 'sr@latin']);
|
||||
|
||||
$this->assertEquals('choice 0 (EN)', $translator->transChoice('choice', 0));
|
||||
$this->assertEquals('other choice 1 (PT-BR)', $translator->transChoice('other choice', 1));
|
||||
|
@ -83,10 +83,10 @@ class TranslatorTest extends TestCase
|
|||
$this->assertEquals('foo (FR)', $translator->trans('foo'));
|
||||
$this->assertEquals('bar (EN)', $translator->trans('bar'));
|
||||
$this->assertEquals('foobar (ES)', $translator->trans('foobar'));
|
||||
$this->assertEquals('choice 0 (EN)', $translator->trans('choice', array('%count%' => 0)));
|
||||
$this->assertEquals('choice 0 (EN)', $translator->trans('choice', ['%count%' => 0]));
|
||||
$this->assertEquals('no translation', $translator->trans('no translation'));
|
||||
$this->assertEquals('foobarfoo (PT-PT)', $translator->trans('foobarfoo'));
|
||||
$this->assertEquals('other choice 1 (PT-BR)', $translator->trans('other choice', array('%count%' => 1)));
|
||||
$this->assertEquals('other choice 1 (PT-BR)', $translator->trans('other choice', ['%count%' => 1]));
|
||||
$this->assertEquals('foobarbaz (fr.UTF-8)', $translator->trans('foobarbaz'));
|
||||
$this->assertEquals('foobarbax (sr@latin)', $translator->trans('foobarbax'));
|
||||
|
||||
|
@ -113,9 +113,9 @@ class TranslatorTest extends TestCase
|
|||
public function testTransChoiceWithCaching()
|
||||
{
|
||||
// prime the cache
|
||||
$translator = $this->getTranslator($this->getLoader(), array('cache_dir' => $this->tmpDir));
|
||||
$translator = $this->getTranslator($this->getLoader(), ['cache_dir' => $this->tmpDir]);
|
||||
$translator->setLocale('fr');
|
||||
$translator->setFallbackLocales(array('en', 'es', 'pt-PT', 'pt_BR', 'fr.UTF-8', 'sr@latin'));
|
||||
$translator->setFallbackLocales(['en', 'es', 'pt-PT', 'pt_BR', 'fr.UTF-8', 'sr@latin']);
|
||||
|
||||
$this->assertEquals('choice 0 (EN)', $translator->transChoice('choice', 0));
|
||||
$this->assertEquals('other choice 1 (PT-BR)', $translator->transChoice('other choice', 1));
|
||||
|
@ -124,9 +124,9 @@ class TranslatorTest extends TestCase
|
|||
$loader = $this->getMockBuilder('Symfony\Component\Translation\Loader\LoaderInterface')->getMock();
|
||||
$loader->expects($this->never())->method('load');
|
||||
|
||||
$translator = $this->getTranslator($loader, array('cache_dir' => $this->tmpDir));
|
||||
$translator = $this->getTranslator($loader, ['cache_dir' => $this->tmpDir]);
|
||||
$translator->setLocale('fr');
|
||||
$translator->setFallbackLocales(array('en', 'es', 'pt-PT', 'pt_BR', 'fr.UTF-8', 'sr@latin'));
|
||||
$translator->setFallbackLocales(['en', 'es', 'pt-PT', 'pt_BR', 'fr.UTF-8', 'sr@latin']);
|
||||
|
||||
$this->assertEquals('choice 0 (EN)', $translator->transChoice('choice', 0));
|
||||
$this->assertEquals('other choice 1 (PT-BR)', $translator->transChoice('other choice', 1));
|
||||
|
|
|
@ -150,15 +150,15 @@ class SecurityDataCollector extends DataCollector implements LateDataCollectorIn
|
|||
// collect voter details
|
||||
$decisionLog = $this->accessDecisionManager->getDecisionLog();
|
||||
foreach ($decisionLog as $key => $log) {
|
||||
$decisionLog[$key]['voter_details'] = array();
|
||||
$decisionLog[$key]['voter_details'] = [];
|
||||
foreach ($log['voterDetails'] as $voterDetail) {
|
||||
$voterClass = \get_class($voterDetail['voter']);
|
||||
$classData = $this->hasVarDumper ? new ClassStub($voterClass) : $voterClass;
|
||||
$decisionLog[$key]['voter_details'][] = array(
|
||||
$decisionLog[$key]['voter_details'][] = [
|
||||
'class' => $classData,
|
||||
'attributes' => $voterDetail['attributes'], // Only displayed for unanimous strategy
|
||||
'vote' => $voterDetail['vote'],
|
||||
);
|
||||
];
|
||||
}
|
||||
unset($decisionLog[$key]['voterDetails']);
|
||||
}
|
||||
|
|
|
@ -67,10 +67,10 @@ final class WrappedListener implements ListenerInterface
|
|||
$this->stub = self::$hasVarDumper ? new ClassStub(\get_class($this->listener)) : \get_class($this->listener);
|
||||
}
|
||||
|
||||
return array(
|
||||
return [
|
||||
'response' => $this->response,
|
||||
'time' => $this->time,
|
||||
'stub' => $this->stub,
|
||||
);
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ class AddExpressionLanguageProvidersPass implements CompilerPassInterface
|
|||
if ($container->has('security.expression_language')) {
|
||||
$definition = $container->findDefinition('security.expression_language');
|
||||
foreach ($container->findTaggedServiceIds('security.expression_language_provider', true) as $id => $attributes) {
|
||||
$definition->addMethodCall('registerProvider', array(new Reference($id)));
|
||||
$definition->addMethodCall('registerProvider', [new Reference($id)]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ class AddSecurityVotersPass implements CompilerPassInterface
|
|||
}
|
||||
|
||||
$debug = $container->getParameter('kernel.debug');
|
||||
$voterServices = array();
|
||||
$voterServices = [];
|
||||
foreach ($voters as $voter) {
|
||||
$voterServiceId = (string) $voter;
|
||||
$definition = $container->getDefinition($voterServiceId);
|
||||
|
|
|
@ -39,7 +39,7 @@ class JsonLoginLdapFactory extends JsonLoginFactory
|
|||
;
|
||||
|
||||
if (!empty($config['query_string'])) {
|
||||
$definition->addMethodCall('setQueryString', array($config['query_string']));
|
||||
$definition->addMethodCall('setQueryString', [$config['query_string']]);
|
||||
}
|
||||
|
||||
return $provider;
|
||||
|
|
|
@ -142,9 +142,9 @@ class RememberMeFactory implements SecurityFactoryInterface
|
|||
|
||||
foreach ($this->options as $name => $value) {
|
||||
if ('secure' === $name) {
|
||||
$builder->enumNode($name)->values(array(true, false, 'auto'))->defaultValue('auto' === $value ? null : $value);
|
||||
$builder->enumNode($name)->values([true, false, 'auto'])->defaultValue('auto' === $value ? null : $value);
|
||||
} elseif ('samesite' === $name) {
|
||||
$builder->enumNode($name)->values(array(null, Cookie::SAMESITE_LAX, Cookie::SAMESITE_STRICT))->defaultValue($value);
|
||||
$builder->enumNode($name)->values([null, Cookie::SAMESITE_LAX, Cookie::SAMESITE_STRICT])->defaultValue($value);
|
||||
} elseif (\is_bool($value)) {
|
||||
$builder->booleanNode($name)->defaultValue($value);
|
||||
} else {
|
||||
|
|
|
@ -41,18 +41,18 @@ use Symfony\Component\Security\Http\Controller\UserValueResolver;
|
|||
*/
|
||||
class SecurityExtension extends Extension implements PrependExtensionInterface
|
||||
{
|
||||
private $requestMatchers = array();
|
||||
private $expressions = array();
|
||||
private $contextListeners = array();
|
||||
private $listenerPositions = array('pre_auth', 'form', 'http', 'remember_me');
|
||||
private $factories = array();
|
||||
private $userProviderFactories = array();
|
||||
private $statelessFirewallKeys = array();
|
||||
private $requestMatchers = [];
|
||||
private $expressions = [];
|
||||
private $contextListeners = [];
|
||||
private $listenerPositions = ['pre_auth', 'form', 'http', 'remember_me'];
|
||||
private $factories = [];
|
||||
private $userProviderFactories = [];
|
||||
private $statelessFirewallKeys = [];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
foreach ($this->listenerPositions as $position) {
|
||||
$this->factories[$position] = array();
|
||||
$this->factories[$position] = [];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -183,7 +183,7 @@ class SecurityExtension extends Extension implements PrependExtensionInterface
|
|||
}
|
||||
|
||||
$container->getDefinition('security.access_map')
|
||||
->addMethodCall('add', array($matcher, $attributes, $access['requires_channel']));
|
||||
->addMethodCall('add', [$matcher, $attributes, $access['requires_channel']]);
|
||||
}
|
||||
|
||||
// allow cache warm-up for expressions
|
||||
|
@ -207,7 +207,7 @@ class SecurityExtension extends Extension implements PrependExtensionInterface
|
|||
// make the ContextListener aware of the configured user providers
|
||||
$contextListenerDefinition = $container->getDefinition('security.context_listener');
|
||||
$arguments = $contextListenerDefinition->getArguments();
|
||||
$userProviders = array();
|
||||
$userProviders = [];
|
||||
foreach ($providerIds as $userProviderId) {
|
||||
$userProviders[] = new Reference($userProviderId);
|
||||
}
|
||||
|
@ -222,7 +222,7 @@ class SecurityExtension extends Extension implements PrependExtensionInterface
|
|||
|
||||
// load firewall map
|
||||
$mapDef = $container->getDefinition('security.firewall.map');
|
||||
$map = $authenticationProviders = $contextRefs = array();
|
||||
$map = $authenticationProviders = $contextRefs = [];
|
||||
foreach ($firewalls as $name => $firewall) {
|
||||
if (isset($firewall['user_checker']) && 'security.user_checker' !== $firewall['user_checker']) {
|
||||
$customUserChecker = true;
|
||||
|
@ -275,7 +275,7 @@ class SecurityExtension extends Extension implements PrependExtensionInterface
|
|||
} elseif (isset($firewall['pattern']) || isset($firewall['host'])) {
|
||||
$pattern = isset($firewall['pattern']) ? $firewall['pattern'] : null;
|
||||
$host = isset($firewall['host']) ? $firewall['host'] : null;
|
||||
$methods = isset($firewall['methods']) ? $firewall['methods'] : array();
|
||||
$methods = isset($firewall['methods']) ? $firewall['methods'] : [];
|
||||
$matcher = $this->createRequestMatcher($container, $pattern, $host, null, $methods);
|
||||
}
|
||||
|
||||
|
@ -284,7 +284,7 @@ class SecurityExtension extends Extension implements PrependExtensionInterface
|
|||
|
||||
// Security disabled?
|
||||
if (false === $firewall['security']) {
|
||||
return array($matcher, array(), null, null);
|
||||
return [$matcher, [], null, null];
|
||||
}
|
||||
|
||||
$config->replaceArgument(4, $firewall['stateless']);
|
||||
|
@ -303,8 +303,8 @@ class SecurityExtension extends Extension implements PrependExtensionInterface
|
|||
$config->replaceArgument(5, $defaultProvider);
|
||||
|
||||
// Register listeners
|
||||
$listeners = array();
|
||||
$listenerKeys = array();
|
||||
$listeners = [];
|
||||
$listenerKeys = [];
|
||||
|
||||
// Channel listener
|
||||
$listeners[] = new Reference('security.channel_listener');
|
||||
|
@ -328,11 +328,11 @@ class SecurityExtension extends Extension implements PrependExtensionInterface
|
|||
if (isset($firewall['logout'])) {
|
||||
$logoutListenerId = 'security.logout_listener.'.$id;
|
||||
$logoutListener = $container->setDefinition($logoutListenerId, new ChildDefinition('security.logout_listener'));
|
||||
$logoutListener->replaceArgument(3, array(
|
||||
$logoutListener->replaceArgument(3, [
|
||||
'csrf_parameter' => $firewall['logout']['csrf_parameter'],
|
||||
'csrf_token_id' => $firewall['logout']['csrf_token_id'],
|
||||
'logout_path' => $firewall['logout']['path'],
|
||||
));
|
||||
]);
|
||||
|
||||
// add logout success handler
|
||||
if (isset($firewall['logout']['success_handler'])) {
|
||||
|
@ -351,7 +351,7 @@ class SecurityExtension extends Extension implements PrependExtensionInterface
|
|||
|
||||
// add session logout handler
|
||||
if (true === $firewall['logout']['invalidate_session'] && false === $firewall['stateless']) {
|
||||
$logoutListener->addMethodCall('addHandler', array(new Reference('security.logout.handler.session')));
|
||||
$logoutListener->addMethodCall('addHandler', [new Reference('security.logout.handler.session')]);
|
||||
}
|
||||
|
||||
// add cookie logout handler
|
||||
|
@ -360,25 +360,25 @@ class SecurityExtension extends Extension implements PrependExtensionInterface
|
|||
$cookieHandler = $container->setDefinition($cookieHandlerId, new ChildDefinition('security.logout.handler.cookie_clearing'));
|
||||
$cookieHandler->addArgument($firewall['logout']['delete_cookies']);
|
||||
|
||||
$logoutListener->addMethodCall('addHandler', array(new Reference($cookieHandlerId)));
|
||||
$logoutListener->addMethodCall('addHandler', [new Reference($cookieHandlerId)]);
|
||||
}
|
||||
|
||||
// add custom handlers
|
||||
foreach ($firewall['logout']['handlers'] as $handlerId) {
|
||||
$logoutListener->addMethodCall('addHandler', array(new Reference($handlerId)));
|
||||
$logoutListener->addMethodCall('addHandler', [new Reference($handlerId)]);
|
||||
}
|
||||
|
||||
// register with LogoutUrlGenerator
|
||||
$container
|
||||
->getDefinition('security.logout_url_generator')
|
||||
->addMethodCall('registerListener', array(
|
||||
->addMethodCall('registerListener', [
|
||||
$id,
|
||||
$firewall['logout']['path'],
|
||||
$firewall['logout']['csrf_token_id'],
|
||||
$firewall['logout']['csrf_parameter'],
|
||||
isset($firewall['logout']['csrf_token_generator']) ? new Reference($firewall['logout']['csrf_token_generator']) : null,
|
||||
false === $firewall['stateless'] && isset($firewall['context']) ? $firewall['context'] : null,
|
||||
))
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
|
@ -425,7 +425,7 @@ class SecurityExtension extends Extension implements PrependExtensionInterface
|
|||
$config->replaceArgument(10, $listenerKeys);
|
||||
$config->replaceArgument(11, isset($firewall['switch_user']) ? $firewall['switch_user'] : null);
|
||||
|
||||
return array($matcher, $listeners, $exceptionListener, null !== $logoutListenerId ? new Reference($logoutListenerId) : null);
|
||||
return [$matcher, $listeners, $exceptionListener, null !== $logoutListenerId ? new Reference($logoutListenerId) : null];
|
||||
}
|
||||
|
||||
private function createContextListener($container, $contextKey)
|
||||
|
@ -443,7 +443,7 @@ class SecurityExtension extends Extension implements PrependExtensionInterface
|
|||
|
||||
private function createAuthenticationListeners($container, $id, $firewall, &$authenticationProviders, $defaultProvider = null, array $providerIds, $defaultEntryPoint)
|
||||
{
|
||||
$listeners = array();
|
||||
$listeners = [];
|
||||
$hasListeners = false;
|
||||
|
||||
foreach ($this->listenerPositions as $position) {
|
||||
|
@ -505,19 +505,19 @@ class SecurityExtension extends Extension implements PrependExtensionInterface
|
|||
throw new InvalidConfigurationException(sprintf('No authentication listener registered for firewall "%s".', $id));
|
||||
}
|
||||
|
||||
return array($listeners, $defaultEntryPoint);
|
||||
return [$listeners, $defaultEntryPoint];
|
||||
}
|
||||
|
||||
private function createEncoders($encoders, ContainerBuilder $container)
|
||||
{
|
||||
$encoderMap = array();
|
||||
$encoderMap = [];
|
||||
foreach ($encoders as $class => $encoder) {
|
||||
$encoderMap[$class] = $this->createEncoder($encoder, $container);
|
||||
}
|
||||
|
||||
$container
|
||||
->getDefinition('security.encoder_factory.generic')
|
||||
->setArguments(array($encoderMap))
|
||||
->setArguments([$encoderMap])
|
||||
;
|
||||
}
|
||||
|
||||
|
@ -530,33 +530,33 @@ class SecurityExtension extends Extension implements PrependExtensionInterface
|
|||
|
||||
// plaintext encoder
|
||||
if ('plaintext' === $config['algorithm']) {
|
||||
$arguments = array($config['ignore_case']);
|
||||
$arguments = [$config['ignore_case']];
|
||||
|
||||
return array(
|
||||
return [
|
||||
'class' => 'Symfony\Component\Security\Core\Encoder\PlaintextPasswordEncoder',
|
||||
'arguments' => $arguments,
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
// pbkdf2 encoder
|
||||
if ('pbkdf2' === $config['algorithm']) {
|
||||
return array(
|
||||
return [
|
||||
'class' => 'Symfony\Component\Security\Core\Encoder\Pbkdf2PasswordEncoder',
|
||||
'arguments' => array(
|
||||
'arguments' => [
|
||||
$config['hash_algorithm'],
|
||||
$config['encode_as_base64'],
|
||||
$config['iterations'],
|
||||
$config['key_length'],
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
// bcrypt encoder
|
||||
if ('bcrypt' === $config['algorithm']) {
|
||||
return array(
|
||||
return [
|
||||
'class' => 'Symfony\Component\Security\Core\Encoder\BCryptPasswordEncoder',
|
||||
'arguments' => array($config['cost']),
|
||||
);
|
||||
'arguments' => [$config['cost']],
|
||||
];
|
||||
}
|
||||
|
||||
// Argon2i encoder
|
||||
|
@ -569,14 +569,14 @@ class SecurityExtension extends Extension implements PrependExtensionInterface
|
|||
throw new InvalidConfigurationException('Argon2i algorithm is not supported. Install the libsodium extension or use BCrypt instead.');
|
||||
}
|
||||
|
||||
return array(
|
||||
return [
|
||||
'class' => 'Symfony\Component\Security\Core\Encoder\Argon2iPasswordEncoder',
|
||||
'arguments' => array(
|
||||
'arguments' => [
|
||||
$config['memory_cost'],
|
||||
$config['time_cost'],
|
||||
$config['threads'],
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
// run-time configured encoder
|
||||
|
@ -586,7 +586,7 @@ class SecurityExtension extends Extension implements PrependExtensionInterface
|
|||
// Parses user providers and returns an array of their ids
|
||||
private function createUserProviders($config, ContainerBuilder $container)
|
||||
{
|
||||
$providerIds = array();
|
||||
$providerIds = [];
|
||||
foreach ($config['providers'] as $name => $provider) {
|
||||
$id = $this->createUserDaoProvider($name, $provider, $container);
|
||||
$providerIds[str_replace('-', '_', $name)] = $id;
|
||||
|
@ -620,7 +620,7 @@ class SecurityExtension extends Extension implements PrependExtensionInterface
|
|||
|
||||
// Chain provider
|
||||
if (isset($provider['chain'])) {
|
||||
$providers = array();
|
||||
$providers = [];
|
||||
foreach ($provider['chain']['providers'] as $providerName) {
|
||||
$providers[] = new Reference($this->getUserProviderId($providerName));
|
||||
}
|
||||
|
@ -697,20 +697,20 @@ class SecurityExtension extends Extension implements PrependExtensionInterface
|
|||
return $this->expressions[$id] = new Reference($id);
|
||||
}
|
||||
|
||||
private function createRequestMatcher($container, $path = null, $host = null, int $port = null, $methods = array(), $ip = null, array $attributes = array())
|
||||
private function createRequestMatcher($container, $path = null, $host = null, int $port = null, $methods = [], $ip = null, array $attributes = [])
|
||||
{
|
||||
if ($methods) {
|
||||
$methods = array_map('strtoupper', (array) $methods);
|
||||
}
|
||||
|
||||
$id = '.security.request_matcher.'.ContainerBuilder::hash(array($path, $host, $port, $methods, $ip, $attributes));
|
||||
$id = '.security.request_matcher.'.ContainerBuilder::hash([$path, $host, $port, $methods, $ip, $attributes]);
|
||||
|
||||
if (isset($this->requestMatchers[$id])) {
|
||||
return $this->requestMatchers[$id];
|
||||
}
|
||||
|
||||
// only add arguments that are necessary
|
||||
$arguments = array($path, $host, $methods, $ip, $attributes, null, $port);
|
||||
$arguments = [$path, $host, $methods, $ip, $attributes, null, $port];
|
||||
while (\count($arguments) > 0 && !end($arguments)) {
|
||||
array_pop($arguments);
|
||||
}
|
||||
|
|
|
@ -43,6 +43,6 @@ class VoteListener implements EventSubscriberInterface
|
|||
|
||||
public static function getSubscribedEvents()
|
||||
{
|
||||
return array('debug.security.authorization.vote' => 'onVoterVote');
|
||||
return ['debug.security.authorization.vote' => 'onVoterVote'];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -97,12 +97,12 @@ class SecurityDataCollectorTest extends TestCase
|
|||
|
||||
public function testCollectImpersonatedToken()
|
||||
{
|
||||
$adminToken = new UsernamePasswordToken('yceruto', 'P4$$w0rD', 'provider', array('ROLE_ADMIN'));
|
||||
$adminToken = new UsernamePasswordToken('yceruto', 'P4$$w0rD', 'provider', ['ROLE_ADMIN']);
|
||||
|
||||
$userRoles = array(
|
||||
$userRoles = [
|
||||
'ROLE_USER',
|
||||
new SwitchUserRole('ROLE_PREVIOUS_ADMIN', $adminToken),
|
||||
);
|
||||
];
|
||||
|
||||
$tokenStorage = new TokenStorage();
|
||||
$tokenStorage->setToken(new UsernamePasswordToken('hhamon', 'P4$$w0rD', 'provider', $userRoles));
|
||||
|
@ -117,8 +117,8 @@ class SecurityDataCollectorTest extends TestCase
|
|||
$this->assertSame('yceruto', $collector->getImpersonatorUser());
|
||||
$this->assertSame('Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken', $collector->getTokenClass()->getValue());
|
||||
$this->assertTrue($collector->supportsRoleHierarchy());
|
||||
$this->assertSame(array('ROLE_USER', 'ROLE_PREVIOUS_ADMIN'), $collector->getRoles()->getValue(true));
|
||||
$this->assertSame(array(), $collector->getInheritedRoles()->getValue(true));
|
||||
$this->assertSame(['ROLE_USER', 'ROLE_PREVIOUS_ADMIN'], $collector->getRoles()->getValue(true));
|
||||
$this->assertSame([], $collector->getInheritedRoles()->getValue(true));
|
||||
$this->assertSame('hhamon', $collector->getUser());
|
||||
}
|
||||
|
||||
|
@ -213,7 +213,7 @@ class SecurityDataCollectorTest extends TestCase
|
|||
->expects($this->once())
|
||||
->method('getListeners')
|
||||
->with($request)
|
||||
->willReturn(array(array($listener), null, null));
|
||||
->willReturn([[$listener], null, null]);
|
||||
|
||||
$firewall = new TraceableFirewallListener($firewallMap, new EventDispatcher(), new LogoutUrlGenerator());
|
||||
$firewall->onKernelRequest($event);
|
||||
|
@ -235,79 +235,79 @@ class SecurityDataCollectorTest extends TestCase
|
|||
$decoratedVoter1 = new TraceableVoter($voter1, $eventDispatcher);
|
||||
$decoratedVoter2 = new TraceableVoter($voter2, $eventDispatcher);
|
||||
|
||||
yield array(
|
||||
yield [
|
||||
AccessDecisionManager::STRATEGY_AFFIRMATIVE,
|
||||
array(array(
|
||||
'attributes' => array('view'),
|
||||
[[
|
||||
'attributes' => ['view'],
|
||||
'object' => new \stdClass(),
|
||||
'result' => true,
|
||||
'voterDetails' => array(
|
||||
array('voter' => $voter1, 'attributes' => array('view'), 'vote' => VoterInterface::ACCESS_ABSTAIN),
|
||||
array('voter' => $voter2, 'attributes' => array('view'), 'vote' => VoterInterface::ACCESS_ABSTAIN),
|
||||
),
|
||||
)),
|
||||
array($decoratedVoter1, $decoratedVoter1),
|
||||
array(\get_class($voter1), \get_class($voter2)),
|
||||
array(array(
|
||||
'attributes' => array('view'),
|
||||
'voterDetails' => [
|
||||
['voter' => $voter1, 'attributes' => ['view'], 'vote' => VoterInterface::ACCESS_ABSTAIN],
|
||||
['voter' => $voter2, 'attributes' => ['view'], 'vote' => VoterInterface::ACCESS_ABSTAIN],
|
||||
],
|
||||
]],
|
||||
[$decoratedVoter1, $decoratedVoter1],
|
||||
[\get_class($voter1), \get_class($voter2)],
|
||||
[[
|
||||
'attributes' => ['view'],
|
||||
'object' => new \stdClass(),
|
||||
'result' => true,
|
||||
'voter_details' => array(
|
||||
array('class' => \get_class($voter1), 'attributes' => array('view'), 'vote' => VoterInterface::ACCESS_ABSTAIN),
|
||||
array('class' => \get_class($voter2), 'attributes' => array('view'), 'vote' => VoterInterface::ACCESS_ABSTAIN),
|
||||
),
|
||||
)),
|
||||
);
|
||||
'voter_details' => [
|
||||
['class' => \get_class($voter1), 'attributes' => ['view'], 'vote' => VoterInterface::ACCESS_ABSTAIN],
|
||||
['class' => \get_class($voter2), 'attributes' => ['view'], 'vote' => VoterInterface::ACCESS_ABSTAIN],
|
||||
],
|
||||
]],
|
||||
];
|
||||
|
||||
yield array(
|
||||
yield [
|
||||
AccessDecisionManager::STRATEGY_UNANIMOUS,
|
||||
array(
|
||||
array(
|
||||
'attributes' => array('view', 'edit'),
|
||||
[
|
||||
[
|
||||
'attributes' => ['view', 'edit'],
|
||||
'object' => new \stdClass(),
|
||||
'result' => false,
|
||||
'voterDetails' => array(
|
||||
array('voter' => $voter1, 'attributes' => array('view'), 'vote' => VoterInterface::ACCESS_DENIED),
|
||||
array('voter' => $voter1, 'attributes' => array('edit'), 'vote' => VoterInterface::ACCESS_DENIED),
|
||||
array('voter' => $voter2, 'attributes' => array('view'), 'vote' => VoterInterface::ACCESS_GRANTED),
|
||||
array('voter' => $voter2, 'attributes' => array('edit'), 'vote' => VoterInterface::ACCESS_GRANTED),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'attributes' => array('update'),
|
||||
'voterDetails' => [
|
||||
['voter' => $voter1, 'attributes' => ['view'], 'vote' => VoterInterface::ACCESS_DENIED],
|
||||
['voter' => $voter1, 'attributes' => ['edit'], 'vote' => VoterInterface::ACCESS_DENIED],
|
||||
['voter' => $voter2, 'attributes' => ['view'], 'vote' => VoterInterface::ACCESS_GRANTED],
|
||||
['voter' => $voter2, 'attributes' => ['edit'], 'vote' => VoterInterface::ACCESS_GRANTED],
|
||||
],
|
||||
],
|
||||
[
|
||||
'attributes' => ['update'],
|
||||
'object' => new \stdClass(),
|
||||
'result' => true,
|
||||
'voterDetails' => array(
|
||||
array('voter' => $voter1, 'attributes' => array('update'), 'vote' => VoterInterface::ACCESS_GRANTED),
|
||||
array('voter' => $voter2, 'attributes' => array('update'), 'vote' => VoterInterface::ACCESS_GRANTED),
|
||||
),
|
||||
),
|
||||
),
|
||||
array($decoratedVoter1, $decoratedVoter1),
|
||||
array(\get_class($voter1), \get_class($voter2)),
|
||||
array(
|
||||
array(
|
||||
'attributes' => array('view', 'edit'),
|
||||
'voterDetails' => [
|
||||
['voter' => $voter1, 'attributes' => ['update'], 'vote' => VoterInterface::ACCESS_GRANTED],
|
||||
['voter' => $voter2, 'attributes' => ['update'], 'vote' => VoterInterface::ACCESS_GRANTED],
|
||||
],
|
||||
],
|
||||
],
|
||||
[$decoratedVoter1, $decoratedVoter1],
|
||||
[\get_class($voter1), \get_class($voter2)],
|
||||
[
|
||||
[
|
||||
'attributes' => ['view', 'edit'],
|
||||
'object' => new \stdClass(),
|
||||
'result' => false,
|
||||
'voter_details' => array(
|
||||
array('class' => \get_class($voter1), 'attributes' => array('view'), 'vote' => VoterInterface::ACCESS_DENIED),
|
||||
array('class' => \get_class($voter1), 'attributes' => array('edit'), 'vote' => VoterInterface::ACCESS_DENIED),
|
||||
array('class' => \get_class($voter2), 'attributes' => array('view'), 'vote' => VoterInterface::ACCESS_GRANTED),
|
||||
array('class' => \get_class($voter2), 'attributes' => array('edit'), 'vote' => VoterInterface::ACCESS_GRANTED),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'attributes' => array('update'),
|
||||
'voter_details' => [
|
||||
['class' => \get_class($voter1), 'attributes' => ['view'], 'vote' => VoterInterface::ACCESS_DENIED],
|
||||
['class' => \get_class($voter1), 'attributes' => ['edit'], 'vote' => VoterInterface::ACCESS_DENIED],
|
||||
['class' => \get_class($voter2), 'attributes' => ['view'], 'vote' => VoterInterface::ACCESS_GRANTED],
|
||||
['class' => \get_class($voter2), 'attributes' => ['edit'], 'vote' => VoterInterface::ACCESS_GRANTED],
|
||||
],
|
||||
],
|
||||
[
|
||||
'attributes' => ['update'],
|
||||
'object' => new \stdClass(),
|
||||
'result' => true,
|
||||
'voter_details' => array(
|
||||
array('class' => \get_class($voter1), 'attributes' => array('update'), 'vote' => VoterInterface::ACCESS_GRANTED),
|
||||
array('class' => \get_class($voter2), 'attributes' => array('update'), 'vote' => VoterInterface::ACCESS_GRANTED),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
'voter_details' => [
|
||||
['class' => \get_class($voter1), 'attributes' => ['update'], 'vote' => VoterInterface::ACCESS_GRANTED],
|
||||
['class' => \get_class($voter2), 'attributes' => ['update'], 'vote' => VoterInterface::ACCESS_GRANTED],
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -326,7 +326,7 @@ class SecurityDataCollectorTest extends TestCase
|
|||
$accessDecisionManager = $this
|
||||
->getMockBuilder(TraceableAccessDecisionManager::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(array('getStrategy', 'getVoters', 'getDecisionLog'))
|
||||
->setMethods(['getStrategy', 'getVoters', 'getDecisionLog'])
|
||||
->getMock();
|
||||
|
||||
$accessDecisionManager
|
||||
|
@ -359,43 +359,43 @@ class SecurityDataCollectorTest extends TestCase
|
|||
|
||||
public function provideRoles()
|
||||
{
|
||||
return array(
|
||||
return [
|
||||
// Basic roles
|
||||
array(
|
||||
array('ROLE_USER'),
|
||||
array('ROLE_USER'),
|
||||
array(),
|
||||
),
|
||||
array(
|
||||
array(new Role('ROLE_USER')),
|
||||
array('ROLE_USER'),
|
||||
array(),
|
||||
),
|
||||
[
|
||||
['ROLE_USER'],
|
||||
['ROLE_USER'],
|
||||
[],
|
||||
],
|
||||
[
|
||||
[new Role('ROLE_USER')],
|
||||
['ROLE_USER'],
|
||||
[],
|
||||
],
|
||||
// Inherited roles
|
||||
array(
|
||||
array('ROLE_ADMIN'),
|
||||
array('ROLE_ADMIN'),
|
||||
array('ROLE_USER', 'ROLE_ALLOWED_TO_SWITCH'),
|
||||
),
|
||||
array(
|
||||
array(new Role('ROLE_ADMIN')),
|
||||
array('ROLE_ADMIN'),
|
||||
array('ROLE_USER', 'ROLE_ALLOWED_TO_SWITCH'),
|
||||
),
|
||||
array(
|
||||
array('ROLE_ADMIN', 'ROLE_OPERATOR'),
|
||||
array('ROLE_ADMIN', 'ROLE_OPERATOR'),
|
||||
array('ROLE_USER', 'ROLE_ALLOWED_TO_SWITCH'),
|
||||
),
|
||||
);
|
||||
[
|
||||
['ROLE_ADMIN'],
|
||||
['ROLE_ADMIN'],
|
||||
['ROLE_USER', 'ROLE_ALLOWED_TO_SWITCH'],
|
||||
],
|
||||
[
|
||||
[new Role('ROLE_ADMIN')],
|
||||
['ROLE_ADMIN'],
|
||||
['ROLE_USER', 'ROLE_ALLOWED_TO_SWITCH'],
|
||||
],
|
||||
[
|
||||
['ROLE_ADMIN', 'ROLE_OPERATOR'],
|
||||
['ROLE_ADMIN', 'ROLE_OPERATOR'],
|
||||
['ROLE_USER', 'ROLE_ALLOWED_TO_SWITCH'],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
private function getRoleHierarchy()
|
||||
{
|
||||
return new RoleHierarchy(array(
|
||||
'ROLE_ADMIN' => array('ROLE_USER', 'ROLE_ALLOWED_TO_SWITCH'),
|
||||
'ROLE_OPERATOR' => array('ROLE_USER'),
|
||||
));
|
||||
return new RoleHierarchy([
|
||||
'ROLE_ADMIN' => ['ROLE_USER', 'ROLE_ALLOWED_TO_SWITCH'],
|
||||
'ROLE_OPERATOR' => ['ROLE_USER'],
|
||||
]);
|
||||
}
|
||||
|
||||
private function getRequest()
|
||||
|
|
|
@ -51,7 +51,7 @@ class TraceableFirewallListenerTest extends TestCase
|
|||
->expects($this->once())
|
||||
->method('getListeners')
|
||||
->with($request)
|
||||
->willReturn(array(array($listener), null, null));
|
||||
->willReturn([[$listener], null, null]);
|
||||
|
||||
$firewall = new TraceableFirewallListener($firewallMap, new EventDispatcher(), new LogoutUrlGenerator());
|
||||
$firewall->onKernelRequest($event);
|
||||
|
|
|
@ -86,7 +86,7 @@ class AddSecurityVotersPassTest extends TestCase
|
|||
|
||||
$container
|
||||
->register('security.access.decision_manager', AccessDecisionManager::class)
|
||||
->addArgument(array($voterDef1, $voterDef2));
|
||||
->addArgument([$voterDef1, $voterDef2]);
|
||||
$container->setParameter('kernel.debug', true);
|
||||
|
||||
$compilerPass = new AddSecurityVotersPass();
|
||||
|
@ -119,7 +119,7 @@ class AddSecurityVotersPassTest extends TestCase
|
|||
|
||||
$container
|
||||
->register('security.access.decision_manager', AccessDecisionManager::class)
|
||||
->addArgument(array($voterDef1, $voterDef2));
|
||||
->addArgument([$voterDef1, $voterDef2]);
|
||||
|
||||
$compilerPass = new AddSecurityVotersPass();
|
||||
$compilerPass->process($container);
|
||||
|
|
|
@ -22,7 +22,7 @@ class AddSessionDomainConstraintPassTest extends TestCase
|
|||
{
|
||||
public function testSessionCookie()
|
||||
{
|
||||
$container = $this->createContainer(array('cookie_domain' => '.symfony.com.', 'cookie_secure' => true));
|
||||
$container = $this->createContainer(['cookie_domain' => '.symfony.com.', 'cookie_secure' => true]);
|
||||
|
||||
$utils = $container->get('security.http_utils');
|
||||
$request = Request::create('/', 'get');
|
||||
|
@ -37,7 +37,7 @@ class AddSessionDomainConstraintPassTest extends TestCase
|
|||
|
||||
public function testSessionNoDomain()
|
||||
{
|
||||
$container = $this->createContainer(array('cookie_secure' => true));
|
||||
$container = $this->createContainer(['cookie_secure' => true]);
|
||||
|
||||
$utils = $container->get('security.http_utils');
|
||||
$request = Request::create('/', 'get');
|
||||
|
@ -52,7 +52,7 @@ class AddSessionDomainConstraintPassTest extends TestCase
|
|||
|
||||
public function testSessionNoSecure()
|
||||
{
|
||||
$container = $this->createContainer(array('cookie_domain' => '.symfony.com.'));
|
||||
$container = $this->createContainer(['cookie_domain' => '.symfony.com.']);
|
||||
|
||||
$utils = $container->get('security.http_utils');
|
||||
$request = Request::create('/', 'get');
|
||||
|
@ -67,7 +67,7 @@ class AddSessionDomainConstraintPassTest extends TestCase
|
|||
|
||||
public function testSessionNoSecureAndNoDomain()
|
||||
{
|
||||
$container = $this->createContainer(array());
|
||||
$container = $this->createContainer([]);
|
||||
|
||||
$utils = $container->get('security.http_utils');
|
||||
$request = Request::create('/', 'get');
|
||||
|
@ -98,7 +98,7 @@ class AddSessionDomainConstraintPassTest extends TestCase
|
|||
|
||||
public function testSessionAutoSecure()
|
||||
{
|
||||
$container = $this->createContainer(array('cookie_domain' => '.symfony.com.', 'cookie_secure' => 'auto'));
|
||||
$container = $this->createContainer(['cookie_domain' => '.symfony.com.', 'cookie_secure' => 'auto']);
|
||||
|
||||
$utils = $container->get('security.http_utils');
|
||||
$request = Request::create('/', 'get');
|
||||
|
@ -119,7 +119,7 @@ class AddSessionDomainConstraintPassTest extends TestCase
|
|||
private function createContainer($sessionStorageOptions)
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$container->setParameter('kernel.bundles_metadata', array());
|
||||
$container->setParameter('kernel.bundles_metadata', []);
|
||||
$container->setParameter('kernel.cache_dir', __DIR__);
|
||||
$container->setParameter('kernel.charset', 'UTF-8');
|
||||
$container->setParameter('kernel.container_class', 'cc');
|
||||
|
@ -133,15 +133,15 @@ class AddSessionDomainConstraintPassTest extends TestCase
|
|||
$container->setParameter('request_listener.http_port', 80);
|
||||
$container->setParameter('request_listener.https_port', 443);
|
||||
|
||||
$config = array(
|
||||
'security' => array(
|
||||
'providers' => array('some_provider' => array('id' => 'foo')),
|
||||
'firewalls' => array('some_firewall' => array('security' => false)),
|
||||
),
|
||||
);
|
||||
$config = [
|
||||
'security' => [
|
||||
'providers' => ['some_provider' => ['id' => 'foo']],
|
||||
'firewalls' => ['some_firewall' => ['security' => false]],
|
||||
],
|
||||
];
|
||||
|
||||
$ext = new FrameworkExtension();
|
||||
$ext->load(array('framework' => array('csrf_protection' => false, 'router' => array('resource' => 'dummy'))), $container);
|
||||
$ext->load(['framework' => ['csrf_protection' => false, 'router' => ['resource' => 'dummy']]], $container);
|
||||
|
||||
$ext = new SecurityExtension();
|
||||
$ext->load($config, $container);
|
||||
|
|
|
@ -29,11 +29,11 @@ abstract class CompleteConfigurationTest extends TestCase
|
|||
public function testRolesHierarchy()
|
||||
{
|
||||
$container = $this->getContainer('container1');
|
||||
$this->assertEquals(array(
|
||||
'ROLE_ADMIN' => array('ROLE_USER'),
|
||||
'ROLE_SUPER_ADMIN' => array('ROLE_USER', 'ROLE_ADMIN', 'ROLE_ALLOWED_TO_SWITCH'),
|
||||
'ROLE_REMOTE' => array('ROLE_USER', 'ROLE_ADMIN'),
|
||||
), $container->getParameter('security.role_hierarchy.roles'));
|
||||
$this->assertEquals([
|
||||
'ROLE_ADMIN' => ['ROLE_USER'],
|
||||
'ROLE_SUPER_ADMIN' => ['ROLE_USER', 'ROLE_ADMIN', 'ROLE_ALLOWED_TO_SWITCH'],
|
||||
'ROLE_REMOTE' => ['ROLE_USER', 'ROLE_ADMIN'],
|
||||
], $container->getParameter('security.role_hierarchy.roles'));
|
||||
}
|
||||
|
||||
public function testUserProviders()
|
||||
|
@ -42,30 +42,30 @@ abstract class CompleteConfigurationTest extends TestCase
|
|||
|
||||
$providers = array_values(array_filter($container->getServiceIds(), function ($key) { return 0 === strpos($key, 'security.user.provider.concrete'); }));
|
||||
|
||||
$expectedProviders = array(
|
||||
$expectedProviders = [
|
||||
'security.user.provider.concrete.default',
|
||||
'security.user.provider.concrete.digest',
|
||||
'security.user.provider.concrete.basic',
|
||||
'security.user.provider.concrete.service',
|
||||
'security.user.provider.concrete.chain',
|
||||
);
|
||||
];
|
||||
|
||||
$this->assertEquals(array(), array_diff($expectedProviders, $providers));
|
||||
$this->assertEquals(array(), array_diff($providers, $expectedProviders));
|
||||
$this->assertEquals([], array_diff($expectedProviders, $providers));
|
||||
$this->assertEquals([], array_diff($providers, $expectedProviders));
|
||||
|
||||
// chain provider
|
||||
$this->assertEquals(array(new IteratorArgument(array(
|
||||
$this->assertEquals([new IteratorArgument([
|
||||
new Reference('security.user.provider.concrete.service'),
|
||||
new Reference('security.user.provider.concrete.basic'),
|
||||
))), $container->getDefinition('security.user.provider.concrete.chain')->getArguments());
|
||||
])], $container->getDefinition('security.user.provider.concrete.chain')->getArguments());
|
||||
}
|
||||
|
||||
public function testFirewalls()
|
||||
{
|
||||
$container = $this->getContainer('container1');
|
||||
$arguments = $container->getDefinition('security.firewall.map')->getArguments();
|
||||
$listeners = array();
|
||||
$configs = array();
|
||||
$listeners = [];
|
||||
$configs = [];
|
||||
foreach (array_keys($arguments[1]->getValues()) as $contextId) {
|
||||
$contextDef = $container->getDefinition($contextId);
|
||||
$arguments = $contextDef->getArguments();
|
||||
|
@ -80,14 +80,14 @@ abstract class CompleteConfigurationTest extends TestCase
|
|||
$configs[0][2] = strtolower($configs[0][2]);
|
||||
$configs[2][2] = strtolower($configs[2][2]);
|
||||
|
||||
$this->assertEquals(array(
|
||||
array(
|
||||
$this->assertEquals([
|
||||
[
|
||||
'simple',
|
||||
'security.user_checker',
|
||||
'.security.request_matcher.xmi9dcw',
|
||||
false,
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'secure',
|
||||
'security.user_checker',
|
||||
null,
|
||||
|
@ -98,7 +98,7 @@ abstract class CompleteConfigurationTest extends TestCase
|
|||
'security.authentication.form_entry_point.secure',
|
||||
null,
|
||||
null,
|
||||
array(
|
||||
[
|
||||
'switch_user',
|
||||
'x509',
|
||||
'remote_user',
|
||||
|
@ -106,14 +106,14 @@ abstract class CompleteConfigurationTest extends TestCase
|
|||
'http_basic',
|
||||
'remember_me',
|
||||
'anonymous',
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'parameter' => '_switch_user',
|
||||
'role' => 'ROLE_ALLOWED_TO_SWITCH',
|
||||
'stateless' => false,
|
||||
),
|
||||
),
|
||||
array(
|
||||
],
|
||||
],
|
||||
[
|
||||
'host',
|
||||
'security.user_checker',
|
||||
'.security.request_matcher.iw4hyjb',
|
||||
|
@ -124,13 +124,13 @@ abstract class CompleteConfigurationTest extends TestCase
|
|||
'security.authentication.basic_entry_point.host',
|
||||
null,
|
||||
null,
|
||||
array(
|
||||
[
|
||||
'http_basic',
|
||||
'anonymous',
|
||||
),
|
||||
],
|
||||
null,
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'with_user_checker',
|
||||
'app.user_checker',
|
||||
null,
|
||||
|
@ -141,17 +141,17 @@ abstract class CompleteConfigurationTest extends TestCase
|
|||
'security.authentication.basic_entry_point.with_user_checker',
|
||||
null,
|
||||
null,
|
||||
array(
|
||||
[
|
||||
'http_basic',
|
||||
'anonymous',
|
||||
),
|
||||
],
|
||||
null,
|
||||
),
|
||||
), $configs);
|
||||
],
|
||||
], $configs);
|
||||
|
||||
$this->assertEquals(array(
|
||||
array(),
|
||||
array(
|
||||
$this->assertEquals([
|
||||
[],
|
||||
[
|
||||
'security.channel_listener',
|
||||
'security.authentication.listener.x509.secure',
|
||||
'security.authentication.listener.remote_user.secure',
|
||||
|
@ -161,22 +161,22 @@ abstract class CompleteConfigurationTest extends TestCase
|
|||
'security.authentication.listener.anonymous.secure',
|
||||
'security.authentication.switchuser_listener.secure',
|
||||
'security.access_listener',
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'security.channel_listener',
|
||||
'security.context_listener.0',
|
||||
'security.authentication.listener.basic.host',
|
||||
'security.authentication.listener.anonymous.host',
|
||||
'security.access_listener',
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'security.channel_listener',
|
||||
'security.context_listener.1',
|
||||
'security.authentication.listener.basic.with_user_checker',
|
||||
'security.authentication.listener.anonymous.with_user_checker',
|
||||
'security.access_listener',
|
||||
),
|
||||
), $listeners);
|
||||
],
|
||||
], $listeners);
|
||||
|
||||
$this->assertFalse($container->hasAlias('Symfony\Component\Security\Core\User\UserCheckerInterface', 'No user checker alias is registered when custom user checker services are registered'));
|
||||
}
|
||||
|
@ -186,7 +186,7 @@ abstract class CompleteConfigurationTest extends TestCase
|
|||
$container = $this->getContainer('container1');
|
||||
|
||||
$arguments = $container->getDefinition('security.firewall.map')->getArguments();
|
||||
$matchers = array();
|
||||
$matchers = [];
|
||||
|
||||
foreach ($arguments[1]->getValues() as $reference) {
|
||||
if ($reference instanceof Reference) {
|
||||
|
@ -195,16 +195,16 @@ abstract class CompleteConfigurationTest extends TestCase
|
|||
}
|
||||
}
|
||||
|
||||
$this->assertEquals(array(
|
||||
array(
|
||||
$this->assertEquals([
|
||||
[
|
||||
'/login',
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'/test',
|
||||
'foo\\.example\\.org',
|
||||
array('GET', 'POST'),
|
||||
),
|
||||
), $matchers);
|
||||
['GET', 'POST'],
|
||||
],
|
||||
], $matchers);
|
||||
}
|
||||
|
||||
public function testUserCheckerAliasIsRegistered()
|
||||
|
@ -219,14 +219,14 @@ abstract class CompleteConfigurationTest extends TestCase
|
|||
{
|
||||
$container = $this->getContainer('container1');
|
||||
|
||||
$rules = array();
|
||||
$rules = [];
|
||||
foreach ($container->getDefinition('security.access_map')->getMethodCalls() as $call) {
|
||||
if ('add' == $call[0]) {
|
||||
$rules[] = array((string) $call[1][0], $call[1][1], $call[1][2]);
|
||||
$rules[] = [(string) $call[1][0], $call[1][1], $call[1][2]];
|
||||
}
|
||||
}
|
||||
|
||||
$matcherIds = array();
|
||||
$matcherIds = [];
|
||||
foreach ($rules as list($matcherId, $attributes, $channel)) {
|
||||
$requestMatcher = $container->getDefinition($matcherId);
|
||||
|
||||
|
@ -235,17 +235,17 @@ abstract class CompleteConfigurationTest extends TestCase
|
|||
|
||||
$i = \count($matcherIds);
|
||||
if (1 === $i) {
|
||||
$this->assertEquals(array('ROLE_USER'), $attributes);
|
||||
$this->assertEquals(['ROLE_USER'], $attributes);
|
||||
$this->assertEquals('https', $channel);
|
||||
$this->assertEquals(
|
||||
array('/blog/524', null, array('GET', 'POST'), array(), array(), null, 8000),
|
||||
['/blog/524', null, ['GET', 'POST'], [], [], null, 8000],
|
||||
$requestMatcher->getArguments()
|
||||
);
|
||||
} elseif (2 === $i) {
|
||||
$this->assertEquals(array('IS_AUTHENTICATED_ANONYMOUSLY'), $attributes);
|
||||
$this->assertEquals(['IS_AUTHENTICATED_ANONYMOUSLY'], $attributes);
|
||||
$this->assertNull($channel);
|
||||
$this->assertEquals(
|
||||
array('/blog/.*'),
|
||||
['/blog/.*'],
|
||||
$requestMatcher->getArguments()
|
||||
);
|
||||
} elseif (3 === $i) {
|
||||
|
@ -260,22 +260,22 @@ abstract class CompleteConfigurationTest extends TestCase
|
|||
{
|
||||
$container = $this->getContainer('merge');
|
||||
|
||||
$this->assertEquals(array(
|
||||
'FOO' => array('MOO'),
|
||||
'ADMIN' => array('USER'),
|
||||
), $container->getParameter('security.role_hierarchy.roles'));
|
||||
$this->assertEquals([
|
||||
'FOO' => ['MOO'],
|
||||
'ADMIN' => ['USER'],
|
||||
], $container->getParameter('security.role_hierarchy.roles'));
|
||||
}
|
||||
|
||||
public function testEncoders()
|
||||
{
|
||||
$container = $this->getContainer('container1');
|
||||
|
||||
$this->assertEquals(array(array(
|
||||
'JMS\FooBundle\Entity\User1' => array(
|
||||
$this->assertEquals([[
|
||||
'JMS\FooBundle\Entity\User1' => [
|
||||
'class' => 'Symfony\Component\Security\Core\Encoder\PlaintextPasswordEncoder',
|
||||
'arguments' => array(false),
|
||||
),
|
||||
'JMS\FooBundle\Entity\User2' => array(
|
||||
'arguments' => [false],
|
||||
],
|
||||
'JMS\FooBundle\Entity\User2' => [
|
||||
'algorithm' => 'sha1',
|
||||
'encode_as_base64' => false,
|
||||
'iterations' => 5,
|
||||
|
@ -286,8 +286,8 @@ abstract class CompleteConfigurationTest extends TestCase
|
|||
'memory_cost' => null,
|
||||
'time_cost' => null,
|
||||
'threads' => null,
|
||||
),
|
||||
'JMS\FooBundle\Entity\User3' => array(
|
||||
],
|
||||
'JMS\FooBundle\Entity\User3' => [
|
||||
'algorithm' => 'md5',
|
||||
'hash_algorithm' => 'sha512',
|
||||
'key_length' => 40,
|
||||
|
@ -298,17 +298,17 @@ abstract class CompleteConfigurationTest extends TestCase
|
|||
'memory_cost' => null,
|
||||
'time_cost' => null,
|
||||
'threads' => null,
|
||||
),
|
||||
],
|
||||
'JMS\FooBundle\Entity\User4' => new Reference('security.encoder.foo'),
|
||||
'JMS\FooBundle\Entity\User5' => array(
|
||||
'JMS\FooBundle\Entity\User5' => [
|
||||
'class' => 'Symfony\Component\Security\Core\Encoder\Pbkdf2PasswordEncoder',
|
||||
'arguments' => array('sha1', false, 5, 30),
|
||||
),
|
||||
'JMS\FooBundle\Entity\User6' => array(
|
||||
'arguments' => ['sha1', false, 5, 30],
|
||||
],
|
||||
'JMS\FooBundle\Entity\User6' => [
|
||||
'class' => 'Symfony\Component\Security\Core\Encoder\BCryptPasswordEncoder',
|
||||
'arguments' => array(15),
|
||||
),
|
||||
)), $container->getDefinition('security.encoder_factory.generic')->getArguments());
|
||||
'arguments' => [15],
|
||||
],
|
||||
]], $container->getDefinition('security.encoder_factory.generic')->getArguments());
|
||||
}
|
||||
|
||||
public function testEncodersWithLibsodium()
|
||||
|
@ -319,12 +319,12 @@ abstract class CompleteConfigurationTest extends TestCase
|
|||
|
||||
$container = $this->getContainer('argon2i_encoder');
|
||||
|
||||
$this->assertEquals(array(array(
|
||||
'JMS\FooBundle\Entity\User1' => array(
|
||||
$this->assertEquals([[
|
||||
'JMS\FooBundle\Entity\User1' => [
|
||||
'class' => 'Symfony\Component\Security\Core\Encoder\PlaintextPasswordEncoder',
|
||||
'arguments' => array(false),
|
||||
),
|
||||
'JMS\FooBundle\Entity\User2' => array(
|
||||
'arguments' => [false],
|
||||
],
|
||||
'JMS\FooBundle\Entity\User2' => [
|
||||
'algorithm' => 'sha1',
|
||||
'encode_as_base64' => false,
|
||||
'iterations' => 5,
|
||||
|
@ -335,8 +335,8 @@ abstract class CompleteConfigurationTest extends TestCase
|
|||
'memory_cost' => null,
|
||||
'time_cost' => null,
|
||||
'threads' => null,
|
||||
),
|
||||
'JMS\FooBundle\Entity\User3' => array(
|
||||
],
|
||||
'JMS\FooBundle\Entity\User3' => [
|
||||
'algorithm' => 'md5',
|
||||
'hash_algorithm' => 'sha512',
|
||||
'key_length' => 40,
|
||||
|
@ -347,21 +347,21 @@ abstract class CompleteConfigurationTest extends TestCase
|
|||
'memory_cost' => null,
|
||||
'time_cost' => null,
|
||||
'threads' => null,
|
||||
),
|
||||
],
|
||||
'JMS\FooBundle\Entity\User4' => new Reference('security.encoder.foo'),
|
||||
'JMS\FooBundle\Entity\User5' => array(
|
||||
'JMS\FooBundle\Entity\User5' => [
|
||||
'class' => 'Symfony\Component\Security\Core\Encoder\Pbkdf2PasswordEncoder',
|
||||
'arguments' => array('sha1', false, 5, 30),
|
||||
),
|
||||
'JMS\FooBundle\Entity\User6' => array(
|
||||
'arguments' => ['sha1', false, 5, 30],
|
||||
],
|
||||
'JMS\FooBundle\Entity\User6' => [
|
||||
'class' => 'Symfony\Component\Security\Core\Encoder\BCryptPasswordEncoder',
|
||||
'arguments' => array(15),
|
||||
),
|
||||
'JMS\FooBundle\Entity\User7' => array(
|
||||
'arguments' => [15],
|
||||
],
|
||||
'JMS\FooBundle\Entity\User7' => [
|
||||
'class' => 'Symfony\Component\Security\Core\Encoder\Argon2iPasswordEncoder',
|
||||
'arguments' => array(256, 1, 2),
|
||||
),
|
||||
)), $container->getDefinition('security.encoder_factory.generic')->getArguments());
|
||||
'arguments' => [256, 1, 2],
|
||||
],
|
||||
]], $container->getDefinition('security.encoder_factory.generic')->getArguments());
|
||||
}
|
||||
|
||||
public function testRememberMeThrowExceptionsDefault()
|
||||
|
@ -470,8 +470,8 @@ abstract class CompleteConfigurationTest extends TestCase
|
|||
{
|
||||
$container = $this->getContainer('simple_auth');
|
||||
$arguments = $container->getDefinition('security.firewall.map')->getArguments();
|
||||
$listeners = array();
|
||||
$configs = array();
|
||||
$listeners = [];
|
||||
$configs = [];
|
||||
foreach (array_keys($arguments[1]->getValues()) as $contextId) {
|
||||
$contextDef = $container->getDefinition($contextId);
|
||||
$arguments = $contextDef->getArguments();
|
||||
|
@ -481,7 +481,7 @@ abstract class CompleteConfigurationTest extends TestCase
|
|||
$configs[] = array_values($configDef->getArguments());
|
||||
}
|
||||
|
||||
$this->assertSame(array(array(
|
||||
$this->assertSame([[
|
||||
'simple_auth',
|
||||
'security.user_checker',
|
||||
null,
|
||||
|
@ -492,18 +492,18 @@ abstract class CompleteConfigurationTest extends TestCase
|
|||
'security.authentication.form_entry_point.simple_auth',
|
||||
null,
|
||||
null,
|
||||
array('simple_form', 'anonymous',
|
||||
),
|
||||
['simple_form', 'anonymous',
|
||||
],
|
||||
null,
|
||||
)), $configs);
|
||||
]], $configs);
|
||||
|
||||
$this->assertSame(array(array(
|
||||
$this->assertSame([[
|
||||
'security.channel_listener',
|
||||
'security.context_listener.0',
|
||||
'security.authentication.listener.simple_form.simple_auth',
|
||||
'security.authentication.listener.anonymous.simple_auth',
|
||||
'security.access_listener',
|
||||
)), $listeners);
|
||||
]], $listeners);
|
||||
}
|
||||
|
||||
protected function getContainer($file)
|
||||
|
@ -520,8 +520,8 @@ abstract class CompleteConfigurationTest extends TestCase
|
|||
$bundle->build($container); // Attach all default factories
|
||||
$this->getLoader($container)->load($file);
|
||||
|
||||
$container->getCompilerPassConfig()->setOptimizationPasses(array());
|
||||
$container->getCompilerPassConfig()->setRemovingPasses(array());
|
||||
$container->getCompilerPassConfig()->setOptimizationPasses([]);
|
||||
$container->getCompilerPassConfig()->setRemovingPasses([]);
|
||||
$container->compile();
|
||||
|
||||
return $container;
|
||||
|
|
|
@ -1,67 +1,67 @@
|
|||
<?php
|
||||
|
||||
$container->loadFromExtension('security', array(
|
||||
'encoders' => array(
|
||||
$container->loadFromExtension('security', [
|
||||
'encoders' => [
|
||||
'JMS\FooBundle\Entity\User1' => 'plaintext',
|
||||
'JMS\FooBundle\Entity\User2' => array(
|
||||
'JMS\FooBundle\Entity\User2' => [
|
||||
'algorithm' => 'sha1',
|
||||
'encode_as_base64' => false,
|
||||
'iterations' => 5,
|
||||
),
|
||||
'JMS\FooBundle\Entity\User3' => array(
|
||||
],
|
||||
'JMS\FooBundle\Entity\User3' => [
|
||||
'algorithm' => 'md5',
|
||||
),
|
||||
'JMS\FooBundle\Entity\User4' => array(
|
||||
],
|
||||
'JMS\FooBundle\Entity\User4' => [
|
||||
'id' => 'security.encoder.foo',
|
||||
),
|
||||
'JMS\FooBundle\Entity\User5' => array(
|
||||
],
|
||||
'JMS\FooBundle\Entity\User5' => [
|
||||
'algorithm' => 'pbkdf2',
|
||||
'hash_algorithm' => 'sha1',
|
||||
'encode_as_base64' => false,
|
||||
'iterations' => 5,
|
||||
'key_length' => 30,
|
||||
),
|
||||
'JMS\FooBundle\Entity\User6' => array(
|
||||
],
|
||||
'JMS\FooBundle\Entity\User6' => [
|
||||
'algorithm' => 'bcrypt',
|
||||
'cost' => 15,
|
||||
),
|
||||
),
|
||||
'providers' => array(
|
||||
'default' => array(
|
||||
'memory' => array(
|
||||
'users' => array(
|
||||
'foo' => array('password' => 'foo', 'roles' => 'ROLE_USER'),
|
||||
),
|
||||
),
|
||||
),
|
||||
'digest' => array(
|
||||
'memory' => array(
|
||||
'users' => array(
|
||||
'foo' => array('password' => 'foo', 'roles' => 'ROLE_USER, ROLE_ADMIN'),
|
||||
),
|
||||
),
|
||||
),
|
||||
'basic' => array(
|
||||
'memory' => array(
|
||||
'users' => array(
|
||||
'foo' => array('password' => '0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33', 'roles' => 'ROLE_SUPER_ADMIN'),
|
||||
'bar' => array('password' => '0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33', 'roles' => array('ROLE_USER', 'ROLE_ADMIN')),
|
||||
),
|
||||
),
|
||||
),
|
||||
'service' => array(
|
||||
],
|
||||
],
|
||||
'providers' => [
|
||||
'default' => [
|
||||
'memory' => [
|
||||
'users' => [
|
||||
'foo' => ['password' => 'foo', 'roles' => 'ROLE_USER'],
|
||||
],
|
||||
],
|
||||
],
|
||||
'digest' => [
|
||||
'memory' => [
|
||||
'users' => [
|
||||
'foo' => ['password' => 'foo', 'roles' => 'ROLE_USER, ROLE_ADMIN'],
|
||||
],
|
||||
],
|
||||
],
|
||||
'basic' => [
|
||||
'memory' => [
|
||||
'users' => [
|
||||
'foo' => ['password' => '0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33', 'roles' => 'ROLE_SUPER_ADMIN'],
|
||||
'bar' => ['password' => '0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33', 'roles' => ['ROLE_USER', 'ROLE_ADMIN']],
|
||||
],
|
||||
],
|
||||
],
|
||||
'service' => [
|
||||
'id' => 'user.manager',
|
||||
),
|
||||
'chain' => array(
|
||||
'chain' => array(
|
||||
'providers' => array('service', 'basic'),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
'chain' => [
|
||||
'chain' => [
|
||||
'providers' => ['service', 'basic'],
|
||||
],
|
||||
],
|
||||
],
|
||||
|
||||
'firewalls' => array(
|
||||
'simple' => array('provider' => 'default', 'pattern' => '/login', 'security' => false),
|
||||
'secure' => array('stateless' => true,
|
||||
'firewalls' => [
|
||||
'simple' => ['provider' => 'default', 'pattern' => '/login', 'security' => false],
|
||||
'secure' => ['stateless' => true,
|
||||
'provider' => 'default',
|
||||
'http_basic' => true,
|
||||
'form_login' => true,
|
||||
|
@ -70,34 +70,34 @@ $container->loadFromExtension('security', array(
|
|||
'x509' => true,
|
||||
'remote_user' => true,
|
||||
'logout' => true,
|
||||
'remember_me' => array('secret' => 'TheSecret'),
|
||||
'remember_me' => ['secret' => 'TheSecret'],
|
||||
'user_checker' => null,
|
||||
),
|
||||
'host' => array(
|
||||
],
|
||||
'host' => [
|
||||
'provider' => 'default',
|
||||
'pattern' => '/test',
|
||||
'host' => 'foo\\.example\\.org',
|
||||
'methods' => array('GET', 'POST'),
|
||||
'methods' => ['GET', 'POST'],
|
||||
'anonymous' => true,
|
||||
'http_basic' => true,
|
||||
),
|
||||
'with_user_checker' => array(
|
||||
],
|
||||
'with_user_checker' => [
|
||||
'provider' => 'default',
|
||||
'user_checker' => 'app.user_checker',
|
||||
'anonymous' => true,
|
||||
'http_basic' => true,
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
|
||||
'access_control' => array(
|
||||
array('path' => '/blog/524', 'role' => 'ROLE_USER', 'requires_channel' => 'https', 'methods' => array('get', 'POST'), 'port' => 8000),
|
||||
array('path' => '/blog/.*', 'role' => 'IS_AUTHENTICATED_ANONYMOUSLY'),
|
||||
array('path' => '/blog/524', 'role' => 'IS_AUTHENTICATED_ANONYMOUSLY', 'allow_if' => "token.getUsername() matches '/^admin/'"),
|
||||
),
|
||||
'access_control' => [
|
||||
['path' => '/blog/524', 'role' => 'ROLE_USER', 'requires_channel' => 'https', 'methods' => ['get', 'POST'], 'port' => 8000],
|
||||
['path' => '/blog/.*', 'role' => 'IS_AUTHENTICATED_ANONYMOUSLY'],
|
||||
['path' => '/blog/524', 'role' => 'IS_AUTHENTICATED_ANONYMOUSLY', 'allow_if' => "token.getUsername() matches '/^admin/'"],
|
||||
],
|
||||
|
||||
'role_hierarchy' => array(
|
||||
'role_hierarchy' => [
|
||||
'ROLE_ADMIN' => 'ROLE_USER',
|
||||
'ROLE_SUPER_ADMIN' => array('ROLE_USER', 'ROLE_ADMIN', 'ROLE_ALLOWED_TO_SWITCH'),
|
||||
'ROLE_SUPER_ADMIN' => ['ROLE_USER', 'ROLE_ADMIN', 'ROLE_ALLOWED_TO_SWITCH'],
|
||||
'ROLE_REMOTE' => 'ROLE_USER,ROLE_ADMIN',
|
||||
),
|
||||
));
|
||||
],
|
||||
]);
|
||||
|
|
|
@ -1,21 +1,21 @@
|
|||
<?php
|
||||
|
||||
$container->loadFromExtension('security', array(
|
||||
'providers' => array(
|
||||
'default' => array(
|
||||
'memory' => array(
|
||||
'users' => array(
|
||||
'foo' => array('password' => 'foo', 'roles' => 'ROLE_USER'),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
$container->loadFromExtension('security', [
|
||||
'providers' => [
|
||||
'default' => [
|
||||
'memory' => [
|
||||
'users' => [
|
||||
'foo' => ['password' => 'foo', 'roles' => 'ROLE_USER'],
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
|
||||
'firewalls' => array(
|
||||
'simple_auth' => array(
|
||||
'firewalls' => [
|
||||
'simple_auth' => [
|
||||
'provider' => 'default',
|
||||
'anonymous' => true,
|
||||
'simple_form' => array('authenticator' => 'simple_authenticator'),
|
||||
),
|
||||
),
|
||||
));
|
||||
'simple_form' => ['authenticator' => 'simple_authenticator'],
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
|
|
@ -352,22 +352,22 @@ class SecurityExtensionTest extends TestCase
|
|||
$container = $this->getRawContainer();
|
||||
|
||||
$container->registerExtension(new FrameworkExtension());
|
||||
$container->setParameter('kernel.bundles_metadata', array());
|
||||
$container->setParameter('kernel.bundles_metadata', []);
|
||||
$container->setParameter('kernel.project_dir', __DIR__);
|
||||
$container->setParameter('kernel.root_dir', __DIR__);
|
||||
$container->setParameter('kernel.cache_dir', __DIR__);
|
||||
|
||||
$container->loadFromExtension('security', array(
|
||||
'firewalls' => array(
|
||||
'default' => array(
|
||||
$container->loadFromExtension('security', [
|
||||
'firewalls' => [
|
||||
'default' => [
|
||||
'form_login' => null,
|
||||
'remember_me' => array('secret' => 'baz'),
|
||||
),
|
||||
),
|
||||
));
|
||||
$container->loadFromExtension('framework', array(
|
||||
'remember_me' => ['secret' => 'baz'],
|
||||
],
|
||||
],
|
||||
]);
|
||||
$container->loadFromExtension('framework', [
|
||||
'session' => $config,
|
||||
));
|
||||
]);
|
||||
|
||||
$container->compile();
|
||||
|
||||
|
@ -379,22 +379,22 @@ class SecurityExtensionTest extends TestCase
|
|||
|
||||
public function sessionConfigurationProvider()
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
return [
|
||||
[
|
||||
false,
|
||||
null,
|
||||
false,
|
||||
),
|
||||
array(
|
||||
array(
|
||||
],
|
||||
[
|
||||
[
|
||||
'cookie_secure' => true,
|
||||
'cookie_samesite' => 'lax',
|
||||
'save_path' => null,
|
||||
),
|
||||
],
|
||||
'lax',
|
||||
true,
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
protected function getRawContainer()
|
||||
|
|
|
@ -26,15 +26,15 @@ class VoteListenerTest extends TestCase
|
|||
$traceableAccessDecisionManager = $this
|
||||
->getMockBuilder(TraceableAccessDecisionManager::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(array('addVoterVote'))
|
||||
->setMethods(['addVoterVote'])
|
||||
->getMock();
|
||||
|
||||
$traceableAccessDecisionManager
|
||||
->expects($this->once())
|
||||
->method('addVoterVote')
|
||||
->with($voter, array('myattr1', 'myattr2'), VoterInterface::ACCESS_GRANTED);
|
||||
->with($voter, ['myattr1', 'myattr2'], VoterInterface::ACCESS_GRANTED);
|
||||
|
||||
$sut = new VoteListener($traceableAccessDecisionManager);
|
||||
$sut->onVoterVote(new VoteEvent($voter, 'mysubject', array('myattr1', 'myattr2'), VoterInterface::ACCESS_GRANTED));
|
||||
$sut->onVoterVote(new VoteEvent($voter, 'mysubject', ['myattr1', 'myattr2'], VoterInterface::ACCESS_GRANTED));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ class JsonLoginLdapTest extends WebTestCase
|
|||
{
|
||||
public function testKernelBoot()
|
||||
{
|
||||
$kernel = self::createKernel(array('test_case' => 'JsonLoginLdap', 'root_config' => 'config.yml'));
|
||||
$kernel = self::createKernel(['test_case' => 'JsonLoginLdap', 'root_config' => 'config.yml']);
|
||||
$kernel->boot();
|
||||
|
||||
$this->assertInstanceOf(Kernel::class, $kernel);
|
||||
|
|
|
@ -9,8 +9,8 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
return array(
|
||||
return [
|
||||
new Symfony\Bundle\SecurityBundle\SecurityBundle(),
|
||||
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
|
||||
new Symfony\Bundle\TwigBundle\TwigBundle(),
|
||||
);
|
||||
];
|
||||
|
|
|
@ -46,7 +46,7 @@ class FirewallContextTest extends TestCase
|
|||
*/
|
||||
public function testFirewallConfigAs3rdConstructorArgument()
|
||||
{
|
||||
new FirewallContext(array(), $this->getExceptionListenerMock(), new FirewallConfig('main', 'user_checker', 'request_matcher'));
|
||||
new FirewallContext([], $this->getExceptionListenerMock(), new FirewallConfig('main', 'user_checker', 'request_matcher'));
|
||||
}
|
||||
|
||||
private function getExceptionListenerMock()
|
||||
|
|
|
@ -54,11 +54,11 @@ class Configuration implements ConfigurationInterface
|
|||
->arrayNode('form_themes')
|
||||
->addDefaultChildrenIfNoneSet()
|
||||
->prototype('scalar')->defaultValue('form_div_layout.html.twig')->end()
|
||||
->example(array('@My/form.html.twig'))
|
||||
->example(['@My/form.html.twig'])
|
||||
->validate()
|
||||
->ifTrue(function ($v) { return !\in_array('form_div_layout.html.twig', $v); })
|
||||
->then(function ($v) {
|
||||
return array_merge(array('form_div_layout.html.twig'), $v);
|
||||
return array_merge(['form_div_layout.html.twig'], $v);
|
||||
})
|
||||
->end()
|
||||
->end()
|
||||
|
@ -74,7 +74,7 @@ class Configuration implements ConfigurationInterface
|
|||
->arrayNode('globals')
|
||||
->normalizeKeys(false)
|
||||
->useAttributeAsKey('key')
|
||||
->example(array('foo' => '"@bar"', 'pi' => 3.14))
|
||||
->example(['foo' => '"@bar"', 'pi' => 3.14])
|
||||
->prototype('array')
|
||||
->normalizeKeys(false)
|
||||
->beforeNormalization()
|
||||
|
@ -84,7 +84,7 @@ class Configuration implements ConfigurationInterface
|
|||
return substr($v, 1);
|
||||
}
|
||||
|
||||
return array('id' => substr($v, 1), 'type' => 'service');
|
||||
return ['id' => substr($v, 1), 'type' => 'service'];
|
||||
})
|
||||
->end()
|
||||
->beforeNormalization()
|
||||
|
@ -93,18 +93,18 @@ class Configuration implements ConfigurationInterface
|
|||
$keys = array_keys($v);
|
||||
sort($keys);
|
||||
|
||||
return $keys !== array('id', 'type') && $keys !== array('value');
|
||||
return $keys !== ['id', 'type'] && $keys !== ['value'];
|
||||
}
|
||||
|
||||
return true;
|
||||
})
|
||||
->then(function ($v) { return array('value' => $v); })
|
||||
->then(function ($v) { return ['value' => $v]; })
|
||||
->end()
|
||||
->children()
|
||||
->scalarNode('id')->end()
|
||||
->scalarNode('type')
|
||||
->validate()
|
||||
->ifNotInArray(array('service'))
|
||||
->ifNotInArray(['service'])
|
||||
->thenInvalid('The %s type is not supported')
|
||||
->end()
|
||||
->end()
|
||||
|
@ -147,7 +147,7 @@ class Configuration implements ConfigurationInterface
|
|||
->beforeNormalization()
|
||||
->always()
|
||||
->then(function ($paths) {
|
||||
$normalized = array();
|
||||
$normalized = [];
|
||||
foreach ($paths as $path => $namespace) {
|
||||
if (\is_array($namespace)) {
|
||||
// xml
|
||||
|
|
|
@ -57,10 +57,10 @@ class TwigExtension extends Extension
|
|||
if (isset($config['globals'])) {
|
||||
foreach ($config['globals'] as $name => $value) {
|
||||
if (\is_array($value) && isset($value['key'])) {
|
||||
$configs[$key]['globals'][$name] = array(
|
||||
$configs[$key]['globals'][$name] = [
|
||||
'key' => $name,
|
||||
'value' => $value,
|
||||
);
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -93,9 +93,9 @@ class TwigExtension extends Extension
|
|||
// register user-configured paths
|
||||
foreach ($config['paths'] as $path => $namespace) {
|
||||
if (!$namespace) {
|
||||
$twigFilesystemLoaderDefinition->addMethodCall('addPath', array($path));
|
||||
$twigFilesystemLoaderDefinition->addMethodCall('addPath', [$path]);
|
||||
} else {
|
||||
$twigFilesystemLoaderDefinition->addMethodCall('addPath', array($path, $namespace));
|
||||
$twigFilesystemLoaderDefinition->addMethodCall('addPath', [$path, $namespace]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -106,12 +106,12 @@ class TwigExtension extends Extension
|
|||
foreach ($this->getBundleTemplatePaths($container, $config) as $name => $paths) {
|
||||
$namespace = $this->normalizeBundleName($name);
|
||||
foreach ($paths as $path) {
|
||||
$twigFilesystemLoaderDefinition->addMethodCall('addPath', array($path, $namespace));
|
||||
$twigFilesystemLoaderDefinition->addMethodCall('addPath', [$path, $namespace]);
|
||||
}
|
||||
|
||||
if ($paths) {
|
||||
// the last path must be the bundle views directory
|
||||
$twigFilesystemLoaderDefinition->addMethodCall('addPath', array($path, '!'.$namespace));
|
||||
$twigFilesystemLoaderDefinition->addMethodCall('addPath', [$path, '!'.$namespace]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -120,12 +120,12 @@ class TwigExtension extends Extension
|
|||
@trigger_error(sprintf('Templates directory "%s" is deprecated since Symfony 4.2, use "%s" instead.', $dir, $defaultTwigPath), E_USER_DEPRECATED);
|
||||
}
|
||||
|
||||
$twigFilesystemLoaderDefinition->addMethodCall('addPath', array($dir));
|
||||
$twigFilesystemLoaderDefinition->addMethodCall('addPath', [$dir]);
|
||||
}
|
||||
$container->addResource(new FileExistenceResource($dir));
|
||||
|
||||
if (file_exists($defaultTwigPath)) {
|
||||
$twigFilesystemLoaderDefinition->addMethodCall('addPath', array($defaultTwigPath));
|
||||
$twigFilesystemLoaderDefinition->addMethodCall('addPath', [$defaultTwigPath]);
|
||||
}
|
||||
$container->addResource(new FileExistenceResource($defaultTwigPath));
|
||||
|
||||
|
@ -133,9 +133,9 @@ class TwigExtension extends Extension
|
|||
$def = $container->getDefinition('twig');
|
||||
foreach ($config['globals'] as $key => $global) {
|
||||
if (isset($global['type']) && 'service' === $global['type']) {
|
||||
$def->addMethodCall('addGlobal', array($key, new Reference($global['id'])));
|
||||
$def->addMethodCall('addGlobal', [$key, new Reference($global['id'])]);
|
||||
} else {
|
||||
$def->addMethodCall('addGlobal', array($key, $global['value']));
|
||||
$def->addMethodCall('addGlobal', [$key, $global['value']]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -147,7 +147,7 @@ class TwigExtension extends Extension
|
|||
);
|
||||
|
||||
if (isset($config['autoescape_service']) && isset($config['autoescape_service_method'])) {
|
||||
$config['autoescape'] = array(new Reference($config['autoescape_service']), $config['autoescape_service_method']);
|
||||
$config['autoescape'] = [new Reference($config['autoescape_service']), $config['autoescape_service_method']];
|
||||
}
|
||||
unset($config['autoescape_service'], $config['autoescape_service_method']);
|
||||
|
||||
|
@ -167,7 +167,7 @@ class TwigExtension extends Extension
|
|||
|
||||
private function getBundleTemplatePaths(ContainerBuilder $container, array $config)
|
||||
{
|
||||
$bundleHierarchy = array();
|
||||
$bundleHierarchy = [];
|
||||
foreach ($container->getParameter('kernel.bundles_metadata') as $name => $bundle) {
|
||||
$defaultOverrideBundlePath = $container->getParameterBag()->resolveValue($config['default_path']).'/bundles/'.$name;
|
||||
|
||||
|
|
|
@ -29,9 +29,9 @@ class TwigExtensionTest extends TestCase
|
|||
{
|
||||
$container = $this->createContainer();
|
||||
$container->registerExtension(new TwigExtension());
|
||||
$container->loadFromExtension('twig', array(
|
||||
$container->loadFromExtension('twig', [
|
||||
'strict_variables' => false, // to be removed in 5.0 relying on default
|
||||
));
|
||||
]);
|
||||
$this->compileContainer($container);
|
||||
|
||||
$this->assertEquals('Twig\Environment', $container->getDefinition('twig')->getClass(), '->load() loads the twig.xml file');
|
||||
|
@ -74,9 +74,9 @@ class TwigExtensionTest extends TestCase
|
|||
$this->assertEquals(3.14, $calls[4][1][1], '->load() registers variables as Twig globals');
|
||||
|
||||
// Yaml and Php specific configs
|
||||
if (\in_array($format, array('yml', 'php'))) {
|
||||
if (\in_array($format, ['yml', 'php'])) {
|
||||
$this->assertEquals('bad', $calls[5][1][0], '->load() registers variables as Twig globals');
|
||||
$this->assertEquals(array('key' => 'foo'), $calls[5][1][1], '->load() registers variables as Twig globals');
|
||||
$this->assertEquals(['key' => 'foo'], $calls[5][1][1], '->load() registers variables as Twig globals');
|
||||
}
|
||||
|
||||
// Twig options
|
||||
|
@ -101,7 +101,7 @@ class TwigExtensionTest extends TestCase
|
|||
$this->compileContainer($container);
|
||||
|
||||
$options = $container->getDefinition('twig')->getArgument(1);
|
||||
$this->assertEquals(array(new Reference('my_project.some_bundle.template_escaping_guesser'), 'guess'), $options['autoescape']);
|
||||
$this->assertEquals([new Reference('my_project.some_bundle.template_escaping_guesser'), 'guess'], $options['autoescape']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -140,8 +140,8 @@ class TwigExtensionTest extends TestCase
|
|||
|
||||
public function testGlobalsWithDifferentTypesAndValues()
|
||||
{
|
||||
$globals = array(
|
||||
'array' => array(),
|
||||
$globals = [
|
||||
'array' => [],
|
||||
'false' => false,
|
||||
'float' => 2.0,
|
||||
'integer' => 3,
|
||||
|
@ -149,14 +149,14 @@ class TwigExtensionTest extends TestCase
|
|||
'object' => new \stdClass(),
|
||||
'string' => 'foo',
|
||||
'true' => true,
|
||||
);
|
||||
];
|
||||
|
||||
$container = $this->createContainer();
|
||||
$container->registerExtension(new TwigExtension());
|
||||
$container->loadFromExtension('twig', array(
|
||||
$container->loadFromExtension('twig', [
|
||||
'globals' => $globals,
|
||||
'strict_variables' => false, // // to be removed in 5.0 relying on default
|
||||
));
|
||||
]);
|
||||
$this->compileContainer($container);
|
||||
|
||||
$calls = $container->getDefinition('twig')->getMethodCalls();
|
||||
|
@ -180,24 +180,24 @@ class TwigExtensionTest extends TestCase
|
|||
$this->compileContainer($container);
|
||||
|
||||
$def = $container->getDefinition('twig.loader.native_filesystem');
|
||||
$paths = array();
|
||||
$paths = [];
|
||||
foreach ($def->getMethodCalls() as $call) {
|
||||
if ('addPath' === $call[0] && false === strpos($call[1][0], 'Form')) {
|
||||
$paths[] = $call[1];
|
||||
}
|
||||
}
|
||||
|
||||
$this->assertEquals(array(
|
||||
array('path1'),
|
||||
array('path2'),
|
||||
array('namespaced_path1', 'namespace1'),
|
||||
array('namespaced_path2', 'namespace2'),
|
||||
array('namespaced_path3', 'namespace3'),
|
||||
array(__DIR__.'/Fixtures/templates/bundles/TwigBundle', 'Twig'),
|
||||
array(realpath(__DIR__.'/../..').'/Resources/views', 'Twig'),
|
||||
array(realpath(__DIR__.'/../..').'/Resources/views', '!Twig'),
|
||||
array(__DIR__.'/Fixtures/templates'),
|
||||
), $paths);
|
||||
$this->assertEquals([
|
||||
['path1'],
|
||||
['path2'],
|
||||
['namespaced_path1', 'namespace1'],
|
||||
['namespaced_path2', 'namespace2'],
|
||||
['namespaced_path3', 'namespace3'],
|
||||
[__DIR__.'/Fixtures/templates/bundles/TwigBundle', 'Twig'],
|
||||
[realpath(__DIR__.'/../..').'/Resources/views', 'Twig'],
|
||||
[realpath(__DIR__.'/../..').'/Resources/views', '!Twig'],
|
||||
[__DIR__.'/Fixtures/templates'],
|
||||
], $paths);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -215,35 +215,35 @@ class TwigExtensionTest extends TestCase
|
|||
$this->compileContainer($container);
|
||||
|
||||
$def = $container->getDefinition('twig.loader.native_filesystem');
|
||||
$paths = array();
|
||||
$paths = [];
|
||||
foreach ($def->getMethodCalls() as $call) {
|
||||
if ('addPath' === $call[0] && false === strpos($call[1][0], 'Form')) {
|
||||
$paths[] = $call[1];
|
||||
}
|
||||
}
|
||||
|
||||
$this->assertEquals(array(
|
||||
array('path1'),
|
||||
array('path2'),
|
||||
array('namespaced_path1', 'namespace1'),
|
||||
array('namespaced_path2', 'namespace2'),
|
||||
array('namespaced_path3', 'namespace3'),
|
||||
array(__DIR__.'/../Fixtures/templates/Resources/TwigBundle/views', 'Twig'),
|
||||
array(__DIR__.'/Fixtures/templates/bundles/TwigBundle', 'Twig'),
|
||||
array(realpath(__DIR__.'/../..').'/Resources/views', 'Twig'),
|
||||
array(realpath(__DIR__.'/../..').'/Resources/views', '!Twig'),
|
||||
array(__DIR__.'/../Fixtures/templates/Resources/views'),
|
||||
array(__DIR__.'/Fixtures/templates'),
|
||||
), $paths);
|
||||
$this->assertEquals([
|
||||
['path1'],
|
||||
['path2'],
|
||||
['namespaced_path1', 'namespace1'],
|
||||
['namespaced_path2', 'namespace2'],
|
||||
['namespaced_path3', 'namespace3'],
|
||||
[__DIR__.'/../Fixtures/templates/Resources/TwigBundle/views', 'Twig'],
|
||||
[__DIR__.'/Fixtures/templates/bundles/TwigBundle', 'Twig'],
|
||||
[realpath(__DIR__.'/../..').'/Resources/views', 'Twig'],
|
||||
[realpath(__DIR__.'/../..').'/Resources/views', '!Twig'],
|
||||
[__DIR__.'/../Fixtures/templates/Resources/views'],
|
||||
[__DIR__.'/Fixtures/templates'],
|
||||
], $paths);
|
||||
}
|
||||
|
||||
public function getFormats()
|
||||
{
|
||||
return array(
|
||||
array('php'),
|
||||
array('yml'),
|
||||
array('xml'),
|
||||
);
|
||||
return [
|
||||
['php'],
|
||||
['yml'],
|
||||
['xml'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -257,9 +257,9 @@ class TwigExtensionTest extends TestCase
|
|||
$container->register('debug.stopwatch', 'Symfony\Component\Stopwatch\Stopwatch');
|
||||
}
|
||||
$container->registerExtension(new TwigExtension());
|
||||
$container->loadFromExtension('twig', array(
|
||||
$container->loadFromExtension('twig', [
|
||||
'strict_variables' => false, // to be removed in 5.0 relying on default
|
||||
));
|
||||
]);
|
||||
$container->setAlias('test.twig.extension.debug.stopwatch', 'twig.extension.debug.stopwatch')->setPublic(true);
|
||||
$this->compileContainer($container);
|
||||
|
||||
|
@ -272,21 +272,21 @@ class TwigExtensionTest extends TestCase
|
|||
|
||||
public function stopwatchExtensionAvailabilityProvider()
|
||||
{
|
||||
return array(
|
||||
'debug-and-stopwatch-enabled' => array(true, true, true),
|
||||
'only-stopwatch-enabled' => array(false, true, false),
|
||||
'only-debug-enabled' => array(true, false, false),
|
||||
'debug-and-stopwatch-disabled' => array(false, false, false),
|
||||
);
|
||||
return [
|
||||
'debug-and-stopwatch-enabled' => [true, true, true],
|
||||
'only-stopwatch-enabled' => [false, true, false],
|
||||
'only-debug-enabled' => [true, false, false],
|
||||
'debug-and-stopwatch-disabled' => [false, false, false],
|
||||
];
|
||||
}
|
||||
|
||||
public function testRuntimeLoader()
|
||||
{
|
||||
$container = $this->createContainer();
|
||||
$container->registerExtension(new TwigExtension());
|
||||
$container->loadFromExtension('twig', array(
|
||||
$container->loadFromExtension('twig', [
|
||||
'strict_variables' => false, // to be removed in 5.0 relying on default
|
||||
));
|
||||
]);
|
||||
$container->setParameter('kernel.environment', 'test');
|
||||
$container->setParameter('debug.file_link_format', 'test');
|
||||
$container->setParameter('foo', 'FooClass');
|
||||
|
@ -295,7 +295,7 @@ class TwigExtensionTest extends TestCase
|
|||
$container->register('templating.name_parser', 'FooClass');
|
||||
$container->register('foo', '%foo%')->addTag('twig.runtime');
|
||||
$container->addCompilerPass(new RuntimeLoaderPass(), PassConfig::TYPE_BEFORE_REMOVING);
|
||||
$container->getCompilerPassConfig()->setRemovingPasses(array());
|
||||
$container->getCompilerPassConfig()->setRemovingPasses([]);
|
||||
$container->compile();
|
||||
|
||||
$loader = $container->getDefinition('twig.runtime_loader');
|
||||
|
@ -308,30 +308,30 @@ class TwigExtensionTest extends TestCase
|
|||
|
||||
private function createContainer(string $rootDir = __DIR__.'/Fixtures')
|
||||
{
|
||||
$container = new ContainerBuilder(new ParameterBag(array(
|
||||
$container = new ContainerBuilder(new ParameterBag([
|
||||
'kernel.cache_dir' => __DIR__,
|
||||
'kernel.root_dir' => $rootDir,
|
||||
'kernel.project_dir' => __DIR__,
|
||||
'kernel.charset' => 'UTF-8',
|
||||
'kernel.debug' => false,
|
||||
'kernel.bundles' => array(
|
||||
'kernel.bundles' => [
|
||||
'TwigBundle' => 'Symfony\\Bundle\\TwigBundle\\TwigBundle',
|
||||
),
|
||||
'kernel.bundles_metadata' => array(
|
||||
'TwigBundle' => array(
|
||||
],
|
||||
'kernel.bundles_metadata' => [
|
||||
'TwigBundle' => [
|
||||
'namespace' => 'Symfony\\Bundle\\TwigBundle',
|
||||
'path' => realpath(__DIR__.'/../..'),
|
||||
),
|
||||
),
|
||||
)));
|
||||
],
|
||||
],
|
||||
]));
|
||||
|
||||
return $container;
|
||||
}
|
||||
|
||||
private function compileContainer(ContainerBuilder $container)
|
||||
{
|
||||
$container->getCompilerPassConfig()->setOptimizationPasses(array());
|
||||
$container->getCompilerPassConfig()->setRemovingPasses(array());
|
||||
$container->getCompilerPassConfig()->setOptimizationPasses([]);
|
||||
$container->getCompilerPassConfig()->setRemovingPasses([]);
|
||||
$container->compile();
|
||||
}
|
||||
|
||||
|
|
|
@ -55,21 +55,21 @@ class NoTemplatingEntryKernel extends Kernel
|
|||
{
|
||||
public function registerBundles()
|
||||
{
|
||||
return array(new FrameworkBundle(), new TwigBundle());
|
||||
return [new FrameworkBundle(), new TwigBundle()];
|
||||
}
|
||||
|
||||
public function registerContainerConfiguration(LoaderInterface $loader)
|
||||
{
|
||||
$loader->load(function ($container) {
|
||||
$container
|
||||
->loadFromExtension('framework', array(
|
||||
->loadFromExtension('framework', [
|
||||
'secret' => '$ecret',
|
||||
'form' => array('enabled' => false),
|
||||
))
|
||||
->loadFromExtension('twig', array(
|
||||
'form' => ['enabled' => false],
|
||||
])
|
||||
->loadFromExtension('twig', [
|
||||
'strict_variables' => false, // to be removed in 5.0 relying on default
|
||||
'default_path' => __DIR__.'/templates',
|
||||
))
|
||||
])
|
||||
;
|
||||
});
|
||||
}
|
||||
|
|
|
@ -150,14 +150,14 @@ class WebServer
|
|||
throw new \RuntimeException('Unable to find the PHP binary.');
|
||||
}
|
||||
|
||||
$xdebugArgs = ini_get('xdebug.profiler_enable_trigger') ? array('-dxdebug.profiler_enable_trigger=1') : array();
|
||||
$xdebugArgs = ini_get('xdebug.profiler_enable_trigger') ? ['-dxdebug.profiler_enable_trigger=1'] : [];
|
||||
|
||||
$process = new Process(array_merge(array($binary), $finder->findArguments(), $xdebugArgs, array('-dvariables_order=EGPCS', '-S', $config->getAddress(), $config->getRouter())));
|
||||
$process = new Process(array_merge([$binary], $finder->findArguments(), $xdebugArgs, ['-dvariables_order=EGPCS', '-S', $config->getAddress(), $config->getRouter()]));
|
||||
$process->setWorkingDirectory($config->getDocumentRoot());
|
||||
$process->setTimeout(null);
|
||||
|
||||
if (\in_array('APP_ENV', explode(',', getenv('SYMFONY_DOTENV_VARS')))) {
|
||||
$process->setEnv(array('APP_ENV' => false));
|
||||
$process->setEnv(['APP_ENV' => false]);
|
||||
$process->inheritEnvironmentVariables();
|
||||
}
|
||||
|
||||
|
|
|
@ -29,33 +29,33 @@ class UrlPackageTest extends TestCase
|
|||
|
||||
public function getConfigs()
|
||||
{
|
||||
return array(
|
||||
array('http://example.net', '', 'http://example.com/foo', 'http://example.com/foo'),
|
||||
array('http://example.net', '', 'https://example.com/foo', 'https://example.com/foo'),
|
||||
array('http://example.net', '', '//example.com/foo', '//example.com/foo'),
|
||||
array('file:///example/net', '', 'file:///example/com/foo', 'file:///example/com/foo'),
|
||||
array('ftp://example.net', '', 'ftp://example.com', 'ftp://example.com'),
|
||||
return [
|
||||
['http://example.net', '', 'http://example.com/foo', 'http://example.com/foo'],
|
||||
['http://example.net', '', 'https://example.com/foo', 'https://example.com/foo'],
|
||||
['http://example.net', '', '//example.com/foo', '//example.com/foo'],
|
||||
['file:///example/net', '', 'file:///example/com/foo', 'file:///example/com/foo'],
|
||||
['ftp://example.net', '', 'ftp://example.com', 'ftp://example.com'],
|
||||
|
||||
array('http://example.com', '', '/foo', 'http://example.com/foo?v1'),
|
||||
array('http://example.com', '', 'foo', 'http://example.com/foo?v1'),
|
||||
array('http://example.com/', '', 'foo', 'http://example.com/foo?v1'),
|
||||
array('http://example.com/foo', '', 'foo', 'http://example.com/foo/foo?v1'),
|
||||
array('http://example.com/foo/', '', 'foo', 'http://example.com/foo/foo?v1'),
|
||||
array('file:///example/com/foo/', '', 'foo', 'file:///example/com/foo/foo?v1'),
|
||||
['http://example.com', '', '/foo', 'http://example.com/foo?v1'],
|
||||
['http://example.com', '', 'foo', 'http://example.com/foo?v1'],
|
||||
['http://example.com/', '', 'foo', 'http://example.com/foo?v1'],
|
||||
['http://example.com/foo', '', 'foo', 'http://example.com/foo/foo?v1'],
|
||||
['http://example.com/foo/', '', 'foo', 'http://example.com/foo/foo?v1'],
|
||||
['file:///example/com/foo/', '', 'foo', 'file:///example/com/foo/foo?v1'],
|
||||
|
||||
array(array('http://example.com'), '', '/foo', 'http://example.com/foo?v1'),
|
||||
array(array('http://example.com', 'http://example.net'), '', '/foo', 'http://example.com/foo?v1'),
|
||||
array(array('http://example.com', 'http://example.net'), '', '/fooa', 'http://example.net/fooa?v1'),
|
||||
array(array('file:///example/com', 'file:///example/net'), '', '/foo', 'file:///example/com/foo?v1'),
|
||||
array(array('ftp://example.com', 'ftp://example.net'), '', '/fooa', 'ftp://example.net/fooa?v1'),
|
||||
[['http://example.com'], '', '/foo', 'http://example.com/foo?v1'],
|
||||
[['http://example.com', 'http://example.net'], '', '/foo', 'http://example.com/foo?v1'],
|
||||
[['http://example.com', 'http://example.net'], '', '/fooa', 'http://example.net/fooa?v1'],
|
||||
[['file:///example/com', 'file:///example/net'], '', '/foo', 'file:///example/com/foo?v1'],
|
||||
[['ftp://example.com', 'ftp://example.net'], '', '/fooa', 'ftp://example.net/fooa?v1'],
|
||||
|
||||
array('http://example.com', 'version-%2$s/%1$s', '/foo', 'http://example.com/version-v1/foo'),
|
||||
array('http://example.com', 'version-%2$s/%1$s', 'foo', 'http://example.com/version-v1/foo'),
|
||||
array('http://example.com', 'version-%2$s/%1$s', 'foo/', 'http://example.com/version-v1/foo/'),
|
||||
array('http://example.com', 'version-%2$s/%1$s', '/foo/', 'http://example.com/version-v1/foo/'),
|
||||
array('file:///example/com', 'version-%2$s/%1$s', '/foo/', 'file:///example/com/version-v1/foo/'),
|
||||
array('ftp://example.com', 'version-%2$s/%1$s', '/foo/', 'ftp://example.com/version-v1/foo/'),
|
||||
);
|
||||
['http://example.com', 'version-%2$s/%1$s', '/foo', 'http://example.com/version-v1/foo'],
|
||||
['http://example.com', 'version-%2$s/%1$s', 'foo', 'http://example.com/version-v1/foo'],
|
||||
['http://example.com', 'version-%2$s/%1$s', 'foo/', 'http://example.com/version-v1/foo/'],
|
||||
['http://example.com', 'version-%2$s/%1$s', '/foo/', 'http://example.com/version-v1/foo/'],
|
||||
['file:///example/com', 'version-%2$s/%1$s', '/foo/', 'file:///example/com/version-v1/foo/'],
|
||||
['ftp://example.com', 'version-%2$s/%1$s', '/foo/', 'ftp://example.com/version-v1/foo/'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -70,18 +70,18 @@ class UrlPackageTest extends TestCase
|
|||
|
||||
public function getContextConfigs()
|
||||
{
|
||||
return array(
|
||||
array(false, 'http://example.com', '', 'foo', 'http://example.com/foo?v1'),
|
||||
array(false, array('http://example.com'), '', 'foo', 'http://example.com/foo?v1'),
|
||||
array(false, array('http://example.com', 'https://example.com'), '', 'foo', 'http://example.com/foo?v1'),
|
||||
array(false, array('http://example.com', 'https://example.com'), '', 'fooa', 'https://example.com/fooa?v1'),
|
||||
array(false, array('http://example.com/bar'), '', 'foo', 'http://example.com/bar/foo?v1'),
|
||||
array(false, array('http://example.com/bar/'), '', 'foo', 'http://example.com/bar/foo?v1'),
|
||||
array(false, array('//example.com/bar/'), '', 'foo', '//example.com/bar/foo?v1'),
|
||||
return [
|
||||
[false, 'http://example.com', '', 'foo', 'http://example.com/foo?v1'],
|
||||
[false, ['http://example.com'], '', 'foo', 'http://example.com/foo?v1'],
|
||||
[false, ['http://example.com', 'https://example.com'], '', 'foo', 'http://example.com/foo?v1'],
|
||||
[false, ['http://example.com', 'https://example.com'], '', 'fooa', 'https://example.com/fooa?v1'],
|
||||
[false, ['http://example.com/bar'], '', 'foo', 'http://example.com/bar/foo?v1'],
|
||||
[false, ['http://example.com/bar/'], '', 'foo', 'http://example.com/bar/foo?v1'],
|
||||
[false, ['//example.com/bar/'], '', 'foo', '//example.com/bar/foo?v1'],
|
||||
|
||||
array(true, array('http://example.com'), '', 'foo', 'http://example.com/foo?v1'),
|
||||
array(true, array('http://example.com', 'https://example.com'), '', 'foo', 'https://example.com/foo?v1'),
|
||||
);
|
||||
[true, ['http://example.com'], '', 'foo', 'http://example.com/foo?v1'],
|
||||
[true, ['http://example.com', 'https://example.com'], '', 'foo', 'https://example.com/foo?v1'],
|
||||
];
|
||||
}
|
||||
|
||||
public function testVersionStrategyGivesAbsoluteURL()
|
||||
|
@ -100,7 +100,7 @@ class UrlPackageTest extends TestCase
|
|||
*/
|
||||
public function testNoBaseUrls()
|
||||
{
|
||||
new UrlPackage(array(), new EmptyVersionStrategy());
|
||||
new UrlPackage([], new EmptyVersionStrategy());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -115,10 +115,10 @@ class UrlPackageTest extends TestCase
|
|||
|
||||
public function getWrongBaseUrlConfig()
|
||||
{
|
||||
return array(
|
||||
array('not-a-url'),
|
||||
array('not-a-url-with-query?query=://'),
|
||||
);
|
||||
return [
|
||||
['not-a-url'],
|
||||
['not-a-url-with-query?query=://'],
|
||||
];
|
||||
}
|
||||
|
||||
private function getContext($secure)
|
||||
|
|
|
@ -334,7 +334,7 @@ abstract class Client
|
|||
* @param string $method The HTTP method used to submit the form
|
||||
* @param array $serverParameters These values override the ones stored in $_SERVER (HTTP headers must include a HTTP_ prefix as PHP does)
|
||||
*/
|
||||
public function submitForm(string $button, array $fieldValues = array(), string $method = 'POST', array $serverParameters = array()): Crawler
|
||||
public function submitForm(string $button, array $fieldValues = [], string $method = 'POST', array $serverParameters = []): Crawler
|
||||
{
|
||||
if (null === $this->crawler) {
|
||||
throw new BadMethodCallException(sprintf('The "request()" method must be called before "%s()".', __METHOD__));
|
||||
|
@ -343,7 +343,7 @@ abstract class Client
|
|||
$buttonNode = $this->crawler->selectButton($button);
|
||||
$form = $buttonNode->form($fieldValues, $method);
|
||||
|
||||
return $this->submit($form, array(), $serverParameters);
|
||||
return $this->submit($form, [], $serverParameters);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -634,7 +634,7 @@ abstract class Client
|
|||
private function getMetaRefreshUrl(): ?string
|
||||
{
|
||||
$metaRefresh = $this->getCrawler()->filter('head meta[http-equiv="refresh"]');
|
||||
foreach ($metaRefresh->extract(array('content')) as $content) {
|
||||
foreach ($metaRefresh->extract(['content']) as $content) {
|
||||
if (preg_match('/^\s*0\s*;\s*URL\s*=\s*(?|\'([^\']++)|"([^"]++)|([^\'"].*))/i', $content, $m)) {
|
||||
return str_replace("\t\r\n", '', rtrim($m[1]));
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ class Cookie
|
|||
* Handles dates as defined by RFC 2616 section 3.3.1, and also some other
|
||||
* non-standard, but common formats.
|
||||
*/
|
||||
private static $dateFormats = array(
|
||||
private static $dateFormats = [
|
||||
'D, d M Y H:i:s T',
|
||||
'D, d-M-y H:i:s T',
|
||||
'D, d-M-Y H:i:s T',
|
||||
|
@ -30,7 +30,7 @@ class Cookie
|
|||
'D, d-m-Y H:i:s T',
|
||||
'D M j G:i:s Y',
|
||||
'D M d H:i:s Y T',
|
||||
);
|
||||
];
|
||||
|
||||
protected $name;
|
||||
protected $value;
|
||||
|
@ -136,7 +136,7 @@ class Cookie
|
|||
|
||||
list($name, $value) = explode('=', array_shift($parts), 2);
|
||||
|
||||
$values = array(
|
||||
$values = [
|
||||
'name' => trim($name),
|
||||
'value' => trim($value),
|
||||
'expires' => null,
|
||||
|
@ -146,7 +146,7 @@ class Cookie
|
|||
'httponly' => false,
|
||||
'passedRawValue' => true,
|
||||
'samesite' => null,
|
||||
);
|
||||
];
|
||||
|
||||
if (null !== $url) {
|
||||
if ((false === $urlParts = parse_url($url)) || !isset($urlParts['host'])) {
|
||||
|
|
|
@ -375,12 +375,12 @@ class ClientTest extends TestCase
|
|||
$client->setNextResponse(new Response('<html><form name="signup" action="/foo"><input type="text" name="username" value="the username" /><input type="password" name="password" value="the password" /><input type="submit" value="Register" /></form></html>'));
|
||||
$client->request('GET', 'http://www.example.com/foo/foobar');
|
||||
|
||||
$client->submitForm('Register', array(
|
||||
$client->submitForm('Register', [
|
||||
'username' => 'new username',
|
||||
'password' => 'new password',
|
||||
), 'PUT', array(
|
||||
], 'PUT', [
|
||||
'HTTP_USER_AGENT' => 'Symfony User Agent',
|
||||
));
|
||||
]);
|
||||
|
||||
$this->assertEquals('http://www.example.com/foo', $client->getRequest()->getUri(), '->submitForm() submit forms');
|
||||
$this->assertEquals('PUT', $client->getRequest()->getMethod(), '->submitForm() allows to change the method');
|
||||
|
@ -396,10 +396,10 @@ class ClientTest extends TestCase
|
|||
$client->request('GET', 'http://www.example.com/foo/foobar');
|
||||
|
||||
try {
|
||||
$client->submitForm('Register', array(
|
||||
$client->submitForm('Register', [
|
||||
'username' => 'username',
|
||||
'password' => 'password',
|
||||
), 'POST');
|
||||
], 'POST');
|
||||
$this->fail('->submitForm() throws a \InvalidArgumentException if the form could not be found');
|
||||
} catch (\Exception $e) {
|
||||
$this->assertInstanceOf('InvalidArgumentException', $e, '->submitForm() throws a \InvalidArgumentException if the form could not be found');
|
||||
|
@ -670,23 +670,23 @@ class ClientTest extends TestCase
|
|||
|
||||
public function getTestsForMetaRefresh()
|
||||
{
|
||||
return array(
|
||||
array('<html><head><meta http-equiv="Refresh" content="4" /><meta http-equiv="refresh" content="0; URL=http://www.example.com/redirected"/></head></html>', 'http://www.example.com/redirected'),
|
||||
array('<html><head><meta http-equiv="refresh" content="0;URL=http://www.example.com/redirected"/></head></html>', 'http://www.example.com/redirected'),
|
||||
array('<html><head><meta http-equiv="refresh" content="0;URL=\'http://www.example.com/redirected\'"/></head></html>', 'http://www.example.com/redirected'),
|
||||
array('<html><head><meta http-equiv="refresh" content=\'0;URL="http://www.example.com/redirected"\'/></head></html>', 'http://www.example.com/redirected'),
|
||||
array('<html><head><meta http-equiv="refresh" content="0; URL = http://www.example.com/redirected"/></head></html>', 'http://www.example.com/redirected'),
|
||||
array('<html><head><meta http-equiv="refresh" content="0;URL= http://www.example.com/redirected "/></head></html>', 'http://www.example.com/redirected'),
|
||||
array('<html><head><meta http-equiv="refresh" content="0;url=http://www.example.com/redirected "/></head></html>', 'http://www.example.com/redirected'),
|
||||
array('<html><head><noscript><meta http-equiv="refresh" content="0;URL=http://www.example.com/redirected"/></noscript></head></head></html>', 'http://www.example.com/redirected'),
|
||||
return [
|
||||
['<html><head><meta http-equiv="Refresh" content="4" /><meta http-equiv="refresh" content="0; URL=http://www.example.com/redirected"/></head></html>', 'http://www.example.com/redirected'],
|
||||
['<html><head><meta http-equiv="refresh" content="0;URL=http://www.example.com/redirected"/></head></html>', 'http://www.example.com/redirected'],
|
||||
['<html><head><meta http-equiv="refresh" content="0;URL=\'http://www.example.com/redirected\'"/></head></html>', 'http://www.example.com/redirected'],
|
||||
['<html><head><meta http-equiv="refresh" content=\'0;URL="http://www.example.com/redirected"\'/></head></html>', 'http://www.example.com/redirected'],
|
||||
['<html><head><meta http-equiv="refresh" content="0; URL = http://www.example.com/redirected"/></head></html>', 'http://www.example.com/redirected'],
|
||||
['<html><head><meta http-equiv="refresh" content="0;URL= http://www.example.com/redirected "/></head></html>', 'http://www.example.com/redirected'],
|
||||
['<html><head><meta http-equiv="refresh" content="0;url=http://www.example.com/redirected "/></head></html>', 'http://www.example.com/redirected'],
|
||||
['<html><head><noscript><meta http-equiv="refresh" content="0;URL=http://www.example.com/redirected"/></noscript></head></head></html>', 'http://www.example.com/redirected'],
|
||||
// Non-zero timeout should not result in a redirect.
|
||||
array('<html><head><meta http-equiv="refresh" content="4; URL=http://www.example.com/redirected"/></head></html>', 'http://www.example.com/foo/foobar'),
|
||||
array('<html><body></body></html>', 'http://www.example.com/foo/foobar'),
|
||||
['<html><head><meta http-equiv="refresh" content="4; URL=http://www.example.com/redirected"/></head></html>', 'http://www.example.com/foo/foobar'],
|
||||
['<html><body></body></html>', 'http://www.example.com/foo/foobar'],
|
||||
// Invalid meta tag placement should not result in a redirect.
|
||||
array('<html><body><meta http-equiv="refresh" content="0;url=http://www.example.com/redirected"/></body></html>', 'http://www.example.com/foo/foobar'),
|
||||
['<html><body><meta http-equiv="refresh" content="0;url=http://www.example.com/redirected"/></body></html>', 'http://www.example.com/foo/foobar'],
|
||||
// Valid meta refresh should not be followed if disabled.
|
||||
array('<html><head><meta http-equiv="refresh" content="0;URL=http://www.example.com/redirected"/></head></html>', 'http://www.example.com/foo/foobar', false),
|
||||
);
|
||||
['<html><head><meta http-equiv="refresh" content="0;URL=http://www.example.com/redirected"/></head></html>', 'http://www.example.com/foo/foobar', false],
|
||||
];
|
||||
}
|
||||
|
||||
public function testBack()
|
||||
|
@ -927,7 +927,7 @@ class ClassThatInheritClient extends Client
|
|||
return $response;
|
||||
}
|
||||
|
||||
public function submit(DomCrawlerForm $form, array $values = array())
|
||||
public function submit(DomCrawlerForm $form, array $values = [])
|
||||
{
|
||||
return parent::submit($form, $values);
|
||||
}
|
||||
|
|
|
@ -64,12 +64,12 @@ abstract class AbstractAdapter implements AdapterInterface, CacheInterface, Logg
|
|||
null,
|
||||
CacheItem::class
|
||||
);
|
||||
$getId = \Closure::fromCallable(array($this, 'getId'));
|
||||
$getId = \Closure::fromCallable([$this, 'getId']);
|
||||
$this->mergeByLifetime = \Closure::bind(
|
||||
function ($deferred, $namespace, &$expiredIds) use ($getId) {
|
||||
$byLifetime = array();
|
||||
$byLifetime = [];
|
||||
$now = microtime(true);
|
||||
$expiredIds = array();
|
||||
$expiredIds = [];
|
||||
|
||||
foreach ($deferred as $key => $item) {
|
||||
$key = (string) $key;
|
||||
|
@ -83,7 +83,7 @@ abstract class AbstractAdapter implements AdapterInterface, CacheInterface, Logg
|
|||
unset($metadata[CacheItem::METADATA_TAGS]);
|
||||
}
|
||||
// For compactness, expiry and creation duration are packed in the key of an array, using magic numbers as separators
|
||||
$byLifetime[$ttl][$getId($key)] = $metadata ? array("\x9D".pack('VN', (int) $metadata[CacheItem::METADATA_EXPIRY] - CacheItem::METADATA_EXPIRY_OFFSET, $metadata[CacheItem::METADATA_CTIME])."\x5F" => $item->value) : $item->value;
|
||||
$byLifetime[$ttl][$getId($key)] = $metadata ? ["\x9D".pack('VN', (int) $metadata[CacheItem::METADATA_EXPIRY] - CacheItem::METADATA_EXPIRY_OFFSET, $metadata[CacheItem::METADATA_CTIME])."\x5F" => $item->value] : $item->value;
|
||||
}
|
||||
|
||||
return $byLifetime;
|
||||
|
@ -131,7 +131,7 @@ abstract class AbstractAdapter implements AdapterInterface, CacheInterface, Logg
|
|||
return $apcu;
|
||||
}
|
||||
|
||||
public static function createConnection($dsn, array $options = array())
|
||||
public static function createConnection($dsn, array $options = [])
|
||||
{
|
||||
if (!\is_string($dsn)) {
|
||||
throw new InvalidArgumentException(sprintf('The %s() method expect argument #1 to be string, %s given.', __METHOD__, \gettype($dsn)));
|
||||
|
@ -161,11 +161,11 @@ abstract class AbstractAdapter implements AdapterInterface, CacheInterface, Logg
|
|||
$value = null;
|
||||
|
||||
try {
|
||||
foreach ($this->doFetch(array($id)) as $value) {
|
||||
foreach ($this->doFetch([$id]) as $value) {
|
||||
$isHit = true;
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
CacheItem::log($this->logger, 'Failed to fetch key "{key}"', array('key' => $key, 'exception' => $e));
|
||||
CacheItem::log($this->logger, 'Failed to fetch key "{key}"', ['key' => $key, 'exception' => $e]);
|
||||
}
|
||||
|
||||
return $f($key, $value, $isHit);
|
||||
|
@ -174,12 +174,12 @@ abstract class AbstractAdapter implements AdapterInterface, CacheInterface, Logg
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getItems(array $keys = array())
|
||||
public function getItems(array $keys = [])
|
||||
{
|
||||
if ($this->deferred) {
|
||||
$this->commit();
|
||||
}
|
||||
$ids = array();
|
||||
$ids = [];
|
||||
|
||||
foreach ($keys as $key) {
|
||||
$ids[] = $this->getId($key);
|
||||
|
@ -187,8 +187,8 @@ abstract class AbstractAdapter implements AdapterInterface, CacheInterface, Logg
|
|||
try {
|
||||
$items = $this->doFetch($ids);
|
||||
} catch (\Exception $e) {
|
||||
CacheItem::log($this->logger, 'Failed to fetch requested items', array('keys' => $keys, 'exception' => $e));
|
||||
$items = array();
|
||||
CacheItem::log($this->logger, 'Failed to fetch requested items', ['keys' => $keys, 'exception' => $e]);
|
||||
$items = [];
|
||||
}
|
||||
$ids = array_combine($ids, $keys);
|
||||
|
||||
|
@ -229,7 +229,7 @@ abstract class AbstractAdapter implements AdapterInterface, CacheInterface, Logg
|
|||
$ok = true;
|
||||
$byLifetime = $this->mergeByLifetime;
|
||||
$byLifetime = $byLifetime($this->deferred, $this->namespace, $expiredIds);
|
||||
$retry = $this->deferred = array();
|
||||
$retry = $this->deferred = [];
|
||||
|
||||
if ($expiredIds) {
|
||||
$this->doDelete($expiredIds);
|
||||
|
@ -239,7 +239,7 @@ abstract class AbstractAdapter implements AdapterInterface, CacheInterface, Logg
|
|||
$e = $this->doSave($values, $lifetime);
|
||||
} catch (\Exception $e) {
|
||||
}
|
||||
if (true === $e || array() === $e) {
|
||||
if (true === $e || [] === $e) {
|
||||
continue;
|
||||
}
|
||||
if (\is_array($e) || 1 === \count($values)) {
|
||||
|
@ -247,7 +247,7 @@ abstract class AbstractAdapter implements AdapterInterface, CacheInterface, Logg
|
|||
$ok = false;
|
||||
$v = $values[$id];
|
||||
$type = \is_object($v) ? \get_class($v) : \gettype($v);
|
||||
CacheItem::log($this->logger, 'Failed to save key "{key}" ({type})', array('key' => substr($id, \strlen($this->namespace)), 'type' => $type, 'exception' => $e instanceof \Exception ? $e : null));
|
||||
CacheItem::log($this->logger, 'Failed to save key "{key}" ({type})', ['key' => substr($id, \strlen($this->namespace)), 'type' => $type, 'exception' => $e instanceof \Exception ? $e : null]);
|
||||
}
|
||||
} else {
|
||||
foreach ($values as $id => $v) {
|
||||
|
@ -261,15 +261,15 @@ abstract class AbstractAdapter implements AdapterInterface, CacheInterface, Logg
|
|||
foreach ($ids as $id) {
|
||||
try {
|
||||
$v = $byLifetime[$lifetime][$id];
|
||||
$e = $this->doSave(array($id => $v), $lifetime);
|
||||
$e = $this->doSave([$id => $v], $lifetime);
|
||||
} catch (\Exception $e) {
|
||||
}
|
||||
if (true === $e || array() === $e) {
|
||||
if (true === $e || [] === $e) {
|
||||
continue;
|
||||
}
|
||||
$ok = false;
|
||||
$type = \is_object($v) ? \get_class($v) : \gettype($v);
|
||||
CacheItem::log($this->logger, 'Failed to save key "{key}" ({type})', array('key' => substr($id, \strlen($this->namespace)), 'type' => $type, 'exception' => $e instanceof \Exception ? $e : null));
|
||||
CacheItem::log($this->logger, 'Failed to save key "{key}" ({type})', ['key' => substr($id, \strlen($this->namespace)), 'type' => $type, 'exception' => $e instanceof \Exception ? $e : null]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -297,7 +297,7 @@ abstract class AbstractAdapter implements AdapterInterface, CacheInterface, Logg
|
|||
yield $key => $f($key, $value, true);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
CacheItem::log($this->logger, 'Failed to fetch requested items', array('keys' => array_values($keys), 'exception' => $e));
|
||||
CacheItem::log($this->logger, 'Failed to fetch requested items', ['keys' => array_values($keys), 'exception' => $e]);
|
||||
}
|
||||
|
||||
foreach ($keys as $key) {
|
||||
|
|
|
@ -83,7 +83,7 @@ class ArrayAdapter implements AdapterInterface, CacheInterface, LoggerAwareInter
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getItems(array $keys = array())
|
||||
public function getItems(array $keys = [])
|
||||
{
|
||||
foreach ($keys as $key) {
|
||||
if (!\is_string($key) || !isset($this->expiries[$key])) {
|
||||
|
|
|
@ -33,7 +33,7 @@ class ChainAdapter implements AdapterInterface, CacheInterface, PruneableInterfa
|
|||
{
|
||||
use ContractsTrait;
|
||||
|
||||
private $adapters = array();
|
||||
private $adapters = [];
|
||||
private $adapterCount;
|
||||
private $syncItem;
|
||||
|
||||
|
@ -118,7 +118,7 @@ class ChainAdapter implements AdapterInterface, CacheInterface, PruneableInterfa
|
|||
public function getItem($key)
|
||||
{
|
||||
$syncItem = $this->syncItem;
|
||||
$misses = array();
|
||||
$misses = [];
|
||||
|
||||
foreach ($this->adapters as $i => $adapter) {
|
||||
$item = $adapter->getItem($key);
|
||||
|
@ -140,15 +140,15 @@ class ChainAdapter implements AdapterInterface, CacheInterface, PruneableInterfa
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getItems(array $keys = array())
|
||||
public function getItems(array $keys = [])
|
||||
{
|
||||
return $this->generateItems($this->adapters[0]->getItems($keys), 0);
|
||||
}
|
||||
|
||||
private function generateItems($items, $adapterIndex)
|
||||
{
|
||||
$missing = array();
|
||||
$misses = array();
|
||||
$missing = [];
|
||||
$misses = [];
|
||||
$nextAdapterIndex = $adapterIndex + 1;
|
||||
$nextAdapter = isset($this->adapters[$nextAdapterIndex]) ? $this->adapters[$nextAdapterIndex] : null;
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ class PdoAdapter extends AbstractAdapter implements PruneableInterface
|
|||
* @throws InvalidArgumentException When PDO error mode is not PDO::ERRMODE_EXCEPTION
|
||||
* @throws InvalidArgumentException When namespace contains invalid characters
|
||||
*/
|
||||
public function __construct($connOrDsn, string $namespace = '', int $defaultLifetime = 0, array $options = array(), MarshallerInterface $marshaller = null)
|
||||
public function __construct($connOrDsn, string $namespace = '', int $defaultLifetime = 0, array $options = [], MarshallerInterface $marshaller = null)
|
||||
{
|
||||
$this->init($connOrDsn, $namespace, $defaultLifetime, $options, $marshaller);
|
||||
}
|
||||
|
|
|
@ -78,7 +78,7 @@ class ProxyAdapter implements AdapterInterface, CacheInterface, PruneableInterfa
|
|||
}
|
||||
if ($metadata) {
|
||||
// For compactness, expiry and creation duration are packed in the key of an array, using magic numbers as separators
|
||||
$item["\0*\0value"] = array("\x9D".pack('VN', (int) $metadata[CacheItem::METADATA_EXPIRY] - CacheItem::METADATA_EXPIRY_OFFSET, $metadata[CacheItem::METADATA_CTIME])."\x5F" => $item["\0*\0value"]);
|
||||
$item["\0*\0value"] = ["\x9D".pack('VN', (int) $metadata[CacheItem::METADATA_EXPIRY] - CacheItem::METADATA_EXPIRY_OFFSET, $metadata[CacheItem::METADATA_CTIME])."\x5F" => $item["\0*\0value"]];
|
||||
}
|
||||
$innerItem->set($item["\0*\0value"]);
|
||||
$innerItem->expiresAt(null !== $item["\0*\0expiry"] ? \DateTime::createFromFormat('U.u', sprintf('%.6f', $item["\0*\0expiry"])) : null);
|
||||
|
|
|
@ -84,7 +84,7 @@ class TagAwareAdapter implements TagAwareAdapterInterface, TagAwareCacheInterfac
|
|||
function ($deferred) {
|
||||
$tagsByKey = [];
|
||||
foreach ($deferred as $key => $item) {
|
||||
$tagsByKey[$key] = $item->newMetadata[CacheItem::METADATA_TAGS] ?? array();
|
||||
$tagsByKey[$key] = $item->newMetadata[CacheItem::METADATA_TAGS] ?? [];
|
||||
}
|
||||
|
||||
return $tagsByKey;
|
||||
|
|
|
@ -28,8 +28,8 @@ final class CacheItem implements ItemInterface
|
|||
protected $isHit = false;
|
||||
protected $expiry;
|
||||
protected $defaultLifetime;
|
||||
protected $metadata = array();
|
||||
protected $newMetadata = array();
|
||||
protected $metadata = [];
|
||||
protected $newMetadata = [];
|
||||
protected $innerItem;
|
||||
protected $poolHash;
|
||||
protected $isTaggable = false;
|
||||
|
@ -111,7 +111,7 @@ final class CacheItem implements ItemInterface
|
|||
throw new LogicException(sprintf('Cache item "%s" comes from a non tag-aware pool: you cannot tag it.', $this->key));
|
||||
}
|
||||
if (!\is_iterable($tags)) {
|
||||
$tags = array($tags);
|
||||
$tags = [$tags];
|
||||
}
|
||||
foreach ($tags as $tag) {
|
||||
if (!\is_string($tag)) {
|
||||
|
@ -151,7 +151,7 @@ final class CacheItem implements ItemInterface
|
|||
{
|
||||
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.2, use the "getMetadata()" method instead.', __METHOD__), E_USER_DEPRECATED);
|
||||
|
||||
return $this->metadata[self::METADATA_TAGS] ?? array();
|
||||
return $this->metadata[self::METADATA_TAGS] ?? [];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -183,12 +183,12 @@ final class CacheItem implements ItemInterface
|
|||
*
|
||||
* @internal
|
||||
*/
|
||||
public static function log(LoggerInterface $logger = null, $message, $context = array())
|
||||
public static function log(LoggerInterface $logger = null, $message, $context = [])
|
||||
{
|
||||
if ($logger) {
|
||||
$logger->warning($message, $context);
|
||||
} else {
|
||||
$replace = array();
|
||||
$replace = [];
|
||||
foreach ($context as $k => $v) {
|
||||
if (is_scalar($v)) {
|
||||
$replace['{'.$k.'}'] = $v;
|
||||
|
|
|
@ -56,16 +56,16 @@ class CacheCollectorPass implements CompilerPassInterface
|
|||
$recorder = new Definition(is_subclass_of($definition->getClass(), TagAwareAdapterInterface::class) ? TraceableTagAwareAdapter::class : TraceableAdapter::class);
|
||||
$recorder->setTags($definition->getTags());
|
||||
$recorder->setPublic($definition->isPublic());
|
||||
$recorder->setArguments(array(new Reference($innerId = $id.$this->cachePoolRecorderInnerSuffix)));
|
||||
$recorder->setArguments([new Reference($innerId = $id.$this->cachePoolRecorderInnerSuffix)]);
|
||||
|
||||
$definition->setTags(array());
|
||||
$definition->setTags([]);
|
||||
$definition->setPublic(false);
|
||||
|
||||
$container->setDefinition($innerId, $definition);
|
||||
$container->setDefinition($id, $recorder);
|
||||
|
||||
// Tell the collector to add the new instance
|
||||
$collectorDefinition->addMethodCall('addInstance', array($id, new Reference($id)));
|
||||
$collectorDefinition->addMethodCall('addInstance', [$id, new Reference($id)]);
|
||||
$collectorDefinition->setPublic(false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ class CachePoolClearerPass implements CompilerPassInterface
|
|||
|
||||
foreach ($container->findTaggedServiceIds($this->cachePoolClearerTag) as $id => $attr) {
|
||||
$clearer = $container->getDefinition($id);
|
||||
$pools = array();
|
||||
$pools = [];
|
||||
foreach ($clearer->getArgument(0) as $name => $ref) {
|
||||
if ($container->hasDefinition($ref)) {
|
||||
$pools[$name] = new Reference($ref);
|
||||
|
|
|
@ -54,15 +54,15 @@ class CachePoolPass implements CompilerPassInterface
|
|||
}
|
||||
$seed .= '.'.$container->getParameter('kernel.container_class');
|
||||
|
||||
$pools = array();
|
||||
$clearers = array();
|
||||
$attributes = array(
|
||||
$pools = [];
|
||||
$clearers = [];
|
||||
$attributes = [
|
||||
'provider',
|
||||
'name',
|
||||
'namespace',
|
||||
'default_lifetime',
|
||||
'reset',
|
||||
);
|
||||
];
|
||||
foreach ($container->findTaggedServiceIds($this->cachePoolTag) as $id => $tags) {
|
||||
$adapter = $pool = $container->getDefinition($id);
|
||||
if ($pool->isAbstract()) {
|
||||
|
@ -97,7 +97,7 @@ class CachePoolPass implements CompilerPassInterface
|
|||
// no-op
|
||||
} elseif ('reset' === $attr) {
|
||||
if ($tags[0][$attr]) {
|
||||
$pool->addTag($this->kernelResetTag, array('method' => $tags[0][$attr]));
|
||||
$pool->addTag($this->kernelResetTag, ['method' => $tags[0][$attr]]);
|
||||
}
|
||||
} elseif ('namespace' !== $attr || ArrayAdapter::class !== $adapter->getClass()) {
|
||||
$pool->replaceArgument($i++, $tags[0][$attr]);
|
||||
|
@ -156,8 +156,8 @@ class CachePoolPass implements CompilerPassInterface
|
|||
if (!$container->hasDefinition($name = '.cache_connection.'.ContainerBuilder::hash($dsn))) {
|
||||
$definition = new Definition(AbstractAdapter::class);
|
||||
$definition->setPublic(false);
|
||||
$definition->setFactory(array(AbstractAdapter::class, 'createConnection'));
|
||||
$definition->setArguments(array($dsn, array('lazy' => true)));
|
||||
$definition->setFactory([AbstractAdapter::class, 'createConnection']);
|
||||
$definition->setArguments([$dsn, ['lazy' => true]]);
|
||||
$container->setDefinition($name, $definition);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ class CachePoolPrunerPass implements CompilerPassInterface
|
|||
return;
|
||||
}
|
||||
|
||||
$services = array();
|
||||
$services = [];
|
||||
|
||||
foreach ($container->findTaggedServiceIds($this->cachePoolTag) as $id => $tags) {
|
||||
$class = $container->getParameterBag()->resolveValue($container->getDefinition($id)->getClass());
|
||||
|
|
|
@ -25,13 +25,13 @@ use Symfony\Contracts\Cache\ItemInterface;
|
|||
*/
|
||||
class LockRegistry
|
||||
{
|
||||
private static $openedFiles = array();
|
||||
private static $lockedFiles = array();
|
||||
private static $openedFiles = [];
|
||||
private static $lockedFiles = [];
|
||||
|
||||
/**
|
||||
* The number of items in this list controls the max number of concurrent processes.
|
||||
*/
|
||||
private static $files = array(
|
||||
private static $files = [
|
||||
__DIR__.\DIRECTORY_SEPARATOR.'Adapter'.\DIRECTORY_SEPARATOR.'AbstractAdapter.php',
|
||||
__DIR__.\DIRECTORY_SEPARATOR.'Adapter'.\DIRECTORY_SEPARATOR.'AdapterInterface.php',
|
||||
__DIR__.\DIRECTORY_SEPARATOR.'Adapter'.\DIRECTORY_SEPARATOR.'ApcuAdapter.php',
|
||||
|
@ -51,7 +51,7 @@ class LockRegistry
|
|||
__DIR__.\DIRECTORY_SEPARATOR.'Adapter'.\DIRECTORY_SEPARATOR.'TagAwareAdapterInterface.php',
|
||||
__DIR__.\DIRECTORY_SEPARATOR.'Adapter'.\DIRECTORY_SEPARATOR.'TraceableAdapter.php',
|
||||
__DIR__.\DIRECTORY_SEPARATOR.'Adapter'.\DIRECTORY_SEPARATOR.'TraceableTagAwareAdapter.php',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Defines a set of existing files that will be used as keys to acquire locks.
|
||||
|
@ -69,7 +69,7 @@ class LockRegistry
|
|||
fclose($file);
|
||||
}
|
||||
}
|
||||
self::$openedFiles = self::$lockedFiles = array();
|
||||
self::$openedFiles = self::$lockedFiles = [];
|
||||
|
||||
return $previousFiles;
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue