Skip to content

Commit 50406ed

Browse files
committed
[OptionsResolver] Ensure remove() also unsets deprecation status
1 parent d28e7e2 commit 50406ed

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

OptionsResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -803,7 +803,7 @@ public function remove(string|array $optionNames): static
803803

804804
foreach ((array) $optionNames as $option) {
805805
unset($this->defined[$option], $this->defaults[$option], $this->required[$option], $this->resolved[$option]);
806-
unset($this->lazy[$option], $this->normalizers[$option], $this->allowedTypes[$option], $this->allowedValues[$option], $this->info[$option]);
806+
unset($this->lazy[$option], $this->normalizers[$option], $this->allowedTypes[$option], $this->allowedValues[$option], $this->info[$option], $this->deprecated[$option]);
807807
}
808808

809809
return $this;

Tests/OptionsResolverTest.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2566,4 +2566,33 @@ public function testPrototypeDefinition()
25662566

25672567
$this->assertSame($expectedOptions, $actualOptions);
25682568
}
2569+
2570+
public function testRemoveAlsoRemovesDeprecation()
2571+
{
2572+
$this->resolver->setDefined('foo');
2573+
$this->resolver->setDeprecated('foo', 'vendor/package', '1.0');
2574+
$this->assertTrue($this->resolver->isDeprecated('foo'));
2575+
2576+
$this->resolver->remove('foo');
2577+
$this->assertFalse($this->resolver->isDeprecated('foo'));
2578+
2579+
$this->resolver->setDefault('foo', 'bar');
2580+
$this->assertFalse($this->resolver->isDeprecated('foo'));
2581+
2582+
$count = 0;
2583+
set_error_handler(static function (int $type) use (&$count) {
2584+
if (\E_USER_DEPRECATED === $type) {
2585+
++$count;
2586+
}
2587+
2588+
return false;
2589+
});
2590+
2591+
try {
2592+
$this->resolver->resolve(['foo' => 'value']);
2593+
$this->assertSame(0, $count);
2594+
} finally {
2595+
restore_error_handler();
2596+
}
2597+
}
25692598
}

0 commit comments

Comments
 (0)