Skip to content

[OptionsResolver] Remove support for nested options definition via setDefault(), use setOptions() instead #60723

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions UPGRADE-8.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,25 @@ HttpClient
* Remove support for amphp/http-client < 5
* Remove setLogger() methods on decorators; configure the logger on the wrapped client directly instead

OptionsResolver
---------------

* Remove support for nested options definition via `setDefault()`, use `setOptions()` instead

*Before*
```php
$resolver->setDefault('option', function (OptionsResolver $resolver) {
// ...
});
```

*After*
```php
$resolver->setOptions('option', function (OptionsResolver $resolver) {
// ...
});
```

TwigBridge
----------

Expand Down
5 changes: 5 additions & 0 deletions src/Symfony/Component/OptionsResolver/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
CHANGELOG
=========

8.0
---

* Remove support for nested options definition via `setDefault()`, use `setOptions()` instead

7.3
---

Expand Down
16 changes: 0 additions & 16 deletions src/Symfony/Component/OptionsResolver/OptionsResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,22 +229,6 @@ public function setDefault(string $option, mixed $value): static

return $this;
}

// Remove in Symfony 8.0.
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()))) {
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__);
$this->deprecatedNestedOptions[$option] = true;

// Store closure for later evaluation
$this->nested[$option][] = $value;
$this->defaults[$option] = [];
$this->defined[$option] = true;

// Make sure the option is processed and is not lazy anymore
unset($this->resolved[$option], $this->lazy[$option]);

return $this;
}
}

// This option is not lazy anymore
Expand Down
Loading
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy