Skip to content

Commit d8d242d

Browse files
committed
Merge branch '6.0' into 6.1
* 6.0: Replace remaining annotations with attributes, remove remaining annotations configuration block Fixing "HTML5 color format" link Fixing path Removing heading fixes #16310 unclear alternate DSN format
2 parents 5404ee4 + b80b1e3 commit d8d242d

File tree

15 files changed

+88
-241
lines changed

15 files changed

+88
-241
lines changed

best_practices.rst

+5-6
Original file line numberDiff line numberDiff line change
@@ -236,11 +236,11 @@ configuration. You don't need to browse several files created with different
236236
formats (YAML, XML, PHP): all the configuration is just where you need it and
237237
it only uses one format.
238238

239-
Don't Use Annotations to Configure the Controller Template
240-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
239+
Don't Use Attributes to Configure the Controller Template
240+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
241241

242-
The ``@Template`` annotation is useful, but also involves some *magic*.
243-
Moreover, most of the time ``@Template`` is used without any parameters, which
242+
The ``#[Template]`` attribute is useful, but also involves some *magic*.
243+
Moreover, most of the time ``#[Template]`` is used without any parameters, which
244244
makes it more difficult to know which template is being rendered. It also hides
245245
the fact that a controller should always return a ``Response`` object.
246246

@@ -380,8 +380,7 @@ Use Voters to Implement Fine-grained Security Restrictions
380380

381381
If your security logic is complex, you should create custom
382382
:doc:`security voters </security/voters>` instead of defining long expressions
383-
inside the ``#[Security]`` attribute (or in the ``@Security`` annotation if your
384-
PHP version doesn't support attributes yet).
383+
inside the ``#[Security]`` attribute.
385384

386385
Web Assets
387386
----------

components/cache/adapters/redis_adapter.rst

+62-15
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,18 @@ replaced by ``rediss`` (the second ``s`` means "secure").
6767

6868
.. note::
6969

70-
A `Data Source Name (DSN)`_ for this adapter must use the following format.
70+
A `Data Source Name (DSN)`_ for this adapter must use either one of the following formats.
7171

7272
.. code-block:: text
7373
7474
redis[s]://[pass@][ip|host|socket[:port]][/db-index]
7575
76+
.. code-block:: text
77+
78+
redis[s]:[[user]:pass@]?[ip|host|socket[:port]][&params]
79+
80+
Values for placeholders ``[user]``, ``[:port]``, ``[/db-index]`` and ``[&params]`` are optional.
81+
7682
Below are common examples of valid DSNs showing a combination of available values::
7783

7884
use Symfony\Component\Cache\Adapter\RedisAdapter;
@@ -89,8 +95,13 @@ Below are common examples of valid DSNs showing a combination of available value
8995
// socket "/var/run/redis.sock" and auth "bad-pass"
9096
RedisAdapter::createConnection('redis://bad-pass@/var/run/redis.sock');
9197

92-
// a single DSN can define multiple servers using the following syntax:
93-
// host[hostname-or-IP:port] (where port is optional). Sockets must include a trailing ':'
98+
// host "redis1" (docker container) with alternate DSN syntax and selecting database index "3"
99+
RedisAdapter::createConnection('redis:?host[redis1:6379]&dbindex=3');
100+
101+
// providing credentials with alternate DSN syntax
102+
RedisAdapter::createConnection('redis:default:verysecurepassword@?host[redis1:6379]&dbindex=3');
103+
104+
// a single DSN can also define multiple servers
94105
RedisAdapter::createConnection(
95106
'redis:?host[localhost]&host[localhost:6379]&host[/var/run/redis.sock:]&auth=my-password&redis_cluster=1'
96107
);
@@ -103,6 +114,16 @@ parameter to set the name of your service group::
103114
'redis:?host[redis1:26379]&host[redis2:26379]&host[redis3:26379]&redis_sentinel=mymaster'
104115
);
105116

117+
// providing credentials
118+
RedisAdapter::createConnection(
119+
'redis:default:verysecurepassword@?host[redis1:26379]&host[redis2:26379]&host[redis3:26379]&redis_sentinel=mymaster'
120+
);
121+
122+
// providing credentials and selecting database index "3"
123+
RedisAdapter::createConnection(
124+
'redis:default:verysecurepassword@?host[redis1:26379]&host[redis2:26379]&host[redis3:26379]&redis_sentinel=mymaster&dbindex=3'
125+
);
126+
106127
.. note::
107128

