Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f1abd5c

Browse files
committed
Remove support for nested options definition via setDefault(), use setOptions() instead
1 parent 8364823 commit f1abd5c

File tree

4 files changed

+24
-632
lines changed

4 files changed

+24
-632
lines changed

UPGRADE-8.0.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,25 @@ HttpClient
1212
* Remove support for amphp/http-client < 5
1313
* Remove setLogger() methods on decorators; configure the logger on the wrapped client directly instead
1414

15+
OptionsResolver
16+
---------------
17+
18+
* Remove support for nested options definition via `setDefault()`, use `setOptions()` instead
19+
20+
*Before*
21+
```php
22+
$resolver->setDefault('option', function (OptionsResolver $resolver) {
23+
// ...
24+
});
25+
```
26+
27+
*After*
28+
```php
29+
$resolver->setOptions('option', function (OptionsResolver $resolver) {
30+
// ...
31+
});
32+
```
33+
1534
TwigBridge
1635
----------
1736

src/Symfony/Component/OptionsResolver/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
8.0
5+
---
6+
7+
* Remove support for nested options definition via `setDefault()`, use `setOptions()` instead
8+
49
7.3
510
---
611

src/Symfony/Component/OptionsResolver/OptionsResolver.php

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -229,22 +229,6 @@ public function setDefault(string $option, mixed $value): static
229229

230230
return $this;
231231
}
232-
233-
// Remove in Symfony 8.0.
234-
if (isset($params[0]) && ($type = $params[0]->getType()) instanceof \ReflectionNamedType && self::class === $type->getName() && (!isset($params[1]) || (($type = $params[1]->getType()) instanceof \ReflectionNamedType && Options::class === $type->getName()))) {
235-
trigger_deprecation('symfony/options-resolver', '7.3', 'Defining nested options via "%s()" is deprecated and will be removed in Symfony 8.0, use "setOptions()" method instead.', __METHOD__);
236-
$this->deprecatedNestedOptions[$option] = true;
237-
238-
// Store closure for later evaluation
239-
$this->nested[$option][] = $value;
240-
$this->defaults[$option] = [];
241-
$this->defined[$option] = true;
242-
243-
// Make sure the option is processed and is not lazy anymore
244-
unset($this->resolved[$option], $this->lazy[$option]);
245-
246-
return $this;
247-
}
248232
}
249233

250234
// This option is not lazy anymore

0 commit comments

Comments
 (0)