Skip to content

Commit b6dc182

Browse files
committed
Fixed more long array syntax occurrences
1 parent f2e6e1a commit b6dc182

26 files changed

+235
-246
lines changed

components/http_foundation.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -263,14 +263,14 @@ this complexity and defines some methods for the most common tasks::
263263

264264
// Splits an HTTP header by one or more separators
265265
HeaderUtils::split('da, en-gb;q=0.8', ',;');
266-
// => array(array('da'), array('en-gb','q=0.8'))
266+
// => [['da'], ['en-gb','q=0.8']]
267267

268268
// Combines an array of arrays into one associative array
269-
HeaderUtils::combine(array(array('foo', 'abc'), array('bar')));
270-
// => array('foo' => 'abc', 'bar' => true)
269+
HeaderUtils::combine([['foo', 'abc'], ['bar']]);
270+
// => ['foo' => 'abc', 'bar' => true]
271271

272272
// Joins an associative array into a string for use in an HTTP header
273-
HeaderUtils::toString(array('foo' => 'abc', 'bar' => true, 'baz' => 'a b c'), ',');
273+
HeaderUtils::toString(['foo' => 'abc', 'bar' => true, 'baz' => 'a b c'], ',');
274274
// => 'foo=abc, bar, baz="a b c"'
275275

276276
// Encodes a string as a quoted string, if necessary

components/ldap.rst

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ delete existing ones::
131131
$entryManager->update($entry);
132132

133133
// Adding or removing values to a multi-valued attribute is more efficient than using update()
134-
$entryManager->addAttributeValues($entry, 'telephoneNumber', array('+1.111.222.3333', '+1.222.333.4444'));
135-
$entryManager->removeAttributeValues($entry, 'telephoneNumber', array('+1.111.222.3333', '+1.222.333.4444'));
134+
$entryManager->addAttributeValues($entry, 'telephoneNumber', ['+1.111.222.3333', '+1.222.333.4444']);
135+
$entryManager->removeAttributeValues($entry, 'telephoneNumber', ['+1.111.222.3333', '+1.222.333.4444']);
136136

137137
// Removing an existing entry
138138
$entryManager->remove(new Entry('cn=Test User,dc=symfony,dc=com'));
@@ -148,18 +148,18 @@ method to update multiple attributes at once::
148148
use Symfony\Component\Ldap\Entry;
149149
// ...
150150

151-
$entry = new Entry('cn=Fabien Potencier,dc=symfony,dc=com', array(
152-
'sn' => array('fabpot'),
153-
'objectClass' => array('inetOrgPerson'),
154-
));
151+
$entry = new Entry('cn=Fabien Potencier,dc=symfony,dc=com', [
152+
'sn' => ['fabpot'],
153+
'objectClass' => ['inetOrgPerson'],
154+
]);
155155

156156
$entryManager = $ldap->getEntryManager();
157157

158158
// Adding multiple email addresses at once
159-
$entryManager->applyOperations($entry->getDn(), array(
159+
$entryManager->applyOperations($entry->getDn(), [
160160
new UpdateOperation(LDAP_MODIFY_BATCH_ADD, 'mail', 'new1@example.com'),
161161
new UpdateOperation(LDAP_MODIFY_BATCH_ADD, 'mail', 'new2@example.com'),
162-
));
162+
]);
163163

164164
Possible operation types are ``LDAP_MODIFY_BATCH_ADD``, ``LDAP_MODIFY_BATCH_REMOVE``,
165165
``LDAP_MODIFY_BATCH_REMOVE_ALL``, ``LDAP_MODIFY_BATCH_REPLACE``. Parameter
@@ -168,7 +168,7 @@ operation type.
168168

169169
.. versionadded:: 4.2
170170
The ``applyOperations()`` method was introduced in Symfony 4.2.
171-
171+
172172
.. versionadded:: 4.1
173173
The ``addAttributeValues()`` and ``removeAttributeValues()`` methods
174174
were introduced in Symfony 4.1.