108129
See the :class:`Symfony\\Component\\Cache\\Traits\\RedisTrait` for more options
@@ -124,29 +145,31 @@ array of ``key => value`` pairs representing option names and their respective v
124145

125146
// associative array of configuration options
126147
[
127-
'lazy' => false,
148+
'class' => null,
128149
'persistent' => 0,
129150
'persistent_id' => null,
130-
'tcp_keepalive' => 0,
131151
'timeout' => 30,
132152
'read_timeout' => 0,
133153
'retry_interval' => 0,
154+
'tcp_keepalive' => 0,
155+
'lazy' => null,
156+
'redis_cluster' => false,
157+
'redis_sentinel' => null,
158+
'dbindex' => 0,
159+
'failover' => 'none',
160+
'ssl' => null,
134161
]
135162

136163
);
137164

138165
Available Options
139166
~~~~~~~~~~~~~~~~~
140167

141-
``class`` (type: ``string``)
168+
``class`` (type: ``string``, default: ``null``)
142169
Specifies the connection library to return, either ``\Redis`` or ``\Predis\Client``.
143170
If none is specified, it will return ``\Redis`` if the ``redis`` extension is
144-
available, and ``\Predis\Client`` otherwise.
145-
146-
``lazy`` (type: ``bool``, default: ``false``)
147-
Enables or disables lazy connections to the backend. It's ``false`` by
148-
default when using this as a stand-alone component and ``true`` by default
149-
when using it inside a Symfony application.
171+
available, and ``\Predis\Client`` otherwise. Explicitly set this to ``\Predis\Client`` for Sentinel if you are
172+
running into issues when retrieving master information.
150173

151174
``persistent`` (type: ``int``, default: ``0``)
152175
Enables or disables use of persistent connections. A value of ``0`` disables persistent
@@ -155,6 +178,10 @@ Available Options
155178
``persistent_id`` (type: ``string|null``, default: ``null``)
156179
Specifies the persistent id string to use for a persistent connection.
157180

181+
``timeout`` (type: ``int``, default: ``30``)
182+
Specifies the time (in seconds) used to connect to a Redis server before the
183+
connection attempt times out.
184+
158185
``read_timeout`` (type: ``int``, default: ``0``)
159186
Specifies the time (in seconds) used when performing read operations on the underlying
160187
network resource before the operation times out.
@@ -167,9 +194,28 @@ Available Options
167194
Specifies the `TCP-keepalive`_ timeout (in seconds) of the connection. This
168195
requires phpredis v4 or higher and a TCP-keepalive enabled server.
169196

170-
``timeout`` (type: ``int``, default: ``30``)
171-
Specifies the time (in seconds) used to connect to a Redis server before the
172-
connection attempt times out.
197+
``lazy`` (type: ``bool``, default: ``null``)
198+
Enables or disables lazy connections to the backend. It's ``false`` by
199+
default when using this as a stand-alone component and ``true`` by default
200+
when using it inside a Symfony application.
201+
202+
``redis_cluster`` (type: ``bool``, default: ``false``)
203+
Enables or disables redis cluster. The actual value passed is irrelevant as long as it passes loose comparison
204+
checks: `redis_cluster=1` will suffice.
205+
206+
``redis_sentinel`` (type: ``string``, default: ``null``)
207+
Specifies the master name connected to the sentinels.
208+
209+
``dbindex`` (type: ``int``, default: ``0``)
210+
Specifies the database index to select.
211+
212+
``failover`` (type: ``string``, default: ``none``)
213+
Specifies failover for cluster implementations. For ``\RedisCluster`` valid options are ``none`` (default),
214+
``error``, ``distribute`` or ``slaves``. For ``\Predis\ClientInterface`` valid options are ``slaves``
215+
or ``distribute``.
216+
217+
``ssl`` (type: ``bool``, default: ``null``)
218+
SSL context options. See `php.net/context.ssl`_ for more information.
173219

174220
.. note::
175221

@@ -217,3 +263,4 @@ Read more about this topic in the official `Redis LRU Cache Documentation`_.
217263
.. _`TCP-keepalive`: https://redis.io/topics/clients#tcp-keepalive
218264
.. _`Redis Sentinel`: https://redis.io/topics/sentinel
219265
.. _`Redis LRU Cache Documentation`: https://redis.io/topics/lru-cache
266+
.. _`php.net/context.ssl`: https://php.net/context.ssl

