Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a6e4d4a

Browse filesBrowse files
committed
bug #28968 [OptionsResolver] Fixed explicitly ignores a depreciation (yceruto)
This PR was merged into the 4.2-dev branch. Discussion ---------- [OptionsResolver] Fixed explicitly ignores a depreciation | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #28860 (comment) | License | MIT | Doc PR | - When a deprecated option with default value was resolved (the first time it's called) in this case through a lazy evaluation, [the default resolution process](https://github.com/symfony/symfony/blob/8398947c9c1c1266aad0bea773d0b524e0d81643/src/Symfony/Component/OptionsResolver/OptionsResolver.php#L771-L773) takes the resolved value and here should also trigger only if the option was provided by the user or is being called from a lazy evaluation, otherwise ignore. Commits ------- 8398947 Fixed explicitly ignores a depreciation
2 parents 8c24c35 + 8398947 commit a6e4d4a
Copy full SHA for a6e4d4a

File tree

2 files changed

+4
-1
lines changed
Filter options

2 files changed

+4
-1
lines changed

‎src/Symfony/Component/OptionsResolver/OptionsResolver.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/OptionsResolver/OptionsResolver.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -801,7 +801,7 @@ public function offsetGet($option/*, bool $triggerDeprecation = true*/)
801801

802802
// Shortcut for resolved options
803803
if (array_key_exists($option, $this->resolved)) {
804-
if ($triggerDeprecation && isset($this->deprecated[$option]) && \is_string($this->deprecated[$option])) {
804+
if ($triggerDeprecation && isset($this->deprecated[$option]) && (isset($this->given[$option]) || $this->calling) && \is_string($this->deprecated[$option])) {
805805
@trigger_error(strtr($this->deprecated[$option], array('%name%' => $option)), E_USER_DEPRECATED);
806806
}
807807

‎src/Symfony/Component/OptionsResolver/Tests/OptionsResolverTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/OptionsResolver/Tests/OptionsResolverTest.php
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -754,6 +754,9 @@ function (OptionsResolver $resolver) {
754754
yield 'It explicitly ignores a depreciation' => array(
755755
function (OptionsResolver $resolver) {
756756
$resolver
757+
->setDefault('baz', function (Options $options) {
758+
return $options->offsetGet('foo', false);
759+
})
757760
->setDefault('foo', null)
758761
->setDeprecated('foo')
759762
->setDefault('bar', function (Options $options) {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.