You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: contributing/code/conventions.rst
+74-19Lines changed: 74 additions & 19 deletions
Original file line number
Diff line number
Diff line change
@@ -79,31 +79,47 @@ must be used instead (where ``XXX`` is the name of the related thing):
79
79
80
80
.. _contributing-code-conventions-deprecations:
81
81
82
-
Deprecations
83
-
------------
82
+
Deprecating code
83
+
----------------
84
84
85
85
From time to time, some classes and/or methods are deprecated in the
86
86
framework; that happens when a feature implementation cannot be changed
87
87
because of backward compatibility issues, but we still want to propose a
88
88
"better" alternative. In that case, the old implementation can simply be
89
89
**deprecated**.
90
90
91
+
Deprecations must only be introduced on the next minor version of the impacted
92
+
component (or bundle, bridge, contract).
93
+
They can exceptionally be introduced on previous supported versions if they are critical.
94
+
95
+
A new class (or interface, trait) cannot be introduced as deprecated, or
96
+
contains deprecated methods.
97
+
98
+
A new method cannot be introduced as deprecated.
99
+
91
100
A feature is marked as deprecated by adding a ``@deprecated`` phpdoc to
92
101
relevant classes, methods, properties, ...::
93
102
94
103
/**
95
-
* @deprecated since vendor-name/package-name 2.8, to be removed in 3.0. Use XXX instead.
104
+
* @deprecated since Symfony 2.8.
105
+
*/
106
+
107
+
The deprecation message must indicate the version when the class was deprecated,
108
+
and whenever possible, how the feature was replaced::
109
+
110
+
/**
111
+
* @deprecated since Symfony 2.8, use Replacement instead.
96
112
*/
97
113
98
-
The deprecation message should indicate the version when the class/method was
99
-
deprecated, the version when it will be removed, and whenever possible, how
100
-
the feature was replaced.
114
+
When the replacement is in another namespace than the deprecated class, its FQCN must be used::
115
+
116
+
/**
117
+
* @deprecated since Symfony 2.8, use A\B\Replacement instead.
118
+
*/
101
119
102
-
A PHP ``E_USER_DEPRECATED`` error must also be triggered to help people with
103
-
the migration starting one or two minor versions before the version where the
104
-
feature will be removed (depending on the criticality of the removal)::
120
+
A PHP ``E_USER_DEPRECATED`` error must also be triggered to help people with the migration::
105
121
106
-
@trigger_error('XXX() is deprecated since vendor-name/package-name 2.8 and will be removed in 3.0. Use XXX instead.', E_USER_DEPRECATED);
122
+
@trigger_error(sprintf('The "%s" class is deprecated since Symfony 2.8, use "%s" instead.', Deprecated::class, Replacement::class), E_USER_DEPRECATED);
107
123
108
124
Without the `@-silencing operator`_, users would need to opt-out from deprecation
109
125
notices. Silencing swaps this behavior and allows users to opt-in when they are
@@ -114,19 +130,58 @@ the Web Debug Toolbar or by the PHPUnit bridge).
114
130
115
131
When deprecating a whole class the ``trigger_error()`` call should be placed
116
132
between the namespace and the use declarations, like in this example from
@trigger_error('The '.__NAMESPACE__.'\ArrayParserCache class is deprecated since version 3.2 and will be removed in 4.0. Use the Symfony\Component\Cache\Adapter\ArrayAdapter class instead.', E_USER_DEPRECATED);
137
+
use Symfony\Component\Routing\Loader\ContainerLoader;
122
138
123
-
use Symfony\Component\ExpressionLanguage\ParsedExpression;
139
+
@trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.4, use "%s" instead.', ServiceRouterLoader::class, ContainerLoader::class), E_USER_DEPRECATED);
124
140
125
141
/**
126
-
* @author Adrien Brault <adrien.brault@gmail.com>
127
-
*
128
-
* @deprecated since Symfony 3.2, to be removed in 4.0. Use the Symfony\Component\Cache\Adapter\ArrayAdapter class instead.
142
+
* @deprecated since Symfony 4.4, use Symfony\Component\Routing\Loader\ContainerLoader instead.
129
143
*/
130
-
class ArrayParserCache implements ParserCacheInterface
144
+
class ServiceRouterLoader extends ObjectRouteLoader
0 commit comments