Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a4440f9

Browse filesBrowse files
chore: (2/2) Replace long with short syntax.
1 parent 96f68fe commit a4440f9
Copy full SHA for a4440f9

File tree

Expand file treeCollapse file tree

302 files changed

+2544
-2542
lines changed
Filter options

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree

302 files changed

+2544
-2542
lines changed

‎components/cache/adapters/chain_adapter.rst

Copy file name to clipboardExpand all lines: components/cache/adapters/chain_adapter.rst
+6-6Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ lifetime as its constructor arguments::
1717

1818
use Symfony\Component\Cache\Adapter\ApcuAdapter;
1919

20-
$cache = new ChainAdapter(array(
20+
$cache = new ChainAdapter([
2121

2222
// The ordered list of adapters used to fetch cached items
2323
array $adapters,
2424

2525
// The max lifetime of items propagated from lower adapters to upper ones
2626
$maxLifetime = 0
27-
));
27+
]);
2828

2929
.. note::
3030

@@ -40,10 +40,10 @@ slowest storage engines, :class:`Symfony\\Component\\Cache\\Adapter\\ApcuAdapter
4040
use Symfony\Component\Cache\Adapter\ChainAdapter;
4141
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
4242

43-
$cache = new ChainAdapter(array(
43+
$cache = new ChainAdapter([
4444
new ApcuAdapter(),
4545
new FilesystemAdapter(),
46-
));
46+
]);
4747

4848
When calling this adapter's :method:`Symfony\\Component\\Cache\\ChainAdapter::prune` method,
4949
the call is delegated to all its compatible cache adapters. It is safe to mix both adapters
@@ -54,10 +54,10 @@ incompatible adapters are silently ignored::
5454
use Symfony\Component\Cache\Adapter\ChainAdapter;
5555
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
5656

57-
$cache = new ChainAdapter(array(
57+
$cache = new ChainAdapter([
5858
new ApcuAdapter(), // does NOT implement PruneableInterface
5959
new FilesystemAdapter(), // DOES implement PruneableInterface
60-
));
60+
]);
6161

6262
// prune will proxy the call to FilesystemAdapter while silently skipping ApcuAdapter
6363
$cache->prune();

‎components/cache/adapters/memcached_adapter.rst

Copy file name to clipboardExpand all lines: components/cache/adapters/memcached_adapter.rst
+6-6Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,12 @@ helper method allows creating and configuring a `Memcached`_ class instance usin
6161
);
6262

6363
// pass an array of DSN strings to register multiple servers with the client
64-
$client = MemcachedAdapter::createConnection(array(
64+
$client = MemcachedAdapter::createConnection([
6565
'memcached://10.0.0.100',
6666
'memcached://10.0.0.101',
6767
'memcached://10.0.0.102',
6868
// etc...
69-
));
69+
]);
7070

7171
.. versionadded:: 3.4
7272

@@ -90,7 +90,7 @@ Below are common examples of valid DSNs showing a combination of available value
9090

9191
use Symfony\Component\Cache\Adapter\MemcachedAdapter;
9292

93-
$client = MemcachedAdapter::createConnection(array(
93+
$client = MemcachedAdapter::createConnection([
9494
// hostname + port
9595
'memcached://my.server.com:11211'
9696

@@ -105,7 +105,7 @@ Below are common examples of valid DSNs showing a combination of available value
105105

106106
// socket instead of hostname/IP + weight
107107
'memcached:///var/run/memcached.sock?weight=20'
108-
));
108+
]);
109109

110110
Configure the Options
111111
---------------------
@@ -122,11 +122,11 @@ option names and their respective values::
122122
[],
123123

124124
// associative array of configuration options
125-
array(
125+
[
126126
'compression' => true,
127127
'libketama_compatible' => true,
128128
'serializer' => 'igbinary',
129-
)
129+
]
130130
);
131131

132132
Available Options

‎components/cache/adapters/php_array_cache_adapter.rst

Copy file name to clipboardExpand all lines: components/cache/adapters/php_array_cache_adapter.rst
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ that is optimized and preloaded into OPcache memory storage::
1414
// somehow, decide it's time to warm up the cache!
1515
if ($needsWarmup) {
1616
// some static values
17-
$values = array(
17+
$values = [
1818
'stats.products_count' => 4711,
1919
'stats.users_count' => 1356,
20-
);
20+
];
2121

2222
$cache = new PhpArrayAdapter(
2323
// single file where values are cached

‎components/cache/adapters/php_files_adapter.rst

Copy file name to clipboardExpand all lines: components/cache/adapters/php_files_adapter.rst
+5-5Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,22 @@ Php Files Cache Adapter
1010
Similarly to :ref:`Filesystem Adapter <component-cache-filesystem-adapter>`, this cache
1111
implementation writes cache entries out to disk, but unlike the Filesystem cache adapter,
1212
the PHP Files cache adapter writes and reads back these cache files *as native PHP code*.
13-
For example, caching the value ``array('my', 'cached', 'array')`` will write out a cache
13+
For example, caching the value ``['my', 'cached', 'array']`` will write out a cache
1414
file similar to the following::
1515

16-
<?php return array(
16+
<?php return [
1717

1818
// the cache item expiration
1919
0 => 9223372036854775807,
2020

2121
// the cache item contents
22-
1 => array (
22+
1 => [
2323
0 => 'my',
2424
1 => 'cached',
2525
2 => 'array',
26-
),
26+
],
2727

28-
);
28+
];
2929

3030
.. note::
3131

‎components/cache/adapters/redis_adapter.rst

Copy file name to clipboardExpand all lines: components/cache/adapters/redis_adapter.rst
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,14 @@ array of ``key => value`` pairs representing option names and their respective v
9595
'redis://localhost:6379',
9696

9797
// associative array of configuration options
98-
array(
98+
[
9999
'lazy' => false,
100100
'persistent' => 0,
101101
'persistent_id' => null,
102102
'timeout' => 30,
103103
'read_timeout' => 0,
104104
'retry_interval' => 0,
105-
)
105+
]
106106

107107
);
108108

‎components/cache/cache_invalidation.rst

Copy file name to clipboardExpand all lines: components/cache/cache_invalidation.rst
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,15 @@ cache items, as returned by cache adapters::
3636
// ...
3737
// add one or more tags
3838
$item->tag('tag_1');
39-
$item->tag(array('tag_2', 'tag_3'));
39+
$item->tag(['tag_2', 'tag_3'[);
4040
$cache->save($item);
4141

4242
If ``$cache`` implements :class:`Symfony\\Component\\Cache\\Adapter\\TagAwareAdapterInterface`,
4343
you can invalidate the cached items by calling
4444
:method:`Symfony\\Component\\Cache\\Adapter\\TagAwareAdapterInterface::invalidateTags`::
4545

4646
// invalidate all items related to `tag_1` or `tag_3`
47-
$cache->invalidateTags(array('tag_1', 'tag_3'));
47+
$cache->invalidateTags(['tag_1', 'tag_3']);
4848

4949
// if you know the cache key, you can also delete the item directly
5050
$cache->deleteItem('cache_key');

‎components/cache/cache_items.rst

Copy file name to clipboardExpand all lines: components/cache/cache_items.rst
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ the data stored in the cache item::
4141
$cache->save($productsCount);
4242

4343
// storing an array
44-
$productsCount->set(array(
44+
$productsCount->set([
4545
'category1' => 4711,
4646
'category2' => 2387,
47-
));
47+
]);
4848
$cache->save($productsCount);
4949

5050
The key and the value of any given cache item can be obtained with the

‎components/cache/cache_pools.rst

Copy file name to clipboardExpand all lines: components/cache/cache_pools.rst
+5-5Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ value but an empty object which implements the :class:`Symfony\\Component\\Cache
5151
class.
5252