components/process.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ escaping arguments to prevent security issues. It replaces PHP functions like
4949
// traditional string based commands
5050
$builder = new Process('ls -lsa');
5151
// same example but using an array
52-
$builder = new Process(array('ls', '-lsa'));
52+
$builder = new Process(['ls', '-lsa']);
5353
// the array can contain any number of arguments and options
54-
$builder = new Process(array('ls', '-l', '-s', '-a'));
54+
$builder = new Process(['ls', '-l', '-s', '-a']);
5555

5656
The ``getOutput()`` method always returns the whole content of the standard
5757
output of the command and ``getErrorOutput()`` the content of the error

components/serializer.rst

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -654,8 +654,8 @@ You can add new encoders to a Serializer instance by using its second constructo
654654
use Symfony\Component\Serializer\Encoder\XmlEncoder;
655655
use Symfony\Component\Serializer\Encoder\JsonEncoder;
656656

657-
$encoders = array(new XmlEncoder(), new JsonEncoder());
658-
$serializer = new Serializer(array(), $encoders);
657+
$encoders = [new XmlEncoder(), new JsonEncoder()];
658+
$serializer = new Serializer([], $encoders);
659659

660660
Built-in Encoders
661661
~~~~~~~~~~~~~~~~~
@@ -702,7 +702,7 @@ This encoder transforms arrays into XML and vice versa.
702702

703703
For example, take an object normalized as following::
704704

705-
array('foo' => array(1, 2), 'bar' => true);
705+
['foo' => [1, 2], 'bar' => true];
706706

707707
The ``XmlEncoder`` will encode this object like that::
708708

@@ -716,7 +716,7 @@ The ``XmlEncoder`` will encode this object like that::
716716
Be aware that this encoder will consider keys beginning with ``@`` as attributes::
717717

718718
$encoder = new XmlEncoder();
719-
$encoder->encode(array('foo' => array('@bar' => 'value')), 'xml');
719+
$encoder->encode(['foo' => ['@bar' => 'value']], 'xml');
720720
// will return:
721721
// <?xml version="1.0"?>
722722
// <response>
@@ -970,17 +970,17 @@ having unique identifiers::
970970
return '/foos/'.$foo->id;
971971
});
972972

973-
$serializer = new Serializer(array($normalizer));
973+
$serializer = new Serializer([$normalizer]);
974974

975-
$result = $serializer->normalize($level1, null, array(ObjectNormalizer::ENABLE_MAX_DEPTH => true));
975+
$result = $serializer->normalize($level1, null, [ObjectNormalizer::ENABLE_MAX_DEPTH => true]);
976976
/*
977-
$result = array(
977+
$result = [
978978
'id' => 1,
979-
'child' => array(
979+
'child' => [
980980
'id' => 2,
981981
'child' => '/foos/3',
982-
),
983-
);
982+
],
983+
];
984984
*/
985985

986986
.. versionadded:: 4.1
@@ -1126,15 +1126,15 @@ context option::
11261126
}
11271127

11281128
$normalizer = new ObjectNormalizer($classMetadataFactory);
1129-
$serializer = new Serializer(array($normalizer));
1129+
$serializer = new Serializer([$normalizer]);
11301130

11311131
$data = $serializer->denormalize(
1132-
array('foo' => 'Hello'),
1132+
['foo' => 'Hello'],
11331133
'MyObj',
1134-
array('default_constructor_arguments' => array(
1135-
'MyObj' => array('foo' => '', 'bar' => ''),
1136-
)
1137-
));
1134+
['default_constructor_arguments' => [
1135+
'MyObj' => ['foo' => '', 'bar' => ''],
1136+
]]
1137+
);
11381138
// $data = new MyObj('Hello', '');
11391139

11401140
Recursive Denormalization and Type Safety
@@ -1240,8 +1240,8 @@ this is already set up and you only need to provide the configuration. Otherwise
12401240
$discriminator = new ClassDiscriminatorFromClassMetadata($classMetadataFactory);
12411241

