8000 Merge branch '3.2' · symfony/symfony-docs@09b1a22 · GitHub
[go: up one dir, main page]

Skip to content

Commit 09b1a22

Browse files
committed
Merge branch '3.2'
* 3.2: use namespaced PHPUnit classes Update event_dispatcher.rst for consistency Made 'create-user' command consistent. Update without_class.rst Fix typo Fixed the way flash messages are retrieved in the template remove 2.x versionadded directives Fix version notice rendering Minor improvement for the default console command article
2 parents 9232842 + aa0a7aa commit 09b1a22

14 files changed

+33
-39
lines changed

components/console/changing_default_command.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ name to the ``setDefaultCommand()`` method::
2828
}
2929
}
3030

31-
Executing the application and changing the default Command::
31+
Executing the application and changing the default command::
3232

3333
// application.php
3434

@@ -53,9 +53,10 @@ This will print the following to the command line:
5353
5454
Hello World
5555
56-
.. tip::
56+
.. caution::
5757

58-
This feature has a limitation: you cannot use it with any Command arguments.
58+
This feature has a limitation: you cannot pass any argument or option to
59+
the default command because they are ignored.
5960

6061
Learn More!
6162
-----------

components/event_dispatcher.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ A call to the dispatcher's ``addListener()`` method associates any valid
135135
PHP callable to an event::
136136

137137
$listener = new AcmeListener();
138-
$dispatcher->addListener('acme.action', array($listener, 'onFooAction'));
138+
$dispatcher->addListener('acme.foo.action', array($listener, 'onFooAction'));
139139

140140
The ``addListener()`` method takes up to three arguments:
141141

@@ -161,12 +161,12 @@ The ``addListener()`` method takes up to three arguments:
161161

162162
use Symfony\Component\EventDispatcher\Event;
163163

