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 96f68fe

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

File tree

Expand file treeCollapse file tree

103 files changed

+542
-541
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

103 files changed

+542
-541
lines changed

‎best_practices/business-logic.rst

Copy file name to clipboardExpand all lines: best_practices/business-logic.rst
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -312,11 +312,11 @@ Then, enable the bundle in ``AppKernel.php``, but only for the ``dev`` and
312312
{
313313
public function registerBundles()
314314
{
315-
$bundles = array(
315+
$bundles = [
316316
// ...
317-
);
317+
];
318318

319-
if (in_array($this->getEnvironment(), array('dev', 'test'))) {
319+
if (in_array($this->getEnvironment(), ['dev', 'test'])) {
320320
// ...
321321
$bundles[] = new Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle();
322322
}

‎best_practices/controllers.rst

Copy file name to clipboardExpand all lines: best_practices/controllers.rst
+5-5Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,9 @@ for the homepage of our app::
108108
->getRepository(Post::class)
109109
->findLatest();
110110

111-
return $this->render('default/index.html.twig', array(
111+
return $this->render('default/index.html.twig', [
112112
'posts' => $posts,
113-
));
113+
]);
114114
}
115115
}
116116

@@ -155,10 +155,10 @@ For example::
155155
{
156156
$deleteForm = $this->createDeleteForm($post);
157157

158-
return $this->render('admin/post/show.html.twig', array(
158+
return $this->render('admin/post/show.html.twig', [
159159
'post' => $post,
160160
'delete_form' => $deleteForm->createView(),
161-
));
161+
]);
162162
}
163163

164164
Normally, you'd expect a ``$id`` argument to ``showAction()``. Instead, by
@@ -182,7 +182,7 @@ manually. In our application, we have this situation in ``CommentController``::
182182
{
183183
$post = $this->getDoctrine()
184184
->getRepository(Post::class)
185-
->findOneBy(array('slug' => $postSlug));
185+
->findOneBy(['slug' => $postSlug]);
186186

187187
if (!$post) {
188188
throw $this->createNotFoundException();

‎best_practices/forms.rst

Copy file name to clipboardExpand all lines: best_practices/forms.rst
+7-7Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ form in its own PHP class::
4242

4343
public function configureOptions(OptionsResolver $resolver)
4444
{
45-
$resolver->setDefaults(array(
45+
$resolver->setDefaults([
4646
'data_class' => Post::class,
47-
));
47+
]);
4848
}
4949
}
5050

@@ -96,7 +96,7 @@ scope of that form::
9696
{
9797
$builder
9898
// ...
99-
->add('save', SubmitType::class, array('label' => 'Create Post'))
99+
->add('save', SubmitType::class, ['label' => 'Create Post'])
100100
;
101101
}
102102

@@ -123,10 +123,10 @@ some developers configure form buttons in the controller::
123123
{
124124
$post = new Post();
125125
$form = $this->createForm(PostType::class, $post);
126-
$form->add('submit', SubmitType::class, array(
126+
$form->add('submit', SubmitType::class, [
127127
'label' => 'Create',
128-
'attr' => array('class' => 'btn btn-default pull-right'),
129-
));
128+
'attr' => ['class' => 'btn btn-default pull-right'],
129+
]);
130130

131131
// ...
132132
}
@@ -215,7 +215,7 @@ Handling a form submit usually follows a similar template::
215215

216216
return $this->redirect($this->generateUrl(
217217
'admin_post_show',
218-
array('id' => $post->getId())
218+
['id' => $post->getId()]
219219
));
220220
}
221221

‎best_practices/security.rst

Copy file name to clipboardExpand all lines: best_practices/security.rst
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ the same ``getAuthorEmail()`` logic you used above::
285285

286286
protected function supports($attribute, $subject)
287287
{
288-
if (!in_array($attribute, array(self::CREATE, self::EDIT))) {
288+
if (!in_array($attribute, [self::CREATE, self::EDIT])) {
289289
return false;
290290
}
291291

@@ -309,7 +309,7 @@ the same ``getAuthorEmail()`` logic you used above::
309309
switch ($attribute) {
310310
case self::CREATE:
311311
// if the user is an admin, allow them to create new posts
312-
if ($this->decisionManager->decide($token, array('ROLE_ADMIN'))) {
312+
if ($this->decisionManager->decide($token, ['ROLE_ADMIN'])) {
313313
return true;
314314
}
315315

‎best_practices/templates.rst

Copy file name to clipboardExpand all lines: best_practices/templates.rst
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,11 @@ class in the constructor of the Twig extension::
122122

123123
public function getFilters()
124124
{
125-
return array(
125+
return [
126126
new TwigFilter(
127127
'md2html',
128-
array($this, 'markdownToHtml'),
129-
array('is_safe' => array('html'), 'pre_escape' => 'html')
128+
[$this, 'markdownToHtml'],
129+
['is_safe' => ['html'], 'pre_escape' => 'html')
130130
),
131131
);
132132
}

‎best_practices/tests.rst

Copy file name to clipboardExpand all lines: best_practices/tests.rst
+7-7Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,14 @@ A functional test like this is simple to implement thanks to
4949

5050
public function urlProvider()
5151
{
52-
return array(
53-
array('/'),
54-
array('/posts'),
55-
array('/post/fixture-post-1'),
56-
array('/blog/category/fixture-category'),
57-
array('/archives'),
52+
return [
53+
['/'],
54+
['/posts'],
55+
['/post/fixture-post-1'],
56+
['/blog/category/fixture-category'],
57+
['/archives'],
5858
// ...
59-
);
59+
];
6060
}
6161
}
6262

‎bundles.rst

Copy file name to clipboardExpand all lines: bundles.rst
+5-5Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ the ``registerBundles()`` method of the ``AppKernel`` class::
3939
// app/AppKernel.php
4040
public function registerBundles()
4141
{
42-
$bundles = array(
42+
$bundles = [
4343
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
4444
new Symfony\Bundle\SecurityBundle\SecurityBundle(),
4545
new Symfony\Bundle\TwigBundle\TwigBundle(),
@@ -48,9 +48,9 @@ the ``registerBundles()`` method of the ``AppKernel`` class::
4848
new Symfony\Bundle\DoctrineBundle\DoctrineBundle(),
4949
new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
5050
new AppBundle\AppBundle(),
51-
);
51+
];
5252

53-
if (in_array($this->getEnvironment(), array('dev', 'test'))) {
53+
if (in_array($this->getEnvironment(), ['dev', 'test'])) {
5454
$bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
5555
$bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
5656
$bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
@@ -107,12 +107,12 @@ Now that you've created the bundle, enable it via the ``AppKernel`` class::
107107
// app/AppKernel.php
108108
public function registerBundles()
109109
{
110-
$bundles = array(
110+
$bundles = [
111111
// ...
112112

113113
// register your bundle
114114
new Acme\TestBundle\AcmeTestBundle(),
115-
);
115+
];
116116
// ...
117117

118118
return $bundles;

‎bundles/best_practices.rst

Copy file name to clipboardExpand all lines: bundles/best_practices.rst
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -232,10 +232,10 @@ following standardized instructions in your ``README.md`` file.
232232
{
233233
public function registerBundles()
234234
{
235-
$bundles = array(
235+
$bundles = [
236236
// ...
237237
new <vendor>\<bundle-name>\<bundle-long-name>(),
238-
);
238+
];
239239
240240
// ...
241241
}
@@ -278,11 +278,11 @@ following standardized instructions in your ``README.md`` file.
278278
{
279279
public function registerBundles()
280280
{
281-
$bundles = array(
281+
$bundles = [
282282
// ...
283283
284284
new <vendor>\<bundle-name>\<bundle-long-name>(),
285-
);
285+
];
286286
287287
// ...
288288
}

‎bundles/configuration.rst

Copy file name to clipboardExpand all lines: bundles/configuration.rst
+21-21Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ as integration of other related components:
3939
4040
.. code-block:: php
4141
42-
$container->loadFromExtension('framework', array(
42+
$container->loadFromExtension('framework', [
4343
'form' => true,
44-
));
44+
]);
4545
4646
.. sidebar:: Using Parameters to Configure your Bundle
4747

@@ -91,10 +91,10 @@ allow users to configure it with some configuration that looks like this:
9191
.. code-block:: php
9292
9393
// app/config/config.php
94-
$container->loadFromExtension('acme_social', array(
94+
$container->loadFromExtension('acme_social', [
9595
'client_id' => 123,
9696
'client_secret' => 'your_secret',
97-
));
97+
]);
9898
9999
The basic idea is that instead of having the user override individual
100100
parameters, you let the user configure just a few, specifically created,
@@ -139,36 +139,36 @@ automatically converts XML and YAML to an array).
139139
For the configuration example in the previous section, the array passed to your
140140
``load()`` method will look like this::
141141

142-
array(
143-
array(
144-
'twitter' => array(
142+
[
143+
[
144+
'twitter' => [
145145
'client_id' => 123,
146146
'client_secret' => 'your_secret',
147-
),
148-
),
149-
)
147+
],
148+
],
149+
]
150150

151151
Notice that this is an *array of arrays*, not just a single flat array of the
152152
configuration values. This is intentional, as it allows Symfony to parse
153153
several configuration resources. For example, if ``acme_social`` appears in
154154
another configuration file - say ``config_dev.yml`` - with different values
155155
beneath it, the incoming array might look like this::
156156

157-
array(
157+
[
158158
// values from config.yml
159-
array(
160-
'twitter' => array(
159+
[
160+
'twitter' => [
161161
'client_id' => 123,
162162
'client_secret' => 'your_secret',
163-
),
164-
),
163+
],
164+
],
165165
// values from config_dev.yml
166-
array(
167-
'twitter' => array(
166+
[
167+
'twitter' => [
168168
'client_id' => 456,
169-
),
170-
),
171-
)
169+
],
170+
],
171+
]
172172

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

@@ -315,7 +315,7 @@ In your extension, you can load this and dynamically set its arguments::
315315
316316
public function load(array $configs, ContainerBuilder $container)
317317
{
318-
$config = array();
318+
$config = [];
319319
// let resources override the previous set value
320320
foreach ($configs as $subConfig) {
321321
$config = array_merge($config, $subConfig);

‎bundles/extension.rst

Copy file name to clipboardExpand all lines: bundles/extension.rst
+8-8Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -157,17 +157,17 @@ class names::
157157
// ...
158158

159159
// this method can't compile classes that contain PHP annotations
160-
$this->addClassesToCompile(array(
160+
$this->addClassesToCompile([
161161
UserManager::class,
162162
Slugger::class,
163163
// ...
164-
));
164+
]);
165165

166166
// add here only classes that contain PHP annotations
167-
$this->addAnnotatedClassesToCompile(array(
167+
$this->addAnnotatedClassesToCompile([
168168
'AppBundle\\Controller\\DefaultController',
169169
// ...
170-
));
170+
]);
171171
}
172172

173173
.. note::
@@ -186,15 +186,15 @@ The classes to compile can also be added using file path patterns::
186186
{
187187
// ...
188188

189-
$this->addClassesToCompile(array(
189+
$this->addClassesToCompile([
190190
'**Bundle\\Manager\\',
191191
// ...
192-
));
192+
]);
193193

194-
$this->addAnnotatedClassesToCompile(array(
194+
$this->addAnnotatedClassesToCompile([
195195
'**Bundle\\Controller\\',
196196
// ...
197-
));
197+
]);
198198
}
199199

200200
Patterns are transformed into the actual class namespaces using the classmap

‎bundles/installation.rst

Copy file name to clipboardExpand all lines: bundles/installation.rst
+5-5Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ The only thing you need to do now is register the bundle in ``AppKernel``::
6161

6262
public function registerBundles()
6363
{
64-
$bundles = array(
64+
$bundles = [
6565
// ...
6666
new FOS\UserBundle\FOSUserBundle(),
67-
);
67+
];
6868

6969
// ...
7070
}
@@ -85,11 +85,11 @@ and ``test`` environments, register the bundle in this way::
8585

8686
public function registerBundles()
8787
{
88-
$bundles = array(
88+
$bundles = [
8989
// ...
90-
);
90+
];
9191

92-
if (in_array($this->getEnvironment(), array('dev', 'test'))) {
92+
if (in_array($this->getEnvironment(), ['dev', 'test'])) {
9393
$bundles[] = new Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle();
9494
}
9595

0 commit comments

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