components/http_kernel.rst

+5-5
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ on the event object that's passed to listeners on this event.
302302
the profiler is enabled.
303303

304304
One interesting listener comes from the `SensioFrameworkExtraBundle`_. This
305-
listener's `@ParamConverter`_ functionality allows you to pass a full object
305+
listener's `#[ParamConverter]`_ functionality allows you to pass a full object
306306
(e.g. a ``Post`` object) to your controller instead of a scalar value (e.g.
307307
an ``id`` parameter that was on your route). The listener -
308308
``ParamConverterListener`` - uses reflection to look at each of the
@@ -411,8 +411,8 @@ return a ``Response``.
411411

412412
There is no default listener inside the Symfony Framework for the ``kernel.view``
413413
event. However, `SensioFrameworkExtraBundle`_ *does* add a listener to this
414-
event. If your controller returns an array, and you place the `@Template`_
415-
annotation above the controller, then this listener renders a template,
414+
event. If your controller returns an array, and you place the `#[Template]`_
415+
attribute above the controller, then this listener renders a template,
416416
passes the array you returned from your controller to that template, and
417417
creates a ``Response`` containing the returned content from that template.
418418

@@ -750,6 +750,6 @@ Learn more
750750
.. _FOSRestBundle: https://github.com/friendsofsymfony/FOSRestBundle
751751
.. _`PHP FPM`: https://www.php.net/manual/en/install.fpm.php
752752
.. _`SensioFrameworkExtraBundle`: https://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle/index.html
753-
.. _`@ParamConverter`: https://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle/annotations/converters.html
754-
.. _`@Template`: https://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle/annotations/view.html
753+
.. _`#[ParamConverter]`: https://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle/annotations/converters.html
754+
.. _`#[Template]`: https://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle/annotations/view.html
755755
.. _variadic: https://www.php.net/manual/en/functions.arguments.php#functions.variable-arg-list

components/serializer.rst

+1-102
Original file line numberDiff line numberDiff line change
@@ -293,35 +293,6 @@ Then, create your groups definition:
293293

294294
.. configuration-block::
295295

296-
.. code-block:: php-annotations
297-
298-
namespace Acme;
299-
300-
use Symfony\Component\Serializer\Annotation\Groups;
301-
302-
class MyObj
303-
{
304-
/**
305-
* @Groups({"group1", "group2"})
306-
*/
307-
public $foo;
308-
309-
/**
310-
* @Groups({"group4"})
311-
*/
312-
public $anotherProperty;
313-
314-
/**
315-
* @Groups("group3")
316-
*/
317-
public function getBar() // is* methods are also supported
318-
{
319-
return $this->bar;
320-
}
321-
322-
// ...
323-
}
324-
325296
.. code-block:: php-attributes
326297
327298
namespace Acme;
@@ -467,22 +438,6 @@ Option 1: Using ``@Ignore`` Annotation
467438

468439
.. configuration-block::
469440

470-
.. code-block:: php-annotations
471-
472-
namespace App\Model;
473-
474-
use Symfony\Component\Serializer\Annotation\Ignore;
475-
476-
class MyClass
477-
{
478-
public $foo;
479-
480-
/**
481-
* @Ignore()
482-
*/
483-
public $bar;
484-
}
485-
486441
.. code-block:: php-attributes
487442
488443
namespace App\Model;
@@ -697,27 +652,6 @@ defines a ``Person`` entity with a ``firstName`` property:
697652

698653
.. configuration-block::
699654

700-
.. code-block:: php-annotations
701-
702-
namespace App\Entity;
703-
704-
use Symfony\Component\Serializer\Annotation\SerializedName;
705-
706-
class Person
707-
{
708-
/**
709-
* @SerializedName("customer_name")
710-
*/
711-
private $firstName;
712-
713-
public function __construct($firstName)
714-
{
715-
$this->firstName = $firstName;
716-
}
717-
718-
// ...
719-
}
720-
721655
.. code-block:: php-attributes
722656
723657
namespace App\Entity;
@@ -1450,22 +1384,6 @@ Here, we set it to 2 for the ``$child`` property:
14501384

14511385
.. configuration-block::
14521386

