Skip to content

Commit

Permalink
Merge branch '3.4' into 4.1
Browse files Browse the repository at this point in the history
* 3.4:
  Use the short array syntax notation in all examples
  • Loading branch information
javiereguiluz committed Jan 15, 2019
2 parents f29fc98 + a0d0c83 commit f2e6e1a
Show file tree
Hide file tree
Showing 307 changed files with 2,579 additions and 2,476 deletions.
1 change: 0 additions & 1 deletion best_practices/business-logic.rst
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,6 @@ Then, this bundle is enabled automatically, but only for the ``dev`` and
``test`` environments::

// config/bundles.php

return [
// ...
Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle::class => ['dev' => true, 'test' => true],
Expand Down
8 changes: 4 additions & 4 deletions bundles/best_practices.rst
Original file line number Diff line number Diff line change
Expand Up @@ -317,10 +317,10 @@ following standardized instructions in your ``README.md`` file.
{
public function registerBundles()
{
$bundles = array(
$bundles = [
// ...
new <vendor>\<bundle-name>\<bundle-long-name>(),
);
];
// ...
}
Expand Down Expand Up @@ -375,11 +375,11 @@ following standardized instructions in your ``README.md`` file.
{
public function registerBundles()
{
$bundles = array(
$bundles = [
// ...
new <vendor>\<bundle-name>\<bundle-long-name>(),
);
];
// ...
}
Expand Down
42 changes: 21 additions & 21 deletions bundles/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ as integration of other related components:
.. code-block:: php
$container->loadFromExtension('framework', array(
$container->loadFromExtension('framework', [
'form' => true,
));
]);
Using the Bundle Extension
--------------------------
Expand Down Expand Up @@ -81,10 +81,10 @@ allow users to configure it with some configuration that looks like this:
.. code-block:: php
// config/packages/acme_social.php
$container->loadFromExtension('acme_social', array(
$container->loadFromExtension('acme_social', [
'client_id' => 123,
'client_secret' => 'your_secret',
));
]);
The basic idea is that instead of having the user override individual
parameters, you let the user configure just a few, specifically created,
Expand Down Expand Up @@ -129,36 +129,36 @@ automatically converts XML and YAML to an array).
For the configuration example in the previous section, the array passed to your
``load()`` method will look like this::

array(
array(
'twitter' => array(
[
[
'twitter' => [
'client_id' => 123,
'client_secret' => 'your_secret',
),
),
)
],
],
]

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

array(
[
// values from config/packages/acme_social.yaml
array(
'twitter' => array(
[
'twitter' => [
'client_id' => 123,
'client_secret' => 'your_secret',
),
),
],
],
// values from config/packages/dev/acme_social.yaml
array(
'twitter' => array(
[
'twitter' => [
'client_id' => 456,
),
),
)
],
],
]

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

Expand Down Expand Up @@ -304,7 +304,7 @@ In your extension, you can load this and dynamically set its arguments::
public function load(array $configs, ContainerBuilder $container)
{
$config = array();
$config = [];
// let resources override the previous set value
foreach ($configs as $subConfig) {
$config = array_merge($config, $subConfig);
Expand Down
4 changes: 2 additions & 2 deletions bundles/extension.rst
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,14 @@ performance. Define the list of annotated classes to compile in the
{
// ...

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

// ...
));
]);
}