5353
If you need to fetch several cache items simultaneously, use instead the
54-
``getItems(array($key1, $key2, ...))`` method::
54+
``getItems([$key1, $key2, ...])`` method::
5555

5656
// ...
57-
$stocks = $cache->getItems(array('AAPL', 'FB', 'GOOGL', 'MSFT'));
57+
$stocks = $cache->getItems(['AAPL', 'FB', 'GOOGL', 'MSFT']);
5858

5959
Again, if any of the keys doesn't represent a valid cache item, you won't get
6060
a ``null`` value but an empty ``CacheItem`` object.
@@ -115,7 +115,7 @@ delete several cache items simultaneously (it returns ``true`` only if all the
115115
items have been deleted, even when any or some of them don't exist)::
116116

117117
// ...
118-
$areDeleted = $cache->deleteItems(array('category1', 'category2'));
118+
$areDeleted = $cache->deleteItems(['category1', 'category2']);
119119

120120
Finally, to remove all the cache items stored in the pool, use the
121121
``Psr\\Cache\\CacheItemPoolInterface::clear`` method (which returns ``true``
@@ -190,13 +190,13 @@ silently ignored)::
190190
use Symfony\Component\Cache\Adapter\PdoAdapter;
191191
use Symfony\Component\Cache\Adapter\PhpFilesAdapter;
192192

193-
$cache = new ChainAdapter(array(
193+
$cache = new ChainAdapter([
194194
new ApcuAdapter(), // does NOT implement PruneableInterface
195195
new FilesystemAdapter(), // DOES implement PruneableInterface
196196
new PdoAdapter(), // DOES implement PruneableInterface
197197
new PhpFilesAdapter(), // DOES implement PruneableInterface
198198
// ...
199-
));
199+
]);
200200

201201
// prune will proxy the call to PdoAdapter, FilesystemAdapter and PhpFilesAdapter,
202202
// while silently skipping ApcuAdapter

‎components/class_loader/class_loader.rst

Copy file name to clipboardExpand all lines: components/class_loader/class_loader.rst
+6-6Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,29 +41,29 @@ your classes::
4141
$loader->addPrefix('Symfony', __DIR__.'/vendor/symfony/symfony/src');
4242

4343
// registers several namespaces at once
44-
$loader->addPrefixes(array(
44+
$loader->addPrefixes([
4545
'Symfony' => __DIR__.'/../vendor/symfony/symfony/src',
4646
'Monolog' => __DIR__.'/../vendor/monolog/monolog/src',
47-
));
47+
]);
4848

4949
// registers a prefix for a class following the PEAR naming conventions
5050
$loader->addPrefix('Twig_', __DIR__.'/vendor/twig/twig/lib');
5151

52-
$loader->addPrefixes(array(
52+
$loader->addPrefixes([
5353
'Swift_' => __DIR__.'/vendor/swiftmailer/swiftmailer/lib/classes',
5454
'Twig_' => __DIR__.'/vendor/twig/twig/lib',
55-
));
55+
]);
5656

5757
Classes from a sub-namespace or a sub-hierarchy of `PEAR`_ classes can be
5858
looked for in a location list to ease the vendoring of a sub-set of classes
5959
for large projects::
6060

61-
$loader->addPrefixes(array(
61+
$loader->addPrefixes([
6262
'Doctrine\Common' => __DIR__.'/vendor/doctrine/common/lib',
6363
'Doctrine\DBAL\Migrations' => __DIR__.'/vendor/doctrine/migrations/lib',
6464
'Doctrine\DBAL' => __DIR__.'/vendor/doctrine/dbal/lib',
6565
'Doctrine' => __DIR__.'/vendor/doctrine/orm/lib',
66-
));
66+
]);
6767

6868
In this example, if you try to use a class in the ``Doctrine\Common`` namespace
6969
or one of its children, the autoloader will first look for the class under

‎components/class_loader/class_map_generator.rst

Copy file name to clipboardExpand all lines: components/class_loader/class_map_generator.rst
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ is the same as in the example above)::
119119
use Symfony\Component\ClassLoader\ClassMapGenerator;
120120

