Skip to content

Commit 23b409b

Browse files
committed
Merge branch '4.2'
* 4.2: Use the short array syntax notation in all examples
2 parents ccca18b + 82ef94e commit 23b409b

File tree

318 files changed

+2791
-2764
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

318 files changed

+2791
-2764
lines changed

best_practices/business-logic.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,6 @@ Then, this bundle is enabled automatically, but only for the ``dev`` and
232232
``test`` environments::
233233

234234
// config/bundles.php
235-
236235
return [
237236
// ...
238237
Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle::class => ['dev' => true, 'test' => true],

bundles/best_practices.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -317,10 +317,10 @@ following standardized instructions in your ``README.md`` file.
317317
{
318318
public function registerBundles()
319319
{
320-
$bundles = array(
320+
$bundles = [
321321
// ...
322322
new <vendor>\<bundle-name>\<bundle-long-name>(),
323-
);
323+
];
324324
325325
// ...
326326
}
@@ -375,11 +375,11 @@ following standardized instructions in your ``README.md`` file.
375375
{
376376
public function registerBundles()
377377
{
378-
$bundles = array(
378+
$bundles = [
379379
// ...
380380
381381
new <vendor>\<bundle-name>\<bundle-long-name>(),
382-
);
382+
];
383383
384384
// ...
385385
}

bundles/configuration.rst

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ as integration of other related components:
4040
4141
.. code-block:: php
4242
43-
$container->loadFromExtension('framework', array(
43+
$container->loadFromExtension('framework', [
4444
'form' => true,
45-
));
45+
]);
4646
4747
Using the Bundle Extension
4848
--------------------------
@@ -81,10 +81,10 @@ allow users to configure it with some configuration that looks like this:
8181
.. code-block:: php
8282
8383
// config/packages/acme_social.php
84-
$container->loadFromExtension('acme_social', array(
84+
$container->loadFromExtension('acme_social', [
8585
'client_id' => 123,
8686
'client_secret' => 'your_secret',
87-
));
87+
]);
8888
8989
The basic idea is that instead of having the user override individual
9090
parameters, you let the user configure just a few, specifically created,
@@ -129,36 +129,36 @@ automatically converts XML and YAML to an array).
129129
For the configuration example in the previous section, the array passed to your
130130
``load()`` method will look like this::
131131

132-
array(
133-
array(
134-
'twitter' => array(
132+
[
133+
[
134+
'twitter' => [
135135
'client_id' => 123,
136136
'client_secret' => 'your_secret',
137-
),
138-
),
139-
)
137+
],
138+
],
139+
]
140140

141141
Notice that this is an *array of arrays*, not just a single flat array of the
142142
configuration values. This is intentional, as it allows Symfony to parse several
143143
configuration resources. For example, if ``acme_social`` appears in another
144144
configuration file - say ``config/packages/dev/acme_social.yaml`` - with
145145
different values beneath it, the incoming array might look like this::
146146

147-
array(
147+
[
148148
// values from config/packages/acme_social.yaml
149-
array(
150-
'twitter' => array(
149+
[
150+
'twitter' => [
151151
'client_id' => 123,
152152
'client_secret' => 'your_secret',
153-
),
154-
),
153+
],
154+
],
155155
// values from config/packages/dev/acme_social.yaml
156-
array(
157-
'twitter' => array(
156+
[
157+
'twitter' => [
158158
'client_id' => 456,
159-
),
160-
),
161-
)
159+
],
160+
],
161+
]
162162

163163
The order of the two arrays depends on which one is set first.
164164

@@ -307,7 +307,7 @@ In your extension, you can load this and dynamically set its arguments::
307307
308308
public function load(array $configs, ContainerBuilder $container)
309309
{
310-
$config = array();
310+
$config = [];
311311
// let resources override the previous set value
312312
foreach ($configs as $subConfig) {
313313
$config = array_merge($config, $subConfig);

bundles/extension.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,14 +126,14 @@ performance. Define the list of annotated classes to compile in the
126126
{
127127
// ...
128128

129-
$this->addAnnotatedClassesToCompile(array(
129+
$this->addAnnotatedClassesToCompile([
130130
// you can define the fully qualified class names...
131131
'App\\Controller\\DefaultController',
132132
// ... but glob patterns are also supported:
133133
'**Bundle\\Controller\\',
134134

135135
// ...
136-
));
136+
]);
137137
}
138138

139139
.. note::

bundles/prepend_extension.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ in case a specific other bundle is not registered::
6363
// determine if AcmeGoodbyeBundle is registered
6464
if (!isset($bundles['AcmeGoodbyeBundle'])) {
6565
// disable AcmeGoodbyeBundle in bundles
66-
$config = array('use_acme_goodbye' => false);
66+
$config = ['use_acme_goodbye' => false];
6767
foreach ($container->getExtensions() as $name => $extension) {
6868
switch ($name) {
6969
case 'acme_something':
@@ -89,7 +89,7 @@ in case a specific other bundle is not registered::
8989
// check if entity_manager_name is set in the "acme_hello" configuration
9090
if (isset($config['entity_manager_name'])) {
9191
// prepend the acme_something settings with the entity_manager_name
92-
$config = array('entity_manager_name' => $config['entity_manager_name']);
92+
$config = ['entity_manager_name' => $config['entity_manager_name']];
9393
$container->prependExtensionConfig('acme_something', $config);
9494
}
9595
}
@@ -135,15 +135,15 @@ registered and the ``entity_manager_name`` setting for ``acme_hello`` is set to
135135
.. code-block:: php
136136
137137
// config/packages/acme_something.php
138-
$container->loadFromExtension('acme_something', array(
138+
$container->loadFromExtension('acme_something', [
139139
// ...
140140
'use_acme_goodbye' => false,
141141
'entity_manager_name' => 'non_default',
142-
));
143-
$container->loadFromExtension('acme_other', array(
142+
]);
143+
$container->loadFromExtension('acme_other', [
144144
// ...
145145
'use_acme_goodbye' => false,
146-
));
146+
]);
147147
148148
More than one Bundle using PrependExtensionInterface
149149
----------------------------------------------------

components/asset.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -292,10 +292,10 @@ constructor::
292292
use Symfony\Component\Asset\UrlPackage;
293293
// ...
294294

295-
$urls = array(
295+
$urls = [
296296
'//static1.example.com/images/',
297297
'//static2.example.com/images/',
298-
);
298+
];
299299
$urlPackage = new UrlPackage($urls, new StaticVersionStrategy('v1'));
300300

301301
echo $urlPackage->getUrl('/logo.png');
@@ -320,7 +320,7 @@ protocol-relative URLs for HTTPs requests, any base URL for HTTP requests)::
320320
// ...
321321

322322
$urlPackage = new UrlPackage(
323-
array('http://example.com/', 'https://example.com/'),
323+
['http://example.com/', 'https://example.com/'],
324324
new StaticVersionStrategy('v1'),
325325
new RequestStackContext($requestStack)
326326
);
@@ -350,10 +350,10 @@ they all have different base paths::
350350

351351
$defaultPackage = new Package($versionStrategy);
352352

353-
$namedPackages = array(
353+
$namedPackages = [
354354
'img' => new UrlPackage('http://img.example.com/', $versionStrategy),
355355
'doc' => new PathPackage('/somewhere/deep/for/documents', $versionStrategy),
356-
);
356+
];
357357

358358
$packages = new Packages($defaultPackage, $namedPackages);
359359

components/browser_kit.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,21 +131,21 @@ field values, etc.) before submitting it::
131131
$client->submitForm('Log in');
132132

133133
// the second optional argument lets you override the default form field values
134-
$client->submitForm('Log in', array(
134+
$client->submitForm('Log in', [
135135
'login' => 'my_user',
136136
'password' => 'my_pass',
137137
// to upload a file, the value must be the absolute file path
138138
'file' => __FILE__,
139-
));
139+
]);
140140

141141
// you can override other form options too
142142
$client->submitForm(
143143
'Log in',
144-
array('login' => 'my_user', 'password' => 'my_pass'),
144+
['login' => 'my_user', 'password' => 'my_pass'],
145145
// override the default form HTTP method
146146
'PUT',
147147
// override some $_SERVER parameters (e.g. HTTP headers)
148-
array('HTTP_ACCEPT_LANGUAGE' => 'es')
148+
['HTTP_ACCEPT_LANGUAGE' => 'es']
149149
);
150150

151151
If you need the :class:`Symfony\\Component\\DomCrawler\\Form` object that
@@ -246,7 +246,7 @@ into the client constructor::
246246
$cookieJar->set($cookie);
247247

248248
// create a client and set the cookies
249-
$client = new Client(array(), null, $cookieJar);
249+
$client = new Client([], null, $cookieJar);
250250
// ...
251251

252252
History

components/cache.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,20 +85,20 @@ Now you can create, retrieve, update and delete items using this object::
8585

8686
You can also work with multiple items at once::
8787

88-
$cache->setMultiple(array(
88+
$cache->setMultiple([
8989
'stats.products_count' => 4711,
9090
'stats.users_count' => 1356,
91-
));
91+
]);
9292

93-
$stats = $cache->getMultiple(array(
93+
$stats = $cache->getMultiple([
9494
'stats.products_count',
9595
'stats.users_count',
96-
));
96+
]);
9797

98-
$cache->deleteMultiple(array(
98+
$cache->deleteMultiple([
9999
'stats.products_count',
100100
'stats.users_count',
101-
));
101+
]);
102102

103103
Available Simple Cache (PSR-16) Classes
104104
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

components/cache/adapters/chain_adapter.rst

Lines 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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,12 @@ helper method allows creating and configuring a `Memcached`_ class instance usin
5757
);
5858

5959
// pass an array of DSN strings to register multiple servers with the client
60-
$client = MemcachedAdapter::createConnection(array(
60+
$client = MemcachedAdapter::createConnection([
6161
'memcached://10.0.0.100',
6262
'memcached://10.0.0.101',
6363
'memcached://10.0.0.102',
6464
// etc...
65-
));
65+
]);
6666

6767
The `Data Source Name (DSN)`_ for this adapter must use the following format:
6868

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

8282
use Symfony\Component\Cache\Adapter\MemcachedAdapter;
8383

84-
$client = MemcachedAdapter::createConnection(array(
84+
$client = MemcachedAdapter::createConnection([
8585
// hostname + port
8686
'memcached://my.server.com:11211'
8787

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

9797
// socket instead of hostname/IP + weight
9898
'memcached:///var/run/memcached.sock?weight=20'
99-
));
99+
]);
100100

101101
Configure the Options
102102
---------------------
@@ -110,14 +110,14 @@ option names and their respective values::
110110

111111
$client = MemcachedAdapter::createConnection(
112112
// a DSN string or an array of DSN strings
113-
array(),
113+
[],
114114

115115
// associative array of configuration options
116-
array(
116+
[
117117
'compression' => true,
118118
'libketama_compatible' => true,
119119
'serializer' => 'igbinary',
120-
)
120+
]
121121
);
122122

123123
Available Options

components/cache/adapters/pdo_doctrine_dbal_adapter.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ third, and forth parameters::
2828
$defaultLifetime = 0,
2929

3030
// an array of options for configuring the database table and connection
31-
$options = array()
31+
$options = []
3232
);
3333

3434
The table where values are stored is created automatically on the first call to

components/cache/adapters/php_array_cache_adapter.rst

Lines 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

0 commit comments

Comments
 (0)