.. note::
Expand Down
12 changes: 6 additions & 6 deletions bundles/prepend_extension.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ in case a specific other bundle is not registered::
// determine if AcmeGoodbyeBundle is registered
if (!isset($bundles['AcmeGoodbyeBundle'])) {
// disable AcmeGoodbyeBundle in bundles
$config = array('use_acme_goodbye' => false);
$config = ['use_acme_goodbye' => false];
foreach ($container->getExtensions() as $name => $extension) {
switch ($name) {
case 'acme_something':
Expand All @@ -89,7 +89,7 @@ in case a specific other bundle is not registered::
// check if entity_manager_name is set in the "acme_hello" configuration
if (isset($config['entity_manager_name'])) {
// prepend the acme_something settings with the entity_manager_name
$config = array('entity_manager_name' => $config['entity_manager_name']);
$config = ['entity_manager_name' => $config['entity_manager_name']];
$container->prependExtensionConfig('acme_something', $config);
}
}
Expand Down Expand Up @@ -135,15 +135,15 @@ registered and the ``entity_manager_name`` setting for ``acme_hello`` is set to
.. code-block:: php
// config/packages/acme_something.php
$container->loadFromExtension('acme_something', array(
$container->loadFromExtension('acme_something', [
// ...
'use_acme_goodbye' => false,
'entity_manager_name' => 'non_default',
));
$container->loadFromExtension('acme_other', array(
]);
$container->loadFromExtension('acme_other', [
// ...
'use_acme_goodbye' => false,
));
]);
More than one Bundle using PrependExtensionInterface
----------------------------------------------------
Expand Down
10 changes: 5 additions & 5 deletions components/asset.rst
Original file line number Diff line number Diff line change
Expand Up @@ -292,10 +292,10 @@ constructor::
use Symfony\Component\Asset\UrlPackage;
// ...

$urls = array(
$urls = [
'//static1.example.com/images/',
'//static2.example.com/images/',
);
];
$urlPackage = new UrlPackage($urls, new StaticVersionStrategy('v1'));

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

$urlPackage = new UrlPackage(
array('http://example.com/', 'https://example.com/'),
['http://example.com/', 'https://example.com/'],
new StaticVersionStrategy('v1'),
new RequestStackContext($requestStack)
);
Expand Down Expand Up @@ -350,10 +350,10 @@ they all have different base paths::

$defaultPackage = new Package($versionStrategy);

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

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

Expand Down
2 changes: 1 addition & 1 deletion components/browser_kit.rst
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ into the client constructor::
$cookieJar->set($cookie);

// create a client and set the cookies
$client = new Client(array(), null, $cookieJar);
$client = new Client([], null, $cookieJar);
// ...

History
Expand Down
12 changes: 6 additions & 6 deletions components/cache.rst
Original file line number Diff line number Diff line change
Expand Up @@ -85,20 +85,20 @@ Now you can create, retrieve, update and delete items using this object::

You can also work with multiple items at once::

$cache->setMultiple(array(
$cache->setMultiple([
'stats.products_count' => 4711,
'stats.users_count' => 1356,
));
]);

$stats = $cache->getMultiple(array(
$stats = $cache->getMultiple([
'stats.products_count',
'stats.users_count',
));
]);

$cache->deleteMultiple(array(
$cache->deleteMultiple([
'stats.products_count',
'stats.users_count',
));
]);

Available Simple Cache (PSR-16) Classes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
12 changes: 6 additions & 6 deletions components/cache/adapters/chain_adapter.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ lifetime as its constructor arguments::

use Symfony\Component\Cache\Adapter\ApcuAdapter;

$cache = new ChainAdapter(array(
$cache = new ChainAdapter([

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

// The max lifetime of items propagated from lower adapters to upper ones
$maxLifetime = 0
));
]);

.. note::

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

$cache = new ChainAdapter(array(
$cache = new ChainAdapter([
new ApcuAdapter(),
new FilesystemAdapter(),
));
]);

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

$cache = new ChainAdapter(array(
$cache = new ChainAdapter([
new ApcuAdapter(), // does NOT implement PruneableInterface
new FilesystemAdapter(), // DOES implement PruneableInterface
));
]);

// prune will proxy the call to FilesystemAdapter while silently skipping ApcuAdapter
$cache->prune();
Expand Down
14 changes: 7 additions & 7 deletions components/cache/adapters/memcached_adapter.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ helper method allows creating and configuring a `Memcached`_ class instance usin
);

// pass an array of DSN strings to register multiple servers with the client
$client = MemcachedAdapter::createConnection(array(
$client = MemcachedAdapter::createConnection([
'memcached://10.0.0.100',
'memcached://10.0.0.101',
'memcached://10.0.0.102',
// etc...
));
]);

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

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

use Symfony\Component\Cache\Adapter\MemcachedAdapter;

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

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

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

Configure the Options
---------------------
Expand All @@ -110,14 +110,14 @@ option names and their respective values::

$client = MemcachedAdapter::createConnection(
// a DSN string or an array of DSN strings
array(),
[],

// associative array of configuration options
array(
[
'compression' => true,
'libketama_compatible' => true,
'serializer' => 'igbinary',
)
]
);

Available Options
Expand Down
2 changes: 1 addition & 1 deletion components/cache/adapters/pdo_doctrine_dbal_adapter.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ third, and forth parameters::
$defaultLifetime = 0,

// an array of options for configuring the database table and connection
$options = array()
$options = []
);

.. tip::
Expand Down
4 changes: 2 additions & 2 deletions components/cache/adapters/php_array_cache_adapter.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ that is optimized and preloaded into OPcache memory storage::
// somehow, decide it's time to warm up the cache!
if ($needsWarmup) {
// some static values
$values = array(
$values = [
'stats.products_count' => 4711,
'stats.users_count' => 1356,
);
];

$cache = new PhpArrayAdapter(
// single file where values are cached
Expand Down
10 changes: 5 additions & 5 deletions components/cache/adapters/php_files_adapter.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@ Php Files Cache Adapter
Similarly to :ref:`Filesystem Adapter <component-cache-filesystem-adapter>`, this cache
implementation writes cache entries out to disk, but unlike the Filesystem cache adapter,
the PHP Files cache adapter writes and reads back these cache files *as native PHP code*.
For example, caching the value ``array('my', 'cached', 'array')`` will write out a cache
For example, caching the value ``['my', 'cached', 'array']`` will write out a cache
file similar to the following::

<?php return array(
<?php return [

// the cache item expiration
0 => 9223372036854775807,

// the cache item contents
1 => array (
1 => [
0 => 'my',
1 => 'cached',
2 => 'array',
),
],

);
];

.. note::

Expand Down
Loading

0 comments on commit f2e6e1a

Please sign in to comment.