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
feature #35871 [Config] Improve the deprecation features by handling package and version (atailouloute)
This PR was merged into the 5.1-dev branch.
Discussion
----------
[Config] Improve the deprecation features by handling package and version
| Q | A
| ------------- | ---
| Branch? | master
| Bug fix? | no
| New feature? | yes
| Deprecations? | yes
| Tickets | https://github.com/orgs/symfony/projects/1#card-32681032
| License | MIT
| Doc PR | TODO
Commits
-------
f4de76d [Config] Improve the deprecation features by handling package and version
Copy file name to clipboardExpand all lines: UPGRADE-5.1.md
+7Lines changed: 7 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,13 @@
1
1
UPGRADE FROM 5.0 to 5.1
2
2
=======================
3
3
4
+
Config
5
+
------
6
+
7
+
* The signature of method `NodeDefinition::setDeprecated()` has been updated to `NodeDefinition::setDeprecation(string $package, string $version, string $message)`.
8
+
* The signature of method `BaseNode::setDeprecated()` has been updated to `BaseNode::setDeprecation(string $package, string $version, string $message)`.
9
+
* Passing a null message to `BaseNode::setDeprecated()` to un-deprecate a node is deprecated
Copy file name to clipboardExpand all lines: UPGRADE-6.0.md
+7Lines changed: 7 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,13 @@
1
1
UPGRADE FROM 5.x to 6.0
2
2
=======================
3
3
4
+
Config
5
+
------
6
+
7
+
* The signature of method `NodeDefinition::setDeprecated()` has been updated to `NodeDefinition::setDeprecation(string $package, string $version, string $message)`.
8
+
* The signature of method `BaseNode::setDeprecated()` has been updated to `BaseNode::setDeprecation(string $package, string $version, string $message)`.
9
+
* Passing a null message to `BaseNode::setDeprecated()` to un-deprecate a node is not supported anymore.
Copy file name to clipboardExpand all lines: src/Symfony/Component/Config/CHANGELOG.md
+7Lines changed: 7 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,13 @@
1
1
CHANGELOG
2
2
=========
3
3
4
+
5.1.0
5
+
-----
6
+
7
+
* updated the signature of method `NodeDefinition::setDeprecated()` to `NodeDefinition::setDeprecation(string $package, string $version, string $message)`
8
+
* updated the signature of method `BaseNode::setDeprecated()` to `BaseNode::setDeprecation(string $package, string $version, string $message)`
9
+
* deprecated passing a null message to `BaseNode::setDeprecated()` to un-deprecate a node
Copy file name to clipboardExpand all lines: src/Symfony/Component/Config/Definition/BaseNode.php
+51-5Lines changed: 51 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -35,7 +35,7 @@ abstract class BaseNode implements NodeInterface
35
35
protected$finalValidationClosures = [];
36
36
protected$allowOverwrite = true;
37
37
protected$required = false;
38
-
protected$deprecationMessage = null;
38
+
protected$deprecation = [];
39
39
protected$equivalentValues = [];
40
40
protected$attributes = [];
41
41
protected$pathSeparator;
@@ -198,12 +198,41 @@ public function setRequired(bool $boolean)
198
198
/**
199
199
* Sets this node as deprecated.
200
200
*
201
+
* @param string $package The name of the composer package that is triggering the deprecation
202
+
* @param string $version The version of the package that introduced the deprecation
203
+
* @param string $message The deprecation message to use
204
+
*
201
205
* You can use %node% and %path% placeholders in your message to display,
202
206
* respectively, the node name and its complete path.
203
207
*/
204
-
publicfunctionsetDeprecated(?string$message)
208
+
publicfunctionsetDeprecated(?string$package/*, string $version, string $message = 'The child node "%node%" at path "%path%" is deprecated.' */)
205
209
{
206
-
$this->deprecationMessage = $message;
210
+
$args = \func_get_args();
211
+
212
+
if (\func_num_args() < 2) {
213
+
trigger_deprecation('symfony/config', '5.1', 'The signature of method "%s()" requires 3 arguments: "string $package, string $version, string $message", not defining them is deprecated.', __METHOD__);
214
+
215
+
if (!isset($args[0])) {
216
+
trigger_deprecation('symfony/config', '5.1', 'Passing a null message to un-deprecate a node is deprecated.');
217
+
218
+
$this->deprecation = [];
219
+
220
+
return;
221
+
}
222
+
223
+
$message = (string) $args[0];
224
+
$package = $version = '';
225
+
} else {
226
+
$package = (string) $args[0];
227
+
$version = (string) $args[1];
228
+
$message = (string) ($args[2] ?? 'The child node "%node%" at path "%path%" is deprecated.');
229
+
}
230
+
231
+
$this->deprecation = [
232
+
'package' => $package,
233
+
'version' => $version,
234
+
'message' => $message,
235
+
];
207
236
}
208
237
209
238
/**
@@ -249,7 +278,7 @@ public function isRequired()
249
278
*/
250
279
85EA
publicfunctionisDeprecated()
251
280
{
252
-
returnnull !== $this->deprecationMessage;
281
+
return(bool) $this->deprecation;
253
282
}
254
283
255
284
/**
@@ -259,10 +288,27 @@ public function isDeprecated()
259
288
* @param string $path the path of the node
260
289
*
261
290
* @return string
291
+
*
292
+
* @deprecated since Symfony 5.1, use "getDeprecation()" instead.
Copy file name to clipboardExpand all lines: src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php
+24-3Lines changed: 24 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -28,7 +28,7 @@ abstract class NodeDefinition implements NodeParentInterface
28
28
protected$defaultValue;
29
29
protected$default = false;
30
30
protected$required = false;
31
-
protected$deprecationMessage = null;
31
+
protected$deprecation = [];
32
32
protected$merge;
33
33
protected$allowEmptyValue = true;
34
34
protected$nullEquivalent;
@@ -159,14 +159,35 @@ public function isRequired()
159
159
/**
160
160
* Sets the node as deprecated.
161
161
*
162
+
* @param string $package The name of the composer package that is triggering the deprecation
163
+
* @param string $version The version of the package that introduced the deprecation
164
+
* @param string $message The deprecation message to use
165
+
*
162
166
* You can use %node% and %path% placeholders in your message to display,
163
167
* respectively, the node name and its complete path.
164
168
*
165
169
* @return $this
166
170
*/
167
-
publicfunctionsetDeprecated(string$message = 'The child node "%node%" at path "%path%" is deprecated.')
171
+
publicfunctionsetDeprecated(/* string $package, string $version, string $message = 'The child node "%node%" at path "%path%" is deprecated.' */)
168
172
{
169
-
$this->deprecationMessage = $message;
173
+
$args = \func_get_args();
174
+
175
+
if (\func_num_args() < 2) {
176
+
trigger_deprecation('symfony/config', '5.1', 'The signature of method "%s()" requires 3 arguments: "string $package, string $version, string $message", not defining them is deprecated.', __METHOD__);
177
+
178
+
$message = $args[0] ?? 'The child node "%node%" at path "%path%" is deprecated.';
179
+
$package = $version = '';
180
+
} else {
181
+
$package = (string) $args[0];
182
+
$version = (string) $args[1];
183
+
$message = (string) ($args[2] ?? 'The child node "%node%" at path "%path%" is deprecated.');
0 commit comments