Skip to content
Closed
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
2 changes: 2 additions & 0 deletions src/Symfony/Component/OptionsResolver/OptionsResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,8 @@ public function setDeprecated(string $option, string $package, string $version,

// ignore if empty string
if ('' === $message) {
unset($this->deprecated[$option]);

return $this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2566,4 +2566,42 @@ public function testPrototypeDefinition()

$this->assertSame($expectedOptions, $actualOptions);
}

public function testDeprecationCanBeOverriddenWithEmptyString()
{
// 1. Base configuration (e.g., parent class) deprecates "hostname"
$this->resolver
->setDefined(['hostname', 'host'])
->setDeprecated(
'hostname',
'acme/package',
'1.2',
'The option "%name%" is deprecated, use "host" instead.'
);

// 2. Child configuration cancel this deprecation
$this->resolver
->setDeprecated('hostname', 'acme/package', '1.3', '');

$this->assertFalse($this->resolver->isDeprecated('hostname'));

$count = 0;
set_error_handler(function (int $type) use (&$count) {
if (\E_USER_DEPRECATED === $type) {
++$count;
}

return false;
});
$e = error_reporting(0);

try {
$this->resolver->resolve(['hostname' => 'localhost']);
} finally {
error_reporting($e);
restore_error_handler();
}

$this->assertSame(0, $count, 'No \E_USER_DEPRECATED error should have been triggered.');
}
}
Loading