Skip to content

Commit 3529d3a

Browse files
committed
Merge remote-tracking branch 'upstream/6.4' into 6.4
* upstream/6.4: (29 commits) Update events.rst Tweaks Update messenger.rst Prefer placing services before query parameters Reword [Console] Fix a typo after symfony#18739 Tweaks Tweaks [Console] Improve console events doc Add the versionadded directive Tweaks Minor tweaks Clearer difference with max and quiet options [Mailer] Fix attachment changes Minor tweak Minor tweak Missing information about payload in callback [Server] Fix typo in Symfony Local Web Server page [AssetMapper] Add docs for the importmap:install command [Validator] Deprecate annotations ...
2 parents 4d66627 + 8e729dc commit 3529d3a

25 files changed

+408
-64
lines changed

components/console/events.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ the wheel, it uses the Symfony EventDispatcher component to do the work::
1717
.. caution::
1818

1919
Console events are only triggered by the main command being executed.
20-
Commands called by the main command will not trigger any event.
20+
Commands called by the main command will not trigger any event, unless
21+
run by the application itself, see :doc:`/console/calling_commands`.
2122

2223
The ``ConsoleEvents::COMMAND`` Event
2324
------------------------------------

components/console/helpers/formatterhelper.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,13 @@ in the default helper set and you can get it by calling
1313

1414
The methods return a string, which you'll usually render to the console by
1515
passing it to the
16-
:method:`OutputInterface::writeln <Symfony\\Component\\Console\\Output\\OutputInterface::writeln>` method.
16+
:method:`OutputInterface::writeln <Symfony\\Component\\Console\\Output\\OutputInterface::writeln>`
17+
method.
18+
19+
.. note::
20+
21+
As an alternative, consider using the
22+
:ref:`SymfonyStyle <symfony-style-blocks>` to display stylized blocks.
1723

1824
Print Messages in a Section
1925
---------------------------

components/console/helpers/processhelper.rst

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
Process Helper
22
==============
33

4-
The Process Helper shows processes as they're running and reports
5-
useful information about process status.
4+
The Process Helper shows processes as they're running and reports useful
5+
information about process status.
66

7-
To display process details, use the :class:`Symfony\\Component\\Console\\Helper\\ProcessHelper`
8-
and run your command with verbosity. For example, running the following code with
7+
To display process details, use the
8+
:class:`Symfony\\Component\\Console\\Helper\\ProcessHelper` and run your command
9+
with verbosity. For example, running the following code with
910
a very verbose verbosity (e.g. ``-vv``)::
1011

1112
use Symfony\Component\Process\Process;

components/console/helpers/progressbar.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ information, which updates as your command runs:
66

77
.. image:: /_images/components/console/progressbar.gif
88

9+
.. note::
10+
11+
As an alternative, consider using the
12+
:ref:`SymfonyStyle <symfony-style-progressbar>` to display a progress bar.
13+
914
To display progress details, use the
1015
:class:`Symfony\\Component\\Console\\Helper\\ProgressBar`, pass it a total
1116
number of units, and advance the progress as the command executes::

components/console/helpers/questionhelper.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ first argument, an :class:`Symfony\\Component\\Console\\Output\\OutputInterface`
1515
instance as the second argument and a
1616
:class:`Symfony\\Component\\Console\\Question\\Question` as last argument.
1717

18+
.. note::
19+
20+
As an alternative, consider using the
21+
:ref:`SymfonyStyle <symfony-style-questions>` to ask questions.
22+
1823
Asking the User for Confirmation
1924
--------------------------------
2025

components/console/helpers/table.rst

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ When building a console application it may be useful to display tabular data:
1414
| 80-902734-1-6 | And Then There Were None | Agatha Christie |
1515
+---------------+--------------------------+------------------+
1616
17+
.. note::
18+
19+
As an alternative, consider using the
20+
:ref:`SymfonyStyle <symfony-style-content>` to display a table.
21+
1722
To display a table, use :class:`Symfony\\Component\\Console\\Helper\\Table`,
1823
set the headers, set the rows and then render the table::
1924

