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
+72-19Lines changed: 72 additions & 19 deletions
Original file line number
Diff line number
Diff line change
@@ -79,31 +79,45 @@ 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
+
91
98
A feature is marked as deprecated by adding a ``@deprecated`` phpdoc to
92
99
relevant classes, methods, properties, ...::
93
100
94
101
/**
95
-
* @deprecated since vendor-name/package-name 2.8, to be removed in 3.0. Use XXX instead.
102
+
* @deprecated since Symfony 2.8.
96
103
*/
97
104
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.
105
+
The deprecation message must indicate the version when the class was deprecated,
106
+
and whenever possible, how the feature was replaced::
101
107
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)::
108
+
/**
109
+
* @deprecated since Symfony 2.8, use Replacement instead.
110
+
*/
105
111
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);
112
+
When the replacement is in another namespace than the deprecated class, its FQCN must be used::
113
+
114
+
/**
115
+
* @deprecated since Symfony 2.8, use A\B\Replacement instead.
116
+
*/
117
+
118
+
A PHP ``E_USER_DEPRECATED`` error must also be triggered to help people with th migration::
119
+
120
+
@trigger_error(sprintf('The "%s" class is deprecated since Symfony 2.8, use "%s" instead.', Deprecated::class, Replacement::class), E_USER_DEPRECATED);
107
121
108
122
Without the `@-silencing operator`_, users would need to opt-out from deprecation
109
123
notices. Silencing swaps this behavior and allows users to opt-in when they are
@@ -114,19 +128,58 @@ the Web Debug Toolbar or by the PHPUnit bridge).
114
128
115
129
When deprecating a whole class the ``trigger_error()`` call should be placed
116
130
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);
135
+
use Symfony\Component\Routing\Loader\ContainerLoader;
122
136
123
-
use Symfony\Component\ExpressionLanguage\ParsedExpression;
137
+
@trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.4, use "%s" instead.', ServiceRouterLoader::class, ContainerLoader::class), E_USER_DEPRECATED);
124
138
125
139
/**
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.
140
+
* @deprecated since Symfony 4.4, use Symfony\Component\Routing\Loader\ContainerLoader instead.
129
141
*/
130
-
class ArrayParserCache implements ParserCacheInterface
142
+
class ServiceRouterLoader extends ObjectRouteLoader
0 commit comments