Skip to content
This repository has been archived by the owner on Oct 8, 2021. It is now read-only.

Commit

Permalink
chore: (2/2) Replace long with short syntax.
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardodevries committed Jan 15, 2019
1 parent 96f68fe commit a4440f9
Show file tree
Hide file tree
Showing 302 changed files with 2,544 additions and 2,542 deletions.
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
12 changes: 6 additions & 6 deletions components/cache/adapters/memcached_adapter.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,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...
));
]);

.. versionadded:: 3.4

Expand All @@ -90,7 +90,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 @@ -105,7 +105,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 @@ -122,11 +122,11 @@ option names and their respective values::
[],

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

Available Options
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
4 changes: 2 additions & 2 deletions components/cache/adapters/redis_adapter.rst
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,14 @@ array of ``key => value`` pairs representing option names and their respective v
'redis://localhost:6379',

// associative array of configuration options
array(
[
'lazy' => false,
'persistent' => 0,
'persistent_id' => null,
'timeout' => 30,
'read_timeout' => 0,
'retry_interval' => 0,
)
]

);

Expand Down
4 changes: 2 additions & 2 deletions components/cache/cache_invalidation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ cache items, as returned by cache adapters::
// ...
// add one or more tags
$item->tag('tag_1');
$item->tag(array('tag_2', 'tag_3'));
$item->tag(['tag_2', 'tag_3'[);
$cache->save($item);

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

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

// if you know the cache key, you can also delete the item directly
$cache->deleteItem('cache_key');
Expand Down
4 changes: 2 additions & 2 deletions components/cache/cache_items.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ the data stored in the cache item::
$cache->save($productsCount);

// storing an array
$productsCount->set(array(
$productsCount->set([
'category1' => 4711,
'category2' => 2387,
));
]);
$cache->save($productsCount);

The key and the value of any given cache item can be obtained with the
Expand Down
10 changes: 5 additions & 5 deletions components/cache/cache_pools.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ value but an empty object which implements the :class:`Symfony\\Component\\Cache
class.

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

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

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

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

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

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

// prune will proxy the call to PdoAdapter, FilesystemAdapter and PhpFilesAdapter,
// while silently skipping ApcuAdapter
Expand Down
12 changes: 6 additions & 6 deletions components/class_loader/class_loader.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,29 +41,29 @@ your classes::
$loader->addPrefix('Symfony', __DIR__.'/vendor/symfony/symfony/src');

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

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

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

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

$loader->addPrefixes(array(
$loader->addPrefixes([
'Doctrine\Common' => __DIR__.'/vendor/doctrine/common/lib',
'Doctrine\DBAL\Migrations' => __DIR__.'/vendor/doctrine/migrations/lib',
'Doctrine\DBAL' => __DIR__.'/vendor/doctrine/dbal/lib',
'Doctrine' => __DIR__.'/vendor/doctrine/orm/lib',
));
]);

In this example, if you try to use a class in the ``Doctrine\Common`` namespace
or one of its children, the autoloader will first look for the class under
Expand Down
2 changes: 1 addition & 1 deletion components/class_loader/class_map_generator.rst
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ is the same as in the example above)::
use Symfony\Component\ClassLoader\ClassMapGenerator;

ClassMapGenerator::dump(
array(__DIR__.'/library/bar', __DIR__.'/library/foo'),
[__DIR__.'/library/bar', __DIR__.'/library/foo'],
__DIR__.'/class_map.php'
);

Expand Down
4 changes: 2 additions & 2 deletions components/class_loader/map_class_loader.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ an instance of the ``MapClassLoader`` class::

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

$mapping = array(
$mapping = [
'Foo' => '/path/to/Foo',
'Bar' => '/path/to/Bar',
);
];

$loader = new MapClassLoader($mapping);

Expand Down
14 changes: 7 additions & 7 deletions components/config/definition.rst
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ values::
$rootNode
->children()
->enumNode('delivery')
->values(array('standard', 'expedited', 'priority'))
->values(['standard', 'expedited', 'priority'])
->end()
->end()
;
Expand Down Expand Up @@ -509,9 +509,9 @@ methods::
// is equivalent to

$arrayNode
->treatFalseLike(array('enabled' => false))
->treatTrueLike(array('enabled' => true))
->treatNullLike(array('enabled' => true))
->treatFalseLike(['enabled' => false])
->treatTrueLike(['enabled' => true])
->treatNullLike(['enabled' => true])
->children()
->booleanNode('enabled')
->defaultFalse()
Expand Down Expand Up @@ -742,7 +742,7 @@ By changing a string value into an associative array with ``name`` as the key::
->arrayNode('connection')
->beforeNormalization()
->ifString()
->then(function ($v) { return array('name' => $v); })
->then(function ($v) { return ['name' => $v]; })
->end()
->children()
->scalarNode('name')->isRequired()
Expand All @@ -767,7 +767,7 @@ The builder is used for adding advanced validation rules to node definitions, li
->scalarNode('driver')
->isRequired()
->validate()
->ifNotInArray(array('mysql', 'sqlite', 'mssql'))
->ifNotInArray(['mysql', 'sqlite', 'mssql'])
->thenInvalid('Invalid database driver %s')
->end()
->end()
Expand Down Expand Up @@ -820,7 +820,7 @@ Otherwise the result is a clean array of configuration values::
file_get_contents(__DIR__.'/src/Matthias/config/config_extra.yml')
);

$configs = array($config, $extraConfig);
$configs = [$config, $extraConfig];

$processor = new Processor();
$databaseConfiguration = new DatabaseConfiguration();
Expand Down
4 changes: 2 additions & 2 deletions components/config/resources.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ files. This can be done with the :class:`Symfony\\Component\\Config\\FileLocator

use Symfony\Component\Config\FileLocator;

$configDirectories = array(__DIR__.'/app/config');
$configDirectories = [__DIR__.'/app/config'];

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

$loaderResolver = new LoaderResolver(array(new YamlUserLoader($fileLocator)));
$loaderResolver = new LoaderResolver([new YamlUserLoader($fileLocator)]);
$delegatingLoader = new DelegatingLoader($loaderResolver);

// YamlUserLoader is used to load this resource because it supports
Expand Down
8 changes: 4 additions & 4 deletions components/console/console_arguments.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ Have a look at the following command that has three options::
->setName('demo:args')
->setDescription('Describe args behaviors')
->setDefinition(
new InputDefinition(array(
new InputDefinition([
new InputOption('foo', 'f'),
new InputOption('bar', 'b', InputOption::VALUE_REQUIRED),
new InputOption('cat', 'c', InputOption::VALUE_OPTIONAL),
))
])
);
}

Expand Down Expand Up @@ -69,10 +69,10 @@ argument::

// ...

new InputDefinition(array(
new InputDefinition([
// ...
new InputArgument('arg', InputArgument::OPTIONAL),
));
]);

You might have to use the special ``--`` separator to separate options from
arguments. Have a look at the fifth example in the following table where it
Expand Down
2 changes: 1 addition & 1 deletion components/console/helpers/formatterhelper.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ notice that the background is only as long as each individual line. Use the
:method:`Symfony\\Component\\Console\\Helper\\FormatterHelper::formatBlock`
to generate a block output::

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

Expand Down
Loading

0 comments on commit a4440f9

Please sign in to comment.