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: CHANGELOG.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,8 @@ CHANGELOG
6
6
7
7
* added fluent configuration of options using `OptionResolver::define()`
8
8
* added `setInfo()` and `getInfo()` methods
9
+
* updated the signature of method `OptionsResolver::setDeprecated()` to `OptionsResolver::setDeprecation(string $option, string $package, string $version, $message)`
10
+
* deprecated `OptionsResolverIntrospector::getDeprecationMessage()`, use `OptionsResolverIntrospector::getDeprecation()` instead
trigger_deprecation('symfony/options-resolver', '5.1', 'The signature of method "%s()" requires 2 new arguments: "string $package, string $version", not defining them is deprecated.', __METHOD__);
99
+
100
+
$message = $args[0] ?? 'The option "%name%" is deprecated.';
101
+
$package = (string) $version = '';
102
+
} else {
103
+
$package = (string) $args[0];
104
+
$version = (string) $args[1];
105
+
$message = (string) ($args[2] ?? 'The option "%name%" is deprecated.');
Copy file name to clipboardExpand all lines: OptionsResolver.php
+34-14Lines changed: 34 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -421,9 +421,11 @@ public function isNested(string $option): bool
421
421
* passed to the closure is the value of the option after validating it
422
422
* and before normalizing it.
423
423
*
424
-
* @param string|\Closure $deprecationMessage
424
+
* @param string $package The name of the composer package that is triggering the deprecation
425
+
* @param string $version The version of the package that introduced the deprecation
426
+
* @param string|\Closure $message The deprecation message to use
425
427
*/
426
-
publicfunctionsetDeprecated(string$option, $deprecationMessage= 'The option "%name%" is deprecated.'): self
428
+
publicfunctionsetDeprecated(string$option/*, string $package, string $version, $message = 'The option "%name%" is deprecated.' */): self
427
429
{
428
430
if ($this->locked) {
429
431
thrownewAccessException('Options cannot be deprecated from a lazy option or normalizer.');
@@ -433,16 +435,33 @@ public function setDeprecated(string $option, $deprecationMessage = 'The option
433
435
thrownewUndefinedOptionsException(sprintf('The option "%s" does not exist, defined options are: "%s".', $this->formatOptions([$option]), implode('", "', array_keys($this->defined))));
434
436
}
435
437
436
-
if (!\is_string($deprecationMessage) && !$deprecationMessageinstanceof \Closure) {
437
-
thrownewInvalidArgumentException(sprintf('Invalid type for deprecation message argument, expected string or \Closure, but got "%s".', get_debug_type($deprecationMessage)));
438
+
$args = \func_get_args();
439
+
440
+
if (\func_num_args() < 3) {
441
+
trigger_deprecation('symfony/options-resolver', '5.1', 'The signature of method "%s()" requires 2 new arguments: "string $package, string $version", not defining them is deprecated.', __METHOD__);
442
+
443
+
$message = $args[1] ?? 'The option "%name%" is deprecated.';
444
+
$package = $version = '';
445
+
} else {
446
+
$package = $args[1];
447
+
$version = $args[2];
448
+
$message = $args[3] ?? 'The option "%name%" is deprecated.';
449
+
}
450
+
451
+
if (!\is_string($message) && !$messageinstanceof \Closure) {
452
+
thrownewInvalidArgumentException(sprintf('Invalid type for deprecation message argument, expected string or \Closure, but got "%s".', get_debug_type($message)));
438
453
}
439
454
440
455
// ignore if empty string
441
-
if ('' === $deprecationMessage) {
456
+
if ('' === $message) {
442
457
return$this;
443
458
}
444
459
445
-
$this->deprecated[$option] = $deprecationMessage;
460
+
$this->deprecated[$option] = [
461
+
'package' => $package,
462
+
'version' => $version,
463
+
'message' => $message,
464
+
];
446
465
447
466
// Make sure the option is processed
448
467
unset($this->resolved[$option]);
@@ -903,8 +922,8 @@ public function offsetGet($option, bool $triggerDeprecation = true)
903
922
904
923
// Shortcut for resolved options
905
924
if (isset($this->resolved[$option]) || \array_key_exists($option, $this->resolved)) {
// If the closure is already being called, we have a cyclic dependency
1055
1075
if (isset($this->calling[$option])) {
1056
1076
thrownewOptionDefinitionException(sprintf('The options "%s" have a cyclic dependency.', $this->formatOptions(array_keys($this->calling))));
1057
1077
}
1058
1078
1059
1079
$this->calling[$option] = true;
1060
1080
try {
1061
-
if (!\is_string($deprecationMessage = $deprecationMessage($this, $value))) {
1062
-
thrownewInvalidOptionsException(sprintf('Invalid type for deprecation message, expected string but got "%s", return an empty string to ignore.', get_debug_type($deprecationMessage)));
1081
+
if (!\is_string($message = $message($this, $value))) {
1082
+
thrownewInvalidOptionsException(sprintf('Invalid type for deprecation message, expected string but got "%s", return an empty string to ignore.', get_debug_type($message)));
0 commit comments