@@ -38,7 +43,7 @@ set the headers, set the rows and then render the table::
3843
])
3944
;
4045
$table->render();
41-
46+
4247
return Command::SUCCESS;
4348
}
4449
}
@@ -435,7 +440,7 @@ The only requirement to append rows is that the table must be rendered inside a
435440
$table->render();
436441

437442
$table->appendRow(['Symfony']);
438-
443+
439444
return Command::SUCCESS;
440445
}
441446
}

components/lock.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -927,7 +927,7 @@ have synchronized clocks.
927927
PostgreSqlStore
928928
~~~~~~~~~~~~~~~
929929

930-
The PdoStore relies on the `Advisory Locks`_ properties of the PostgreSQL
930+
The PostgreSqlStore relies on the `Advisory Locks`_ properties of the PostgreSQL
931931
database. That means that by using :ref:`PostgreSqlStore <lock-store-pgsql>`
932932
the locks will be automatically released at the end of the session in case the
933933
client cannot unlock for any reason.

components/phpunit_bridge.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,8 @@ message, enclosed with ``/``. For example, with:
215215
`PHPUnit`_ will stop your test suite once a deprecation notice is triggered whose
216216
message contains the ``"foobar"`` string.
217217

218+
.. _making-tests-fail:
219+
218220
Making Tests Fail
219221
~~~~~~~~~~~~~~~~~
220222

@@ -349,6 +351,10 @@ It's also possible to change verbosity per deprecation type. For example, using
349351
``quiet[]=indirect&quiet[]=other`` will hide details for deprecations of types
350352
"indirect" and "other".
351353

354+
The ``quiet`` option hides details for the specified deprecation types, but will
355+
not change the outcome in terms of exit code. That's what :ref:`max <making-tests-fail>`
356+
is for, and both settings are orthogonal.
357+
352358
Disabling the Deprecation Helper
353359
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
354360

components/validator/resources.rst

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,14 @@ configure the locations of these files::
8686
The AnnotationLoader
8787
--------------------
8888

89-
At last, the component provides an
89+
.. deprecated:: 6.4
90+
91+
The :class:`Symfony\\Component\\Validator\\Mapping\\Loader\\AnnotationLoader`
92+
is deprecated since Symfony 6.4, use the
93+
:class:`Symfony\\Component\\Validator\\Mapping\\Loader\\AttributeLoader`
94+
instead.
95+
96+
The component provides an
9097
:class:`Symfony\\Component\\Validator\\Mapping\\Loader\\AnnotationLoader` to get
9198
the metadata from the annotations of the class. Annotations are defined as ``@``
9299
prefixed classes included in doc block comments (``/** ... */``). For example::
@@ -121,8 +128,44 @@ If you use annotations instead of attributes, it's also required to call
121128
To disable the annotation loader after it was enabled, call
122129
:method:`Symfony\\Component\\Validator\\ValidatorBuilder::disableAnnotationMapping`.
123130

131+
.. deprecated:: 6.4
132+
133+
The :method:`Symfony\\Component\\Validator\\ValidatorBuilder::enableAnnotationMapping`
134+
and :method:`Symfony\\Component\\Validator\\ValidatorBuilder::disableAnnotationMapping`
135+
methods are deprecated since Symfony 6.4, use the
136+
:method:`Symfony\\Component\\Validator\\ValidatorBuilder::enableAttributeMapping`
137+
and :method:`Symfony\\Component\\Validator\\ValidatorBuilder::disableAttributeMapping`
138+
methods instead.
139+
124140
.. include:: /_includes/_annotation_loader_tip.rst.inc
125141

142+
The AttributeLoader
143+
-------------------
144+
145+
.. versionadded:: 6.4
146+
147+
The :class:`Symfony\\Component\\Validator\\Mapping\\Loader\\AttributeLoader`
148+
was introduced in Symfony 6.4.
149+
150+
The component provides an
151+
:class:`Symfony\\Component\\Validator\\Mapping\\Loader\\AttributeLoader` to get
152+
the metadata from the attributes of the class. For example::
153+
154+
use Symfony\Component\Validator\Constraints as Assert;
155+
// ...
156+
157+
class User
158+
{
159+
#[Assert\NotBlank]
160+
protected string $name;
161+
}
162+
163+
To enable the attribute loader, call the
164+
:method:`Symfony\\Component\\Validator\\ValidatorBuilder::enableAttributeMapping` method.
165+
166+
To disable the annotation loader after it was enabled, call
167+
:method:`Symfony\\Component\\Validator\\ValidatorBuilder::disableAttributeMapping`.
168+
126169
Using Multiple Loaders
127170
----------------------
128171

@@ -136,8 +179,7 @@ multiple mappings::
136179
use Symfony\Component\Validator\Validation;
137180

138181
$validator = Validation::createValidatorBuilder()
139-
->enableAnnotationMapping(true)
140-
->addDefaultDoctrineAnnotationReader()
182+
->enableAttributeMapping()
141183
->addMethodMapping('loadValidatorMetadata')
142184
->addXmlMapping('validator/validation.xml')
143185
->getValidator();

console.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,12 @@ registers an :doc:`event subscriber </event_dispatcher>` to listen to the
577577
:ref:`ConsoleEvents::TERMINATE event <console-events-terminate>` and adds a log
578578
message whenever a command doesn't finish with the ``0`` `exit status`_.
579579

580+
Using Events And Handling Signals
581+
---------------------------------
582+
583+
When a command is running, many events are dispatched, one of them allows to
584+
react to signals, read more in :doc:`this section </components/console/events>`.
585+
580586
Learn More
581587
----------
582588

@@ -596,6 +602,7 @@ tools capable of helping you with different tasks:
596602
* :doc:`/components/console/helpers/table`: displays tabular data as a table
597603
* :doc:`/components/console/helpers/debug_formatter`: provides functions to
598604
output debug information when running an external program
605+
* :doc:`/components/console/helpers/processhelper`: allows to run processes using ``DebugFormatterHelper``
599606
* :doc:`/components/console/helpers/cursor`: allows to manipulate the cursor in the terminal
600607

601608
.. _`exit status`: https://en.wikipedia.org/wiki/Exit_status

console/calling_commands.rst

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ or if you want to create a "meta" command that runs a bunch of other commands
88
changed on the production servers: clearing the cache, generating Doctrine
99
proxies, dumping web assets, ...).
1010

11-
Use the :method:`Symfony\\Component\\Console\\Application::find` method to
12-
find the command you want to run by passing the command name. Then, create a
13-
new :class:`Symfony\\Component\\Console\\Input\\ArrayInput` with the
14-
arguments and options you want to pass to the command.
11+
Use the :method:`Symfony\\Component\\Console\\Application::doRun`. Then, create
12+
a new :class:`Symfony\\Component\\Console\\Input\\ArrayInput` with the
13+
arguments and options you want to pass to the command. The command name must be
14+
the first argument.
1515

16-
Eventually, calling the ``run()`` method actually runs the command and returns
17-
the returned code from the command (return value from command's ``execute()``
16+
Eventually, calling the ``doRun()`` method actually runs the command and returns
17+
the returned code from the command (return value from command ``execute()``
1818
method)::
1919

2020
// ...
@@ -29,15 +29,14 @@ method)::
2929

3030
protected function execute(InputInterface $input, OutputInterface $output): int
3131
{
32-
$command = $this->getApplication()->find('demo:greet');
33-
34-
$arguments = [
32+
$greetInput = new ArrayInput([
33+
// the command name is passed as first argument
34+
'command' => 'demo:greet',
3535
'name' => 'Fabien',
3636
'--yell' => true,
37-
];
37+
]);
3838

39-
$greetInput = new ArrayInput($arguments);
40-
$returnCode = $command->run($greetInput, $output);
39+
$returnCode = $this->getApplication()->doRun($greetInput, $output);
4140

4241
// ...
4342
}
@@ -47,7 +46,16 @@ method)::
4746