121121
ClassMapGenerator::dump(
122-
array(__DIR__.'/library/bar', __DIR__.'/library/foo'),
122+
[__DIR__.'/library/bar', __DIR__.'/library/foo'],
123123
__DIR__.'/class_map.php'
124124
);
125125

‎components/class_loader/map_class_loader.rst

Copy file name to clipboardExpand all lines: components/class_loader/map_class_loader.rst
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ an instance of the ``MapClassLoader`` class::
2929

3030
require_once '/path/to/src/Symfony/Component/ClassLoader/MapClassLoader.php';
3131

32-
$mapping = array(
32+
$mapping = [
3333
'Foo' => '/path/to/Foo',
3434
'Bar' => '/path/to/Bar',
35-
);
35+
];
3636

3737
$loader = new MapClassLoader($mapping);
3838

‎components/config/definition.rst

Copy file name to clipboardExpand all lines: components/config/definition.rst
+7-7Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ values::
143143
$rootNode
144144
->children()
145145
->enumNode('delivery')
146-
->values(array('standard', 'expedited', 'priority'))
146+
->values(['standard', 'expedited', 'priority'])
147147
->end()
148148
->end()
149149
;
@@ -509,9 +509,9 @@ methods::
509509
// is equivalent to
510510

511511
$arrayNode
512-
->treatFalseLike(array('enabled' => false))
513-
->treatTrueLike(array('enabled' => true))
514-
->treatNullLike(array('enabled' => true))
512+
->treatFalseLike(['enabled' => false])
513+
->treatTrueLike(['enabled' => true])
514+
->treatNullLike(['enabled' => true])
515515
->children()
516516
->booleanNode('enabled')
517517
->defaultFalse()
@@ -742,7 +742,7 @@ By changing a string value into an associative array with ``name`` as the key::
742742
->arrayNode('connection')
743743
->beforeNormalization()
744744
->ifString()
745-
->then(function ($v) { return array('name' => $v); })
745+
->then(function ($v) { return ['name' => $v]; })
746746
->end()
747747
->children()
748748
->scalarNode('name')->isRequired()
@@ -767,7 +767,7 @@ The builder is used for adding advanced validation rules to node definitions, li
767767
->scalarNode('driver')
768768
->isRequired()
769769
->validate()
770-
->ifNotInArray(array('mysql', 'sqlite', 'mssql'))
770+
->ifNotInArray(['mysql', 'sqlite', 'mssql'])
771771
->thenInvalid('Invalid database driver %s')
772772
->end()
773773
->end()
@@ -820,7 +820,7 @@ Otherwise the result is a clean array of configuration values::
820820
file_get_contents(__DIR__.'/src/Matthias/config/config_extra.yml')
821821
);
822822