164-
$dispatcher->addListener('foo.action', function (Event $event) {
165-
// will be executed when the foo.action event is dispatched
164+
$dispatcher->addListener('acme.foo.action', function (Event $event) {
165+
// will be executed when the acme.foo.action event is dispatched
166166
});
167167

168168
Once a listener is registered with the dispatcher, it waits until the event
169-
is notified. In the above example, when the ``foo.action`` event is dispatched,
169+
is notified. In the above example, when the ``acme.foo.action`` event is dispatched,
170170
the dispatcher calls the ``AcmeListener::onFooAction()`` method and passes
171171
the ``Event`` object as the single argument::
172172

@@ -211,7 +211,7 @@ determine which instance is passed.
211211
// register an event listener
212212
$listener = new Definition(\AcmeListener::class);
213213
$listener->addTag('kernel.event_listener', array(
214-
'event' => 'foo.action',
214+
'event' => 'acme.foo.action',
215215
'method' => 'onFooAction',
216216
));
217217
$containerBuilder->setDefinition('listener_service_id', $listener);

components/http_foundation/trusting_proxies.rst

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@ your proxy as follows:
2727
// front controller) to only trust proxy headers coming from these IP addresses
2828
Request::setTrustedProxies(array('192.0.0.1', '10.0.0.0/8'));
2929
30-
.. versionadded:: 2.3
31-
CIDR notation support was introduced in Symfony 2.3, so you can whitelist whole
32-
subnets (e.g. ``10.0.0.0/8``, ``fc00::/7``).
33-
3430
You should also make sure that your proxy filters unauthorized use of these
3531
headers, e.g. if a proxy natively uses the ``X-Forwarded-For`` header, it
3632
should not allow clients to send ``Forwarded`` headers to Symfony.

components/var_dumper.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,9 @@ This will provide you with two new assertions:
136136

137137
Example::
138138

139-
class ExampleTest extends \PHPUnit_Framework_TestCase
139+
use PHPUnit\Framework\TestCase;
140+
141+
class ExampleTest extends TestCase
140142
{
141143
use \Symfony\Component\VarDumper\Test\VarDumperTestTrait;
142144

components/yaml.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ changed using the third argument as follows::
206206
Numeric Literals
207207
................
208208

209-
versionadded:: 3.2
209+
.. versionadded:: 3.2
210210
Support for parsing integers grouped by underscores was introduced in
211211
Symfony 3.2.
212212

console.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,14 @@ method. Then you can optionally define a help message and the
5050
{
5151
$this
5252
// the name of the command (the part after "bin/console")
53-
->setName('app:create-users')
53+
->setName('app:create-user')
5454

5555
// the short description shown while running "php bin/console list"
56-
->setDescription('Creates new users.')
56+
->setDescription('Creates a new user.')
5757

5858
// the full command description shown when running the command with
5959
// the "--help" option
60-
->setHelp('This command allows you to create users...')
60+
->setHelp('This command allows you to create a user...')
6161
;
6262
}
6363

@@ -68,7 +68,7 @@ After configuring the command, you can execute it in the terminal:
6868

6969
.. code-block:: terminal
7070
71-
$ php bin/console app:create-users
71+
$ php bin/console app:create-user
7272
7373
As you might expect, this command will do nothing as you didn't write any logic
7474
yet. Add your own logic inside the ``execute()`` method, which has access to the
@@ -258,7 +258,7 @@ console::
258258

259259
When using the Console component in a standalone project, use
260260
:class:`Symfony\\Component\\Console\\Application <Symfony\\Component\\Console\\Application>`
261-
and extend the normal ``\PHPUnit_Framework_TestCase``.
261+
and extend the normal ``\PHPUnit\Framework\TestCase``.
262262

263263
To be able to use the fully set up service container for your console tests
264264
you can extend your test from

controller.rst

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -180,10 +180,6 @@ and ``redirect()`` methods::
180180
return $this->redirect('http://symfony.com/doc');
181181
}
182182

183-
.. versionadded:: 2.6
184-
The ``redirectToRoute()`` method was introduced in Symfony 2.6. Previously (and still now), you
185-
could use ``redirect()`` and ``generateUrl()`` together for this.
186-
187183
For more information, see the :doc:`Routing article </routing>`.
188184

189185
.. caution::
@@ -420,19 +416,19 @@ read any flash messages from the session:
420416
{# app/Resources/views/base.html.twig #}
421417

422418
{# you can read and display just one flash message type... #}
423-
{% for flash_message in app.session.flash('notice') %}
419+
{% for flash_message in app.session.flashBag.get('notice') %}
424420
<div class="flash-notice">
425421
{{ flash_message }}
426422
</div>
427423
{% endfor %}
428424

429425
{# ...or you can read and display every flash message available #}
430-
{% for type, flash_messages in app.session.flashes %}
426+
{% for type, flash_messages in app.session.flashBag.all %}
431427
{% for flash_message in flash_messages %}
432428
<div class="flash-{{ type }}">
433429
{{ flash_message }}
434430
</div>
435-
{% endif %}
431+
{% endfor %}
436432
{% endfor %}
437433

438434
.. code-block:: html+php

create_framework/http_foundation.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ snippet of PHP code is not natural and feels ugly. Here is a tentative PHPUnit
5858
unit test for the above code::
5959

6060
// framework/test.php
61-
class IndexTest extends \PHPUnit_Framework_TestCase
61+
use PHPUnit\Framework\TestCase;
62+
63+
class IndexTest extends TestCase
6264
{
6365
public function testHello()
6466
{

create_framework/unit_testing.rst

F438 Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,15 @@ We are now ready to write our first test::
7575
// example.com/tests/Simplex/Tests/FrameworkTest.php
7676
namespace Simplex\Tests;
7777

78+
use PHPUnit\Framework\TestCase;
7879
use Simplex\Framework;
7980
use Symfony\Component\HttpFoundation\Request;
8081
use Symfony\Component\HttpKernel\Controller\ArgumentResolverInterface;
8182
use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface;
8283
use Symfony\Component\Routing;
8384
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
8485

85-
class FrameworkTest extends \PHPUnit_Framework_TestCase
86+
class FrameworkTest extends TestCase
8687
{
8788
public function testNotFoundHandling()
8889
{

form/without_class.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ but here's a short example:
102102
If you are using validation groups, you need to either reference the
103103
``Default`` group when creating the form, or set the correct group on
104104
the constraint you are adding.
105+
106+
.. code-block:: php
105107
106-
.. code-block:: php
107-
108-
new NotBlank(array('groups' => array('create', 'update'))
108+
new NotBlank(array('groups' => array('create', 'update')))

reference/configuration/framework.rst

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1467,9 +1467,6 @@ name_converter
14671467

14681468
**type**: ``string``
14691469

1470-
.. versionadded:: 2.8
1471-
The ``name_converter`` option was introduced in Symfony 2.8.
1472-
14731470
The name converter to use.
14741471
The :class:`Symfony\\Component\\Serializer\\NameConverter\\CamelCaseToSnakeCaseNameConverter`
14751472
name converter can enabled by using the ``serializer.name_converter.camel_case_to_snake_case``

serializer.rst

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,9 +223,6 @@ A service leveraging `APCu`_ (and APC for PHP < 5.5) is built-in.
223223
Enabling a Name Converter
224224
-------------------------
225225

226-
.. versionadded:: 2.8
227-
The ``name_converter`` option was introduced in Symfony 2.8.
228-
229226
The use of a :ref:`name converter <component-serializer-converting-property-names-when-serializing-and-deserializing>`
230227
service can be defined in the configuration using the :ref:`name_converter <reference-serializer-name_converter>`
231228
option.

testing.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,9 @@ of your application::
6969
namespace Tests\AppBundle\Util;
7070

7171
use AppBundle\Util\Calculator;
72+
use PHPUnit\Framework\TestCase;
7273

73-
class CalculatorTest extends \PHPUnit_Framework_TestCase
74+
class CalculatorTest extends TestCase
7475
{
7576
public function testAdd()
7677
{

testing/database.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,9 @@ it's easy to pass a mock object within a test::
6767
use AppBundle\Salary\SalaryCalculator;
6868
use Doctrine\ORM\EntityRepository;
6969
use Doctrine\Common\Persistence\ObjectManager;
70+
use PHPUnit\Framework\TestCase;
7071

71-
class SalaryCalculatorTest extends \PHPUnit_Framework_TestCase
72+
class SalaryCalculatorTest extends TestCase
7273
{
7374
public function testCalculateTotalSalary()
7475
{

0 commit comments

Comments
 (0)
0