Skip to content

Commit 3a11427

Browse files
dunglassoyuka
andauthored
chore: add missing deprecation notices to ParameterValidator (#6655)
Co-authored-by: soyuka <[email protected]>
1 parent 2b3c55d commit 3a11427

26 files changed

+79
-70
lines changed

src/ParameterValidator/Exception/ValidationException.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
/**
1919
* Filter validation exception.
2020
*
21+
* @deprecated use \ApiPlatform\Metadata\Parameter::$constraints instead
22+
*
2123
* @author Julien DENIAU <[email protected]>
2224
*/
2325
final class ValidationException extends \Exception implements ValidationExceptionInterface, ProblemExceptionInterface
@@ -28,6 +30,8 @@ final class ValidationException extends \Exception implements ValidationExceptio
2830
public function __construct(private readonly array $constraintViolationList, string $message = '', int $code = 0, ?\Exception $previous = null)
2931
{
3032
parent::__construct($message ?: $this->__toString(), $code, $previous);
33+
34+
trigger_deprecation('api-platform/core', '3.4', 'The class "%s" is deprecated, use "\ApiPlatform\Metadata\Parameter::$constraints" instead.', __CLASS__);
3135
}
3236

3337
public function getConstraintViolationList(): array

src/ParameterValidator/Exception/ValidationExceptionInterface.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
/**
1919
* This Exception is thrown when any parameter validation fails.
20+
*
21+
* @deprecated use \ApiPlatform\Metadata\Parameter::$constraints instead
2022
*/
2123
interface ValidationExceptionInterface extends ExceptionInterface, \Stringable
2224
{

src/ParameterValidator/FilterLocatorTrait.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,9 @@
2020
/**
2121
* Manipulates filters with a backward compatibility between the new filter locator and the deprecated filter collection.
2222
*
23-
* @author Baptiste Meyer <[email protected]>
24-
*
25-
* @deprecated
26-
*
2723
* @internal
24+
*
25+
* @author Baptiste Meyer <[email protected]>
2826
*/
2927
trait FilterLocatorTrait
3028
{

src/ParameterValidator/ParameterValidator.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
/**
2727
* Validates parameters depending on filter description.
2828
*
29+
* @deprecated use \ApiPlatform\Metadata\Parameter::$constraints instead
30+
*
2931
* @author Julien Deniau <[email protected]>
3032
*/
3133
class ParameterValidator
@@ -36,6 +38,8 @@ class ParameterValidator
3638

3739
public function __construct(ContainerInterface $filterLocator)
3840
{
41+
trigger_deprecation('api-platform/core', '3.4', 'The class "%s" is deprecated, use "\ApiPlatform\Metadata\Parameter::$constraints" instead.', __CLASS__);
42+
3943
$this->setFilterLocator($filterLocator);
4044

4145
$this->validators = [

src/ParameterValidator/Tests/ParameterValidatorTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
use Psr\Container\ContainerInterface;
2424

2525
/**
26+
* @group legacy
27+
*
2628
* @author Julien Deniau <[email protected]>
2729
*/
2830
class ParameterValidatorTest extends TestCase

src/ParameterValidator/Tests/Validator/ArrayItemsTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
use PHPUnit\Framework\TestCase;
1818

1919
/**
20+
* @group legacy
21+
*
2022
* @author Julien Deniau <[email protected]>
2123
*/
2224
class ArrayItemsTest extends TestCase
@@ -41,9 +43,6 @@ public function testEmptyQueryParameter(): void
4143
);
4244
}
4345

44-
/**
45-
* @group legacy
46-
*/
4746
public function testNonMatchingParameter(): void
4847
{
4948
$filter = new ArrayItems();

src/ParameterValidator/Tests/Validator/BoundsTest.php

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
use PHPUnit\Framework\TestCase;
1818

1919
/**
20+
* @group legacy
21+
*
2022
* @author Julien Deniau <[email protected]>
2123
*/
2224
class BoundsTest extends TestCase
@@ -39,9 +41,6 @@ public function testEmptyQueryParameter(): void
3941
);
4042
}
4143

42-
/**
43-
* @group legacy
44-
*/
4544
public function testNonMatchingMinimum(): void
4645
{
4746
$request = ['some_filter' => '9'];
@@ -124,9 +123,6 @@ public function testNonMatchingMinimumOpenApi(): void
124123
);
125124
}
126125

127-
/**
128-
* @group legacy
129-
*/
130126
public function testMatchingMinimum(): void
131127
{
132128
$request = ['some_filter' => '10'];
@@ -181,9 +177,6 @@ public function testMatchingMinimumOpenApi(): void
181177
);
182178
}
183179

