Skip to content

Commit c2fb7a4

Browse files
committed
Fixed explicitly ignores a depreciation
1 parent d4d6629 commit c2fb7a4

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

OptionsResolver.php

Lines 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

Tests/OptionsResolverTest.php

Lines 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)