Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 281ea5d

Browse filesBrowse files
committed
[Finder] Remove deprecated code
Signed-off-by: Alexander M. Turek <me@derrabus.de>
1 parent ee80fc4 commit 281ea5d
Copy full SHA for 281ea5d

File tree

4 files changed

+12
-77
lines changed
Filter options

4 files changed

+12
-77
lines changed

‎src/Symfony/Component/Finder/CHANGELOG.md

Copy file name to clipboardExpand all lines: src/Symfony/Component/Finder/CHANGELOG.md
+5Lines 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 `Comparator::setTarget()` and `Comparator::setOperator()`
8+
49
5.4.0
510
-----
611

‎src/Symfony/Component/Finder/Comparator/Comparator.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Finder/Comparator/Comparator.php
+6-47Lines changed: 6 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@
1616
*/
1717
class Comparator
1818
{
19-
private ?string $target;
20-
private string $operator = '==';
19+
private string $target;
20+
private string $operator;
2121

22-
public function __construct(string $target = null, string $operator = '==')
22+
public function __construct(string $target, string $operator = '==')
2323
{
24-
if (null === $target) {
25-
trigger_deprecation('symfony/finder', '5.4', 'Constructing a "%s" without setting "$target" is deprecated.', __CLASS__);
24+
if (!\in_array($operator, ['>', '<', '>=', '<=', '==', '!='])) {
25+
throw new \InvalidArgumentException(sprintf('Invalid operator "%s".', $operator));
2626
}
2727

2828
$this->target = $target;
29-
$this->doSetOperator($operator);
29+
$this->operator = $operator;
3030
}
3131

3232
/**
@@ -36,23 +36,9 @@ public function __construct(string $target = null, string $operator = '==')
3636
*/
3737
public function getTarget()
3838
{
39-
if (null === $this->target) {
40-
trigger_deprecation('symfony/finder', '5.4', 'Calling "%s" without initializing the target is deprecated.', __METHOD__);
41-
}
42-
4339
return $this->target;
4440
}
4541

46-
/**
47-
* @deprecated set the target via the constructor instead
48-
*/
49-
public function setTarget(string $target)
50-
{
51-
trigger_deprecation('symfony/finder', '5.4', '"%s" is deprecated. Set the target via the constructor instead.', __METHOD__);
52-
53-
$this->target = $target;
54-
}
55-
5642
/**
5743
* Gets the comparison operator.
5844
*
@@ -63,31 +49,13 @@ public function getOperator()
6349
return $this->operator;
6450
}
6551

66-
/**
67-
* Sets the comparison operator.
68-
*
69-
* @throws \InvalidArgumentException
70-
*
71-
* @deprecated set the operator via the constructor instead
72-
*/
73-
public function setOperator(string $operator)
74-
{
75-
trigger_deprecation('symfony/finder', '5.4', '"%s" is deprecated. Set the operator via the constructor instead.', __METHOD__);
76-
77-
$this->doSetOperator('' === $operator ? '==' : $operator);
78-
}
79-
8052
/**
8153
* Tests against the target.
8254
*
8355
* @return bool
8456
*/
8557
public function test(mixed $test)
8658
{
87-
if (null === $this->target) {
88-
trigger_deprecation('symfony/finder', '5.4', 'Calling "%s" without initializing the target is deprecated.', __METHOD__);
89-
}
90-
9159
switch ($this->operator) {
9260
case '>':
9361
return $test > $this->target;
@@ -103,13 +71,4 @@ public function test(mixed $test)
10371

10472
return $test == $this->target;
10573
}
106-
107-
private function doSetOperator(string $operator): void
108-
{
109-
if (!\in_array($operator, ['>', '<', '>=', '<=', '==', '!='])) {
110-
throw new \InvalidArgumentException(sprintf('Invalid operator "%s".', $operator));
111-
}
112-
113-
$this->operator = $operator;
114-
}
11574
}

‎src/Symfony/Component/Finder/Tests/Comparator/ComparatorTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Finder/Tests/Comparator/ComparatorTest.php
-28Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,10 @@
1212
namespace Symfony\Component\Finder\Tests\Comparator;
1313

1414
use PHPUnit\Framework\TestCase;
15-
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
1615
use Symfony\Component\Finder\Comparator\Comparator;
1716

1817
class ComparatorTest extends TestCase
1918
{
20-
use ExpectDeprecationTrait;
21-
22-
/**
23-
* @group legacy
24-
*/
25-
public function testGetSetOperator()
26-
{
27-
$comparator = new Comparator('some target');
28-
29-
$this->expectDeprecation('Since symfony/finder 5.4: "Symfony\Component\Finder\Comparator\Comparator::setOperator" is deprecated. Set the operator via the constructor instead.');
30-
$comparator->setOperator('>');
31-
$this->assertEquals('>', $comparator->getOperator(), '->getOperator() returns the current operator');
32-
}
33-
3419
public function testInvalidOperator()
3520
{
3621
$this->expectException(\InvalidArgumentException::class);
@@ -39,19 +24,6 @@ public function testInvalidOperator()
3924
new Comparator('some target', 'foo');
4025
}
4126

42-
/**
43-
* @group legacy
44-
*/
45-
public function testGetSetTarget()
46-
{
47-
$this->expectDeprecation('Since symfony/finder 5.4: Constructing a "Symfony\Component\Finder\Comparator\Comparator" without setting "$target" is deprecated.');
48-
$comparator = new Comparator();
49-
50-
$this->expectDeprecation('Since symfony/finder 5.4: "Symfony\Component\Finder\Comparator\Comparator::setTarget" is deprecated. Set the target via the constructor instead.');
51-
$comparator->setTarget(8);
52-
$this->assertEquals(8, $comparator->getTarget(), '->getTarget() returns the target');
53-
}
54-
5527
/**
5628
* @dataProvider provideMatches
5729
*/

‎src/Symfony/Component/Finder/composer.json

Copy file name to clipboardExpand all lines: src/Symfony/Component/Finder/composer.json
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616
}
1717
],
1818
"require": {
19-
"php": ">=8.0.2",
20-
"symfony/deprecation-contracts": "^2.1|^3"
19+
"php": ">=8.0.2"
2120
},
2221
"autoload": {
2322
"psr-4": { "Symfony\\Component\\Finder\\": "" },

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.