4847
If you want to suppress the output of the executed command, pass a
4948
:class:`Symfony\\Component\\Console\\Output\\NullOutput` as the second
50-
argument to ``$command->run()``.
49+
argument to ``$application->doRun()``.
50+
51+
.. note::
52+
53+
Using ``doRun()`` instead of ``run()`` prevents autoexiting and allows to
54+
return the exit code instead.
55+
56+
Also, using ``$this->getApplication()->doRun()`` instead of
57+
``$this->getApplication()->find('demo:greet')->run()`` will allow proper
58+
events to be dispatched for that inner command as well.
5159

5260
.. caution::
5361

console/style.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ Titling Methods
9696

9797
// ...
9898

99+
.. _symfony-style-content:
100+
99101
Content Methods
100102
~~~~~~~~~~~~~~~
101103

@@ -215,6 +217,8 @@ Admonition Methods
215217
'Aenean sit amet arcu vitae sem faucibus porta',
216218
]);
217219

220+
.. _symfony-style-progressbar:
221+
218222
Progress Bar Methods
219223
~~~~~~~~~~~~~~~~~~~~
220224

@@ -259,6 +263,8 @@ Progress Bar Methods
259263
Creates an instance of :class:`Symfony\\Component\\Console\\Helper\\ProgressBar`
260264
styled according to the Symfony Style Guide.
261265

266+
.. _symfony-style-questions:
267+
262268
User Input Methods
263269
~~~~~~~~~~~~~~~~~~
264270

@@ -331,6 +337,8 @@ User Input Methods
331337

332338
The ``multiSelect`` option of ``choice()`` was introduced in Symfony 6.2.
333339

340+
.. _symfony-style-blocks:
341+
334342
Result Methods
335343
~~~~~~~~~~~~~~
336344

doctrine.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ and injected by the dependency injection container::
539539
class ProductController extends AbstractController
540540
{
541541
#[Route('/product/{id}', name: 'product_show')]
542-
public function show(int $id, ProductRepository $productRepository): Response
542+
public function show(ProductRepository $productRepository, int $id): Response
543543
{
544544
$product = $productRepository
545545
->find($id);

doctrine/events.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ listener in the Symfony application by creating a new service for it and
173173

174174
.. code-block:: php-attributes
175175
176-
// src/App/EventListener/SearchIndexer.php
176+
// src/EventListener/SearchIndexer.php
177177
namespace App\EventListener;
178178
179179
use Doctrine\Bundle\DoctrineBundle\Attribute\AsDoctrineListener;

form/unit_testing.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ allows you to return a list of extensions to register::
216216

217217
// or if you also need to read constraints from annotations
218218
$validator = Validation::createValidatorBuilder()
219-
->enableAnnotationMapping(true)
219+
->enableAttributeMapping()
220220
->getValidator();
221221

222222
return [

frontend/asset_mapper.rst

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,14 @@ If you want to download the package locally, use the ``--download`` option:
233233
$ php bin/console importmap:require bootstrap --download
234234
235235
This will download the package into an ``assets/vendor/`` directory and update
236-
the ``importmap.php`` file to point to it. You *should* commit this file to
237-
your repository.
236+
the ``importmap.php`` file to point to it. It's recommended to ignore this
237+
directory and not commit it to your repository. Therefore, you'll need to run the
238+
``php bin/console importmap:install`` command to download the files on other
239+
computers if some files are missing.
240+
241+
.. versionadded:: 6.4
242+
243+
The ``importmap:install`` command was introduced in Symfony 6.4.
238244

239245
.. note::
240246

0 commit comments

Comments
 (0)