1453-
.. code-block:: php-annotations
1454-
1455-
namespace Acme;
1456-
1457-
use Symfony\Component\Serializer\Annotation\MaxDepth;
1458-
1459-
class MyObj
1460-
{
1461-
/**
1462-
* @MaxDepth(2)
1463-
*/
1464-
public $child;
1465-
1466-
// ...
1467-
}
1468-
14691387
.. code-block:: php-attributes
14701388
14711389
namespace Acme;
@@ -1539,9 +1457,7 @@ having unique identifiers::
15391457
{
15401458
public $id;
15411459

1542-
/**
1543-
* @MaxDepth(1)
1544-
*/
1460+
#[MaxDepth(1)]
15451461
public $child;
15461462
}
15471463

@@ -1773,23 +1689,6 @@ and ``BitBucketCodeRepository`` classes:
17731689

17741690
.. configuration-block::
17751691

1776-
.. code-block:: php-annotations
1777-
1778-
namespace App;
1779-
1780-
use Symfony\Component\Serializer\Annotation\DiscriminatorMap;
1781-
1782-
/**
1783-
* @DiscriminatorMap(typeProperty="type", mapping={
1784-
* "github"="App\GitHubCodeRepository",
1785-
* "bitbucket"="App\BitBucketCodeRepository"
1786-
* })
1787-
*/
1788-
abstract class CodeRepository
1789-
{
1790-
// ...
1791-
}
1792-
17931692
.. code-block:: php-attributes
17941693
17951694
namespace App;

contributing/documentation/standards.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ Configuration examples should show all supported formats using
8888
(and their orders) are:
8989

9090
* **Configuration** (including services): YAML, XML, PHP
91-
* **Routing**: Annotations, YAML, XML, PHP
92-
* **Validation**: Annotations, YAML, XML, PHP
93-
* **Doctrine Mapping**: Annotations, YAML, XML, PHP
91+
* **Routing**: Attributes, YAML, XML, PHP
92+
* **Validation**: Attributes, YAML, XML, PHP
93+
* **Doctrine Mapping**: Attributes, YAML, XML, PHP
9494
* **Translation**: XML, YAML, PHP
9595

9696
Example

controller/argument_value_resolver.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,8 @@ with the ``User`` class::
186186
}
187187
}
188188

189-
Beware that this feature is already provided by the `@ParamConverter`_
190-
annotation from the SensioFrameworkExtraBundle. If you have that bundle
189+
Beware that this feature is already provided by the `#[ParamConverter]`_
190+
attribute from the SensioFrameworkExtraBundle. If you have that bundle
191191
installed in your project, add this config to disable the auto-conversion of
192192
type-hinted method arguments:
193193

@@ -372,5 +372,5 @@ command to see which argument resolvers are present and in which order they run.
372372
$user = null``). The ``DefaultValueResolver`` is executed as the last
373373
resolver and will use the default value if no value was already resolved.
374374

375-
.. _`@ParamConverter`: https://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle/annotations/converters.html
375+
.. _`#[ParamConverter]`: https://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle/annotations/converters.html
376376
.. _`yield`: https://www.php.net/manual/en/language.generators.syntax.php

form/form_collections.rst

-2
Original file line numberDiff line numberDiff line change
@@ -522,8 +522,6 @@ Now, you need to put some code into the ``removeTag()`` method of ``Task``::
522522
}
523523
}
524524

525-
Template Modifications
526-
~~~~~~~~~~~~~~~~~~~~~~
527525

528526
The ``allow_delete`` option means that if an item of a collection
529527
isn't sent on submission, the related data is removed from the collection

form/form_themes.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ order is important, because each theme overrides all the previous ones):
141141
{# apply multiple form themes but only to the form of this template #}
142142
{% form_theme form with [
143143
'foundation_5_layout.html.twig',
144-
'forms/my_custom_theme.html.twig'
144+
'form/my_custom_theme.html.twig'
145145
] %}
146146
147147
{# ... #}

reference/configuration/doctrine.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ to organize the application code.
310310
Custom Mapping Entities in a Bundle
311311
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
312312

313-
Doctrine's ``auto_mapping`` feature loads annotation configuration from
313+
Doctrine's ``auto_mapping`` feature loads attribute configuration from
314314
the ``Entity/`` directory of each bundle *and* looks for other formats (e.g.
315315
YAML, XML) in the ``Resources/config/doctrine`` directory.
316316

0 commit comments

Comments
 (0)