Skip to content

Commit 045cda2

Browse files
committed
Use the shorthand notation when applicable
It's part of the standard
1 parent 945dbc6 commit 045cda2

Some content is hidden

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

57 files changed

+108
-260
lines changed

best_practices/business-logic.rst

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,7 @@ The blog application needs a utility that can transform a post title (e.g.
5757
part of the post URL.
5858

5959
Let's create a new ``Slugger`` class inside ``src/AppBundle/Utils/`` and
60-
add the following ``slugify()`` method:
61-
62-
.. code-block:: php
60+
add the following ``slugify()`` method::
6361

6462
// src/AppBundle/Utils/Slugger.php
6563
namespace AppBundle\Utils;
@@ -96,9 +94,7 @@ your code will be easier to read and use.
9694
you ever need to.
9795

9896
Now you can use the custom slugger in any controller class, such as the
99-
``AdminController``:
100-
101-
.. code-block:: php
97+
``AdminController``::
10298

10399
public function createAction(Request $request)
104100
{
@@ -203,9 +199,7 @@ PHP and annotations.
203199
Use annotations to define the mapping information of the Doctrine entities.
204200

205201
Annotations are by far the most convenient and agile way of setting up and
206-
looking for mapping information:
207-
208-
.. code-block:: php
202+
looking for mapping information::
209203

210204
namespace AppBundle\Entity;
211205

@@ -284,9 +278,7 @@ the following command to install the Doctrine fixtures bundle:
284278
$ composer require "doctrine/doctrine-fixtures-bundle"
285279
286280
Then, enable the bundle in ``AppKernel.php``, but only for the ``dev`` and
287-
``test`` environments:
288-
289-
.. code-block:: php
281+
``test`` environments::
290282

291283
use Symfony\Component\HttpKernel\Kernel;
292284

best_practices/configuration.rst

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,7 @@ Constants can be used for example in your Twig templates thanks to the
133133
</p>
134134

135135
And Doctrine entities and repositories can now easily access these values,
136-
whereas they cannot access the container parameters:
137-
138-
.. code-block:: php
136+
whereas they cannot access the container parameters::
139137

140138
namespace AppBundle\Repository;
141139

best_practices/controllers.rst

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,7 @@ What does the Controller look like
8989
----------------------------------
9090

9191
Considering all this, here is an example of what the controller should look like
92-
for the homepage of our app:
93-
94-
.. code-block:: php
92+
for the homepage of our app::
9593

9694
namespace AppBundle\Controller;
9795

@@ -129,9 +127,7 @@ to automatically query for an entity and pass it as an argument to your controll
129127
Use the ParamConverter trick to automatically query for Doctrine entities
130128
when it's simple and convenient.
131129

132-
For example:
133-
134-
.. code-block:: php
130+
For example::
135131

136132
use AppBundle\Entity\Post;
137133
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
@@ -161,9 +157,7 @@ When Things Get More Advanced
161157
The above example works without any configuration because the wildcard name ``{id}`` matches
162158
the name of the property on the entity. If this isn't true, or if you have
163159
even more complex logic, the easiest thing to do is just query for the entity
164-
manually. In our application, we have this situation in ``CommentController``:
165-
166-
.. code-block:: php
160+
manually. In our application, we have this situation in ``CommentController``::
167161

168162
/**
169163
* @Route("/comment/{postSlug}/new", name="comment_new")
@@ -182,9 +176,7 @@ manually. In our application, we have this situation in ``CommentController``:
182176
}
183177

184178
You can also use the ``@ParamConverter`` configuration, which is infinitely
185-
flexible:
186-
187-
.. code-block:: php
179+
flexible::
188180

189181
use AppBundle\Entity\Post;
190182
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;

best_practices/forms.rst

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,7 @@ makes them easier to re-use later.
9494

9595
Since Symfony 2.3, you can add buttons as fields on your form. This is a nice
9696
way to simplify the template that renders your form. But if you add the buttons
97-
directly in your form class, this would effectively limit the scope of that form:
98-
99-
.. code-block:: php
97+
directly in your form class, this would effectively limit the scope of that form::
10098

10199
class PostType extends AbstractType
102100
{
@@ -178,9 +176,7 @@ can control *how* the form renders at a global level using form theming.
178176
Handling Form Submits
179177
---------------------
180178

181-
Handling a form submit usually follows a similar template:
182-
183-
.. code-block:: php
179+
Handling a form submit usually follows a similar template::
184180

185181
public function newAction(Request $request)
186182
{

best_practices/security.rst

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ above each action.
107107
In our application, you need the ``ROLE_ADMIN`` in order to create a new post.
108108
Using ``@Security``, this looks like:
109109

110-
.. code-block:: php
110+
::
111111

112112
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
113113
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
@@ -130,9 +130,7 @@ Using Expressions for Complex Security Restrictions
130130
If your security logic is a little bit more complex, you can use an :doc:`expression </components/expression_language>`
131131
inside ``@Security``. In the following example, a user can only access the
132132
controller if their email matches the value returned by the ``getAuthorEmail()``
133-
method on the ``Post`` object:
134-
135-
.. code-block:: php
133+
method on the ``Post`` object::
136134

137135
use AppBundle\Entity\Post;
138136
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
@@ -163,9 +161,7 @@ need to repeat the expression code using Twig syntax:
163161
{% endif %}
164162

165163
The easiest solution - if your logic is simple enough - is to add a new method
166-
to the ``Post`` entity that checks if a given user is its author:
167-
168-
.. code-block:: php
164+
to the ``Post`` entity that checks if a given user is its author::
169165

170166
// src/AppBundle/Entity/Post.php
171167
// ...
@@ -185,9 +181,7 @@ to the ``Post`` entity that checks if a given user is its author:
185181
}
186182
}
187183

188-
Now you can reuse this method both in the template and in the security expression:
189-
190-
.. code-block:: php
184+
Now you can reuse this method both in the template and in the security expression::
191185

192186
use AppBundle\Entity\Post;
193187
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
@@ -217,9 +211,7 @@ Checking Permissions without @Security
217211
The above example with ``@Security`` only works because we're using the
218212
:ref:`ParamConverter <best-practices-paramconverter>`, which gives the expression
219213
access to the ``post`` variable. If you don't use this, or have some other
220-
more advanced use-case, you can always do the same security check in PHP:
221-
222-
.. code-block:: php
214+
more advanced use-case, you can always do the same security check in PHP::
223215

224216
/**
225217
* @Route("/{id}/edit", name="admin_post_edit")
@@ -257,9 +249,7 @@ of magnitude easier than :doc:`ACLs </security/acl>` and will give
257249
you the flexibility you need in almost all cases.
258250

259251
First, create a voter class. The following example shows a voter that implements
260-
the same ``getAuthorEmail()`` logic you used above:
261-
262-
.. code-block:: php
252+
the same ``getAuthorEmail()`` logic you used above::
263253

264254
namespace AppBundle\Security;
265255

@@ -313,9 +303,7 @@ To enable the security voter in the application, define a new service:
313303
tags:
314304
- { name: security.voter }
315305
316-
Now, you can use the voter with the ``@Security`` annotation:
317-
318-
.. code-block:: php
306+
Now, you can use the voter with the ``@Security`` annotation::
319307

320308
/**
321309
* @Route("/{id}/edit", name="admin_post_edit")
@@ -327,9 +315,7 @@ Now, you can use the voter with the ``@Security`` annotation:
327315
}
328316

329317
You can also use this directly with the ``security.authorization_checker`` service or
330-
via the even easier shortcut in a controller:
331-
332-
.. code-block:: php
318+
via the even easier shortcut in a controller::
333319

334320
/**
335321
* @Route("/{id}/edit", name="admin_post_edit")

best_practices/templates.rst

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,7 @@ Markdown content into HTML::
115115

116116
Next, create a new Twig extension and define a new filter called ``md2html``
117117
using the ``Twig_SimpleFilter`` class. Inject the newly defined ``markdown``
118-
service in the constructor of the Twig extension:
119-
120-
.. code-block:: php
118+
service in the constructor of the Twig extension::
121119

122120
namespace AppBundle\Twig;
123121

best_practices/tests.rst

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,7 @@ generator service:
8080
generator.
8181

8282
Consider the following functional test that uses the ``router`` service to
83-
generate the URL of the tested page:
84-
85-
.. code-block:: php
83+
generate the URL of the tested page::
8684

8785
public function testBlogArchives()
8886
{

components/browser_kit.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ retrieve any cookie while making requests with the client::
155155
Looping Through Cookies
156156
~~~~~~~~~~~~~~~~~~~~~~~
157157

158-
.. code-block:: php
158+
::
159159

160160
use Acme\Client;
161161

components/config/definition.rst

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ has a certain value:
379379
(``null``, ``true``, ``false``), provide a replacement value in case
380380
the value is ``*.``
381381

382-
.. code-block:: php
382+
::
383383

384384
$rootNode
385385
->children()
@@ -417,9 +417,7 @@ Documenting the Option
417417

418418
All options can be documented using the
419419
:method:`Symfony\\Component\\Config\\Definition\\Builder\\NodeDefinition::info`
420-
method.
421-
422-
.. code-block:: php
420+
method::
423421

424422
$rootNode
425423
->children()

components/dom_crawler.rst

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,9 +260,7 @@ The crawler supports multiple ways of adding the content::
260260

261261
As the Crawler's implementation is based on the DOM extension, it is also able
262262
to interact with native :phpclass:`DOMDocument`, :phpclass:`DOMNodeList`
263-
and :phpclass:`DOMNode` objects:
264-
265-
.. code-block:: php
263+
and :phpclass:`DOMNode` objects::
266264

267265
$document = new \DOMDocument();
268266
$document->loadXml('<root><node /><node /></root>');

components/expression_language/caching.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ Both ``evaluate()`` and ``compile()`` can handle ``ParsedExpression`` and
5858

5959
var_dump($language->evaluate($expression)); // prints 5
6060

61-
.. code-block:: php
61+
::
6262

6363
use Symfony\Component\ExpressionLanguage\SerializedParsedExpression;
6464
// ...

components/expression_language/extending.rst

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ This method has 3 arguments:
2929
function;
3030
* **evaluator** - A function executed when the expression is evaluated.
3131

32-
.. code-block:: php
32+
::
3333

3434
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
3535

@@ -68,9 +68,7 @@ This interface requires one method:
6868
:method:`Symfony\\Component\\ExpressionLanguage\\ExpressionFunctionProviderInterface::getFunctions`,
6969
which returns an array of expression functions (instances of
7070
:class:`Symfony\\Component\\ExpressionLanguage\\ExpressionFunction`) to
71-
register.
72-
73-
.. code-block:: php
71+
register::
7472

7573
use Symfony\Component\ExpressionLanguage\ExpressionFunction;
7674
use Symfony\Component\ExpressionLanguage\ExpressionFunctionProviderInterface;

components/filesystem/lock_handler.rst

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@ Usage
2222
The lock handler only works if you're using just one server. If you have
2323
several hosts, you must not use this helper.
2424

25-
A lock can be used, for example, to allow only one instance of a command to run.
26-
27-
.. code-block:: php
25+
A lock can be used, for example, to allow only one instance of a command to run::
2826

2927
use Symfony\Component\Filesystem\LockHandler;
3028

components/http_foundation/trusting_proxies.rst

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ the actual host may be stored in an ``X-Forwarded-Host`` header.
1717

1818
Since HTTP headers can be spoofed, Symfony does *not* trust these proxy
1919
headers by default. If you are behind a proxy, you should manually whitelist
20-
your proxy as follows:
21-
22-
.. code-block:: php
20+
your proxy as follows::
2321

2422
use Symfony\Component\HttpFoundation\Request;
2523

components/options_resolver.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ options are buried in the business logic of your code. Use the
9595
Now all four options are guaranteed to be set. But what happens if the user of
9696
the ``Mailer`` class makes a mistake?
9797

98-
.. code-block:: php
98+
::
9999

100100
$mailer = new Mailer(array(
101101
'usernme' => 'johndoe', // usernme misspelled (instead of username)

components/process.rst

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -310,9 +310,7 @@ Process Pid
310310
The ``getPid()`` method was introduced in Symfony 2.3.
311311

312312
You can access the `pid`_ of a running process with the
313-
:method:`Symfony\\Component\\Process\\Process::getPid` method.
314-
315-
.. code-block:: php
313+
:method:`Symfony\\Component\\Process\\Process::getPid` method::
316314

317315
use Symfony\Component\Process\Process;
318316

components/property_access.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ can use setters, the magic ``__set()`` method or properties to set values::
288288
You can also use ``__call()`` to set values but you need to enable the feature,
289289
see `Enable other Features`_.
290290

291-
.. code-block:: php
291+
::
292292

293293
// ...
294294
class Person
@@ -327,7 +327,7 @@ Writing to Array Properties
327327
The ``PropertyAccessor`` class allows to update the content of arrays stored in
328328
properties through *adder* and *remover* methods.
329329

330-
.. code-block:: php
330+
::
331331

332332
// ...
333333
class Person

components/security/authorization.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ recognizes several strategies:
5454
``unanimous``
5555
only grant access if none of the voters has denied access;
5656

57-
.. code-block:: php
57+
::
5858

5959
use Symfony\Component\Security\Core\Authorization\AccessDecisionManager;
6060

@@ -115,7 +115,7 @@ and ``IS_AUTHENTICATED_ANONYMOUSLY`` and grants access based on the current
115115
level of authentication, i.e. is the user fully authenticated, or only based
116116
on a "remember-me" cookie, or even authenticated anonymously?
117117

118-
.. code-block:: php
118+
::
119119

120120
use Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolver;
121121
use Symfony\Component\Security\Core\Authentication\Token\AnonymousToken;

components/templating.rst

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,7 @@ takes a list of engines and acts just like a normal templating engine. The
188188
only difference is that it delegates the calls to one of the other engines. To
189189
choose which one to use for the template, the
190190
:method:`EngineInterface::supports() <Symfony\\Component\\Templating\\EngineInterface::supports>`
191-
method is used.
192-
193-
.. code-block:: php
191+
method is used::
194192

195193
use Acme\Templating\CustomEngine;
196194
use Symfony\Component\Templating\PhpEngine;

components/translation.rst

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@ catalogs*).
2929
Configuration
3030
~~~~~~~~~~~~~
3131

32-
The constructor of the ``Translator`` class needs one argument: The locale.
33-
34-
.. code-block:: php
32+
The constructor of the ``Translator`` class needs one argument: The locale::
3533

3634
use Symfony\Component\Translation\Translator;
3735

0 commit comments

Comments
 (0)