Skip to content

Commit 63d39b0

Browse files
committed
fixup frozen bag deprecations
1 parent 656dac8 commit 63d39b0

File tree

3 files changed

+29
-7
lines changed

3 files changed

+29
-7
lines changed

src/Symfony/Component/DependencyInjection/ParameterBag/FrozenParameterBag.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class FrozenParameterBag extends ParameterBag
2828
*/
2929
public function __construct(
3030
array $parameters = [],
31-
private array $deprecatedParameters = [],
31+
protected array $deprecatedParameters = [],
3232
) {
3333
$this->parameters = $parameters;
3434
$this->resolved = true;
@@ -58,9 +58,4 @@ public function remove(string $name)
5858
{
5959
throw new LogicException('Impossible to call remove() on a frozen ParameterBag.');
6060
}
61-
62-
public function allDeprecated(): array
63-
{
64-
return $this->deprecatedParameters;
65-
}
6661
}

src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class ParameterBag implements ParameterBagInterface
2424
{
2525
protected $parameters = [];
2626
protected $resolved = false;
27-
private array $deprecatedParameters = [];
27+
protected array $deprecatedParameters = [];
2828

2929
public function __construct(array $parameters = [])
3030
{

src/Symfony/Component/DependencyInjection/Tests/ParameterBag/FrozenParameterBagTest.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,13 @@
1212
namespace Symfony\Component\DependencyInjection\Tests\ParameterBag;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
1516
use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag;
1617

1718
class FrozenParameterBagTest extends TestCase
1819
{
20+
use ExpectDeprecationTrait;
21+
1922
public function testConstructor()
2023
{
2124
$parameters = [
@@ -53,4 +56,28 @@ public function testRemove()
5356
$bag = new FrozenParameterBag(['foo' => 'bar']);
5457
$bag->remove('foo');
5558
}
59+
60+
public function testDeprecate()
61+
{
62+
$this->expectException(\LogicException::class);
63+
$bag = new FrozenParameterBag(['foo' => 'bar']);
64+
$bag->deprecate('foo', 'symfony/test', '6.3');
65+
}
66+
67+
/**
68+
* The test should be kept in the group as it always expects a deprecation.
69+
*
70+
* @group legacy
71+
*/
72+
public function testGetDeprecated()
73+
{
74+
$bag = new FrozenParameterBag(
75+
['foo' => 'bar'],
76+
['foo' => ['symfony/test', '6.3', 'The parameter "%s" is deprecated.', 'foo']]
77+
);
78+
79+
$this->expectDeprecation('Since symfony/test 6.3: The parameter "foo" is deprecated.');
80+
81+
$bag->get('foo');
82+
}
5683
}

0 commit comments

Comments
 (0)
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