12421242
$serializer = new Serializer(
1243-
array(new ObjectNormalizer($classMetadataFactory, null, null, null, $discriminator)),
1244-
array('json' => new JsonEncoder())
1243+
[new ObjectNormalizer($classMetadataFactory, null, null, null, $discriminator)],
1244+
['json' => new JsonEncoder()]
12451245
);
12461246

12471247
Now configure your discriminator class mapping. Consider an application that

components/var_dumper.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,9 @@ the :ref:`dump_destination option <configuration-debug-dump_destination>` of the
146146
.. code-block:: php
147147
148148
// config/packages/debug.php
149-
$container->loadFromExtension('debug', array(
149+
$container->loadFromExtension('debug', [
150150
'dump_destination' => 'tcp://%env(VAR_DUMPER_SERVER)%',
151-
));
151+
]);
152152
153153
Outside a Symfony application, use the :class:`Symfony\\Component\\VarDumper\\Dumper\\ServerDumper` class::
154154

@@ -163,11 +163,11 @@ Outside a Symfony application, use the :class:`Symfony\\Component\\VarDumper\\Du
163163
use Symfony\Component\VarDumper\Dumper\ServerDumper;
164164

165165
$cloner = new VarCloner();
166-
$fallbackDumper = \in_array(\PHP_SAPI, array('cli', 'phpdbg')) ? new CliDumper() : new HtmlDumper();
167-
$dumper = new ServerDumper('tcp://127.0.0.1:9912', $fallbackDumper, array(
166+
$fallbackDumper = \in_array(\PHP_SAPI, ['cli', 'phpdbg']) ? new CliDumper() : new HtmlDumper();
167+
$dumper = new ServerDumper('tcp://127.0.0.1:9912', $fallbackDumper, [
168168
'cli' => new CliContextProvider(),
169169
'source' => new SourceContextProvider(),
170-
));
170+
]);
171171

172172
VarDumper::setHandler(function ($var) use ($cloner, $dumper) {
173173
$dumper->dump($cloner->cloneVar($var));

doctrine/multiple_entity_managers.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -154,16 +154,16 @@ The following configuration code shows how you can configure two entity managers
154154
'entity_managers' => [
155155
'default' => [
156156
'connection' => 'default',
157-
'mappings' => array(
158-
'Main' => array(
157+
'mappings' => [
158+
'Main' => [
159159
is_bundle => false,
160160
type => 'annotation',
161161
dir => '%kernel.project_dir%/src/Entity/Main',
162162
prefix => 'App\Entity\Main',
163163
alias => 'Main',
164-
)
165-
),
166-
),
164+
]
165+
],
166+
],
167167
'customer' => [
168168
'connection' => 'customer',
169169
'mappings' => [

email/dev_environment.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ via the ``delivery_addresses`` option:
8787
8888
// config/packages/dev/swiftmailer.php
8989
$container->loadFromExtension('swiftmailer', [
90-
'delivery_addresses' => array("dev@example.com"),
90+
'delivery_addresses' => ['dev@example.com'],
9191
]);
9292
9393
Now, suppose you're sending an email to ``recipient@example.com`` in a controller::

logging/monolog_exclude_http_codes.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,13 @@ logging these HTTP codes based on the MonologBundle configuration:
5353
.. code-block:: php
5454
5555
// config/packages/prod/monolog.php
56-
$container->loadFromExtension('monolog', array(
57-
'handlers' => array(
58-
'main' => array(
56+
$container->loadFromExtension('monolog', [
57+
'handlers' => [
58+
'main' => [
5959
// ...
6060
'type' => 'fingers_crossed',
6161
'handler' => ...,
62-
'excluded_http_codes' => array(403, 404),
63-
),
64-
),
65-
));
62+
'excluded_http_codes' => [403, 404],
63+
],
64+
],
65+
]);

0 commit comments

Comments
 (0)