8000 Postpone BC layer removal to 6.0. · symfony/symfony@1f66618 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1f66618

Browse files
committed
Postpone BC layer removal to 6.0.
Since users on 5.0 and 5.1 hasn't have the deprecation, removing the BC layer (and so throwing an exception) in 5.x would be a big BC break.
1 parent 2b0fdc9 commit 1f66618

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

src/Symfony/Component/Validator/Constraints/Range.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ class Range extends Constraint
4646
public $max;
4747
public $maxPropertyPath;
4848

49-
// BC layer, to be removed in 5.0
5049
/**
5150
* @internal
5251
*/
@@ -76,8 +75,9 @@ public function __construct($options = null)
7675
$this->deprecatedMinMessageSet = isset($options['minMessage']);
7776
$this->deprecatedMaxMessageSet = isset($options['maxMessage']);
7877

78+
// BC layer, should throw a ConstraintDefinitionException in 6.0
7979
if ($this->deprecatedMinMessageSet || $this->deprecatedMaxMessageSet) {
80-
@trigger_error('Since symfony/validator 4.4: "minMessage" and "maxMessage" are deprecated when the "min" and "max" options are both set. Use "notInRangeMessage" instead.', E_USER_DEPRECATED);
80+
trigger_deprecation('symfony/validator', '4.4', '"minMessage" and "maxMessage" are deprecated when the "min" and "max" options are both set. Use "notInRangeMessage" instead.');
8181
}
8282
}
8383
}

src/Symfony/Component/Validator/Tests/Constraints/RangeTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@
33
namespace Symfony\Component\Validator\Tests\Constraints;
44

55
use PHPUnit\Framework\TestCase;
6+
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
67
use Symfony\Component\Validator\Constraints\Range;
78

89
class RangeTest extends TestCase
910
{
11+
use ExpectDeprecationTrait;
12+
1013
public function testThrowsConstraintExceptionIfBothMinLimitAndPropertyPath()
1114
{
1215
$this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
@@ -52,11 +55,12 @@ public function provideDeprecationTriggeredIfMinMaxAndMinMessageOrMaxMessageSet(
5255

5356
/**
5457
* @group legacy
55-
* @expectedDeprecation Since symfony/validator 4.4: "minMessage" and "maxMessage" are deprecated when the "min" and "max" options are both set. Use "notInRangeMessage" instead.
5658
* @dataProvider provideDeprecationTriggeredIfMinMaxAndMinMessageOrMaxMessageSet
5759
*/
5860
public function testDeprecationTriggeredIfMinMaxAndMinMessageOrMaxMessageSet(array $options, bool $expectedDeprecatedMinMessageSet, bool $expectedDeprecatedMaxMessageSet)
5961
{
62+
$this->expectDeprecation('Since symfony/validator 4.4: "minMessage" and "maxMessage" are deprecated when the "min" and "max" options are both set. Use "notInRangeMessage" instead.');
63+
6064
$sut = new Range($options);
6165
$this->assertEquals($expectedDeprecatedMinMessageSet, $sut->deprecatedMinMessageSet);
6266
$this->assertEquals($expectedDeprecatedMaxMessageSet, $sut->deprecatedMaxMessageSet);

src/Symfony/Component/Validator/composer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
"symfony/polyfill-ctype": "~1.8",
2121
"symfony/polyfill-mbstring": "~1.0",
2222
"symfony/polyfill-php80": "^1.15",
23-
"symfony/translation-contracts": "^1.1|^2"
23+
"symfony/translation-contracts": "^1.1|^2",
24+
"symfony/deprecation-contracts": "^2.0"
2425
},
2526
"require-dev": {
2627
"symfony/http-client": "^4.4|^5.0",
@@ -47,6 +48,7 @@
4748
"symfony/expression-language": "<5.1",
4849
"symfony/http-kernel": "<4.4",
4950
"symfony/intl": "<4.4",
51+
"symfony/phpunit-bridge": "^5.1",
5052
"symfony/translation": "<4.4",
5153
"symfony/yaml": "<4.4"
5254
},

0 commit comments

Comments
 (0)
0