184-
/**
185-
* @group legacy
186-
*/
187180
public function testNonMatchingMaximum(): void
188181
{
189182
$request = ['some_filter' => '11'];
@@ -266,9 +259,6 @@ public function testNonMatchingMaximumOpenApi(): void
266259
);
267260
}
268261

269-
/**
270-
* @group legacy
271-
*/
272262
public function testMatchingMaximum(): void
273263
{
274264
$request = ['some_filter' => '10'];

src/ParameterValidator/Tests/Validator/EnumTest.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
use PHPUnit\Framework\TestCase;
1818

1919
/**
20+
* @group legacy
21+
*
2022
* @author Julien Deniau <[email protected]>
2123
*/
2224
class EnumTest extends TestCase
@@ -39,9 +41,6 @@ public function testEmptyQueryParameter(): void
3941
);
4042
}
4143

42-
/**
43-
* @group legacy
44-
*/
4544
public function testNonMatchingParameter(): void
4645
{
4746
$filter = new Enum();
@@ -74,9 +73,6 @@ public function testNonMatchingParameterOpenApi(): void
7473
);
7574
}
7675

77-
/**
78-
* @group legacy
79-
*/
8076
public function testMatchingParameter(): void
8177
{
8278
$filter = new Enum();

src/ParameterValidator/Tests/Validator/LengthTest.php

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
use PHPUnit\Framework\TestCase;
1818

1919
/**
20+
* @group legacy
21+
*
2022
* @author Julien Deniau <[email protected]>
2123
*/
2224
class LengthTest extends TestCase
@@ -39,9 +41,6 @@ public function testEmptyQueryParameter(): void
3941
);
4042
}
4143

42-
/**
43-
* @group legacy
44-
*/
4544
public function testNonMatchingParameter(): void
4645
{
4746
$filter = new Length();
@@ -86,9 +85,6 @@ public function testNonMatchingParameterOpenApi(): void
8685
);
8786
}
8887

89-
/**
90-
* @group legacy
91-
*/
9288
public function testNonMatchingParameterWithOnlyOneDefinition(): void
9389
{
9490
$filter = new Length();
@@ -143,9 +139,6 @@ public function testNonMatchingParameterWithOnlyOneDefinitionOpenApi(): void
143139
);
144140
}
145141

146-
/**
147-
* @group legacy
148-
*/
149142
public function testMatchingParameter(): void
150143
{
151144
$filter = new Length();
@@ -194,9 +187,6 @@ public function testMatchingParameterOpenApi(): void
194187
);
195188
}
196189

197-
/**
198-
* @group legacy
199-
*/
200190
public function testMatchingParameterWithOneDefinition(): void
201191
{
202192
$filter = new Length();

src/ParameterValidator/Tests/Validator/MultipleOfTest.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
use PHPUnit\Framework\TestCase;
1818

1919
/**
20+
* @group legacy
21+
*
2022
* @author Julien Deniau <[email protected]>
2123
*/
2224
class MultipleOfTest extends TestCase
@@ -40,9 +42,6 @@ public function testEmptyQueryParameter(): void
4042
);
4143
}
4244

43-
/**
44-
* @group legacy
45-
*/
4645
public function testNonMatchingParameter(): void
4746
{
4847
$request = ['some_filter' => '8'];
@@ -77,9 +76,6 @@ public function testNonMatchingParameterOpenApi(): void
7776
);
7877
}
7978

80-
/**
81-
* @group legacy
82-
*/
8379
public function testMatchingParameter(): void
8480
{
8581
$request = ['some_filter' => '8'];

0 commit comments

Comments
 (0)