823-
$configs = array($config, $extraConfig);
823+
$configs = [$config, $extraConfig];
824824

825825
$processor = new Processor();
826826
$databaseConfiguration = new DatabaseConfiguration();

‎components/config/resources.rst

Copy file name to clipboardExpand all lines: components/config/resources.rst
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ files. This can be done with the :class:`Symfony\\Component\\Config\\FileLocator
1919

2020
use Symfony\Component\Config\FileLocator;
2121

22-
$configDirectories = array(__DIR__.'/app/config');
22+
$configDirectories = [__DIR__.'/app/config'];
2323

2424
$fileLocator = new FileLocator($configDirectories);
2525
$yamlUserFiles = $fileLocator->locate('users.yml', null, false);
@@ -84,7 +84,7 @@ the resource::
8484
use Symfony\Component\Config\Loader\LoaderResolver;
8585
use Symfony\Component\Config\Loader\DelegatingLoader;
8686

87-
$loaderResolver = new LoaderResolver(array(new YamlUserLoader($fileLocator)));
87+
$loaderResolver = new LoaderResolver([new YamlUserLoader($fileLocator)]);
8888
$delegatingLoader = new DelegatingLoader($loaderResolver);
8989

9090
// YamlUserLoader is used to load this resource because it supports

‎components/console/console_arguments.rst

Copy file name to clipboardExpand all lines: components/console/console_arguments.rst
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ Have a look at the following command that has three options::
2929
->setName('demo:args')
3030
->setDescription('Describe args behaviors')
3131
->setDefinition(
32-
new InputDefinition(array(
32+
new InputDefinition([
3333
new InputOption('foo', 'f'),
3434
new InputOption('bar', 'b', InputOption::VALUE_REQUIRED),
3535
new InputOption('cat', 'c', InputOption::VALUE_OPTIONAL),
36-
))
36+
])
3737
);
3838
}
3939

@@ -69,10 +69,10 @@ argument::
6969

7070
// ...
7171

72-
new InputDefinition(array(
72+
new InputDefinition([
7373
// ...
7474
new InputArgument('arg', InputArgument::OPTIONAL),
75-
));
75+
]);
7676

7777
You might have to use the special ``--`` separator to separate options from
7878
arguments. Have a look at the fifth example in the following table where it

‎components/console/helpers/formatterhelper.rst

Copy file name to clipboardExpand all lines: components/console/helpers/formatterhelper.rst
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ notice that the background is only as long as each individual line. Use the
5050
:method:`Symfony\\Component\\Console\\Helper\\FormatterHelper::formatBlock`
5151
to generate a block output::
5252

53-
$errorMessages = array('Error!', 'Something went wrong');
53+
$errorMessages = ['Error!', 'Something went wrong'];
5454
$formattedBlock = $formatter->formatBlock($errorMessages, 'error');
5555
$output->writeln($formattedBlock);
5656

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.