8000 [Config] Remove deprecated code · symfony/symfony@a29d155 · GitHub
[go: up one dir, main page]

Skip to content

Commit a29d155

Browse files
committed
[Config] Remove deprecated code
1 parent d131937 commit a29d155

File tree

7 files changed

+13
-129
lines changed

7 files changed

+13
-129
lines changed

src/Symfony/Component/Config/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
6.0
5+
---
6+
7+
* Remove `BaseNode::getDeprecationMessage()`
8+
49
5.3.0
510
-----
611

src/Symfony/Component/Config/Definition/BaseNode.php

Lines changed: 4 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -205,29 +205,8 @@ public function setRequired(bool $boolean)
205205
* You can use %node% and %path% placeholders in your message to display,
206206
* respectively, the node name and its complete path
207207
*/
208-
public function setDeprecated(?string $package/*, string $version, string $message = 'The child node "%node%" at path "%path%" is deprecated.' */)
208+
public function setDeprecated(string $package, string $version, string $message = 'The child node "%node%" at path "%path%" is deprecated.')
209209
{
210-
$args = \func_get_args();
211-
212-
if (\func_num_args() < 2) {
213-
trigger_deprecation('symfony/config', '5.1', 'The signature of method "%s()" requires 3 arguments: "string $package, string $version, string $message", not defining them is deprecated.', __METHOD__);
214-
215-
if (!isset($args[0])) {
216-
trigger_deprecation('symfony/config', '5.1', 'Passing a null message to un-deprecate a node is deprecated.');
217-
218-
$this->deprecation = [];
219-
220-
return;
221-
}
222-
223-
$message = (string) $args[0];
224-
$package = $version = '';
225-
} else {
226-
$package = (string) $args[0];
227-
$version = (string) $args[1];
228-
$message = (string) ($args[2] ?? 'The child node "%node%" at path "%path%" is deprecated.');
229-
}
230-
231210
$this->deprecation = [
232211
'package' => $package,
233212
'version' => $version,
@@ -281,33 +260,16 @@ public function isDeprecated()
281260
return (bool) $this->deprecation;
282261
}
283262

284-
/**
285-
* Returns the deprecated message.
286-
*
287-
* @param string $node the configuration node name
288-
* @param string $path the path of the node
289-
*
290-
* @return string
291-
*
292-
* @deprecated since Symfony 5.1, use "getDeprecation()" instead.
293-
*/
294-
public function getDeprecationMessage(string $node, string $path)
295-
{
296-
trigger_deprecation('symfony/config', '5.1', 'The "%s()" method is deprecated, use "getDeprecation()" instead.', __METHOD__);
297-
298-
return $this->getDeprecation($node, $path)['message'];
299-
}
300-
301263
/**
302264
* @param string $node The configuration node name
303265
* @param string $path The path of the node
304266
*/
305267
public function getDeprecation(string $node, string $path): array
306268
{
307269
return [
308-
'package' => $this->deprecation['package'] ?? '',
309-
'version' => $this->deprecation['version'] ?? '',
310-
'message' => strtr($this->deprecation['message'] ?? '', ['%node%' => $node, '%path%' => $path]),
270+
'package' => $this->deprecation['package'],
271+
'version' => $this->deprecation['version'],
272+
'message' => strtr($this->deprecation['message'], ['%node%' => $node, '%path%' => $path]),
311273
];
312274
}
313275

src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -170,21 +170,8 @@ public function isRequired()
170170
*
171171
* @return $this
172172
*/
173-
public function setDeprecated(/* string $package, string $version, string $message = 'The child node "%node%" at path "%path%" is deprecated.' */)
173+
public function setDeprecated(string $package, string $version, string $message = 'The child node "%node%" at path "%path%" is deprecated.')
174174
{
175-
$args = \func_get_args();
176-
177-
if (\func_num_args() < 2) {
178-
trigger_deprecation('symfony/config', '5.1', 'The signature of method "%s()" requires 3 arguments: "string $package, string $version, string $message", not defining them is deprecated.', __METHOD__);
179-
180-
$message = $args[0] ?? 'The child node "%node%" at path "%path%" is deprecated.';
181-
$package = $version = '';
182-
} else {
183-
$package = (string) $args[0];
184-
$version = (string) $args[1];
185-
$message = (string) ($args[2] ?? 'The child node "%node%" at path "%path%" is deprecated.');
186-
}
187-
188175
$this->deprecation = [
189176
'package' => $package,
190177
'version' => $version,

src/Symfony/Component/Config/Exception/FileLoaderImportCircularReferenceException.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,8 @@
1818
*/
1919
class FileLoaderImportCircularReferenceException extends LoaderLoadException
2020
{
21-
public function __construct(array $resources, ?int $code = 0, \Throwable $previous = null)
21+
public function __construct(array $resources, int $code = 0, \Throwable $previous = null)
2222
{
23-
if (null === $code) {
24-
trigger_deprecation('symfony/config', '5.3', 'Passing null as $code to "%s()" is deprecated, pass 0 instead.', __METHOD__);
25-
26-
$code = 0;
27-
}
28-
2923
$message = sprintf('Circular reference detected in "%s" ("%s" > "%s").', $this->varToString($resources[0]), implode('" > "', $resources), $resources[0]);
3024

3125
\Exception::__construct($message, $code, $previous);

src/Symfony/Component/Config/Exception/LoaderLoadException.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,12 @@ class LoaderLoadException extends \Exception
2121
/**
2222
* @param string $resource The resource that could not be imported
2323
* @param string|null $sourceResource The original resource importing the new resource
24-
* @param int|null $code The error code
24+
* @param int $code The error code
2525
* @param \Throwable|null $previous A previous exception
2626
* @param string|null $type The type of resource
2727
*/
28-
public function __construct(string $resource, string $sourceResource = null, ?int $code = 0, \Throwable $previous = null, string $type = null)
28+
public function __construct(string $resource, string $sourceResource = null, int $code = 0, \Throwable $previous = null, string $type = null)
2929
{
30-
if (null === $code) {
31-
trigger_deprecation('symfony/config', '5.3', 'Passing null as $code to "%s()" is deprecated, pass 0 instead.', __METHOD__);
32-
33-
$code = 0;
34-
}
35-
3630
$message = '';
3731
if ($previous) {
3832
// Include the previous exception, to help the user see what might be the underlying cause

src/Symfony/Component/Config/Tests/Definition/ArrayNodeTest.php

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,13 @@
1212
namespace Symfony\Component\Config\Tests\Definition;
1313

1414
use PHPUnit\Framework\TestCase;
15-
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
1615
use Symfony\Component\Config\Definition\ArrayNode;
1716
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
1817
use Symfony\Component\Config\Definition\Exception\InvalidTypeException;
1918
use Symfony\Component\Config\Definition\ScalarNode;
2019

2120
class ArrayNodeTest extends TestCase
2221
{
23-
use ExpectDeprecationTrait;
24-
2522
public function testNormalizeThrowsExceptionWhenFalseIsNotAllowed()
2623
{
2724
$this->expectException(InvalidTypeException::class);
@@ -263,37 +260,6 @@ public function testSetDeprecated()
263260
$this->assertTrue($deprecationTriggered, '->finalize() should trigger if the deprecated node is set');
264261
}
265262

266-
/**
267-
* @group legacy
268-
*/
269-
public function testUnDeprecateANode()
270-
{
271-
$this->expectDeprecation('Since symfony/config 5.1: The signature of method "Symfony\Component\Config\Definition\BaseNode::setDeprecated()" requires 3 arguments: "string $package, string $version, string $message", not defining them is deprecated.');
272-
$this->expectDeprecation('Since symfony/config 5.1: Passing a null message to un-deprecate a node is deprecated.');
273-
274-
$node = new ArrayNode('foo');
275-
$node->setDeprecated('"%node%" is deprecated');
276-
$node->setDeprecated(null);
277-
278-
$this->assertFalse($node->isDeprecated());
279-
}
280-
281-
/**
282-
* @group legacy
283-
*/
284-
public function testSetDeprecatedWithoutPackageAndVersion()
285-
{
286-
$this->expectDeprecation('Since symfony/config 5.1: The signature of method "Symfony\Component\Config\Definition\BaseNode::setDeprecated()" requires 3 arguments: "string $package, string $version, string $message", not defining them is deprecated.');
287-
288-
$node = new ArrayNode('foo');
289-
$node->setDeprecated('"%node%" is deprecated');
290-
291-
$deprecation = $node->getDeprecation($node->getName(), $node->getPath());
292-
$this->assertSame('"foo" is deprecated', $deprecation['message']);
293-
$this->assertSame('', $deprecation['package']);
294-
$this->assertSame('', $deprecation['version']);
295-
}
296-
297263
/**
298264
* @dataProvider getDataWithIncludedExtraKeys
299265
*/

src/Symfony/Component/Config/Tests/Definition/Builder/ArrayNodeDefinitionTest.php

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace Symfony\Component\Config\Tests\Definition\Builder;
1313

1414
use PHPUnit\Framework\TestCase;
15-
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
1615
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
1716
use Symfony\Component\Config\Definition\Builder\BooleanNodeDefinition;
1817
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
@@ -24,8 +23,6 @@
2423

2524
class ArrayNodeDefinitionTest extends TestCase
2625
{
27-
use ExpectDeprecationTrait;
28-
2926
public function testAppendingSomeNode()
3027
{
3128
$parent = new ArrayNodeDefinition('root');
@@ -349,27 +346,6 @@ public function testSetDeprecated()
349346
$this->assertSame('1.1', $deprecation['version']);
350347
}
351348

352-
/**
353-
* @group legacy
354-
*/
355-
public function testSetDeprecatedWithoutPackageAndVersion()
356-
{
357-
$this->expectDeprecation('Since symfony/config 5.1: The signature of method "Symfony\Component\Config\Definition\Builder\NodeDefinition::setDeprecated()" requires 3 arguments: "string $package, string $version, string $message", not defining them is deprecated.');
358-
$node = new ArrayNodeDefinition('root');
359-
$node
360-
->children()
361-
->arrayNode('foo')->setDeprecated('The "%path%" node is deprecated.')->end()
362-
->end()
363-
;
364-
$deprecatedNode = $node->getNode()->getChildren()['foo'];
365-
366-
$this->assertTrue($deprecatedNode->isDeprecated());
367-
$deprecation = $deprecatedNode->getDeprecation($deprecatedNode->getName(), $deprecatedNode->getPath());
368-
$this->assertSame('The "root.foo" node is deprecated.', $deprecation['message']);
369-
$this->assertSame('', $deprecation['package']);
370-
$this->assertSame('', $deprecation['version']);
371-
}
372-
373349
public function testCannotBeEmptyOnConcreteNode()
374350
{
375351
$this->expectException(InvalidDefinitionException::class);

0 commit comments

Comments
 (0)
0