Skip to content

Commit 0b170c8

Browse files
committed
minor #19765 [Validator] feat: add warning for number constraints with PHP 7.x (alexislefebvre)
This PR was merged into the 5.4 branch. Discussion ---------- [Validator] feat: add warning for number constraints with PHP 7.x Fixes symfony/symfony#45710 See: - symfony/symfony#45710 Symfony 6.x requires PHP 8.x and it fixes this inconsistency, see symfony/symfony#45710 (comment) So this patch should be removed when merging `5.4` in `6.0` (or `6.4`). Commits ------- 7341079 feat: add warning for number constraints with PHP 7.x
2 parents 7f51be3 + 7341079 commit 0b170c8

9 files changed

+22
-0
lines changed

reference/constraints/GreaterThan.rst

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ Class :class:`Symfony\\Component\\Validator\\Constraints\\GreaterThan`
1212
Validator :class:`Symfony\\Component\\Validator\\Constraints\\GreaterThanValidator`
1313
========== ===================================================================
1414

15+
.. include:: /reference/constraints/_php7-string-and-number.rst.inc
16+
1517
Basic Usage
1618
-----------
1719

reference/constraints/GreaterThanOrEqual.rst

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ Class :class:`Symfony\\Component\\Validator\\Constraints\\GreaterThanOrEqu
1111
Validator :class:`Symfony\\Component\\Validator\\Constraints\\GreaterThanOrEqualValidator`
1212
========== ===================================================================
1313

14+
.. include:: /reference/constraints/_php7-string-and-number.rst.inc
15+
1416
Basic Usage
1517
-----------
1618

reference/constraints/LessThan.rst

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ Class :class:`Symfony\\Component\\Validator\\Constraints\\LessThan`
1212
Validator :class:`Symfony\\Component\\Validator\\Constraints\\LessThanValidator`
1313
========== ===================================================================
1414

15+
.. include:: /reference/constraints/_php7-string-and-number.rst.inc
16+
1517
Basic Usage
1618
-----------
1719

reference/constraints/LessThanOrEqual.rst

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ Class :class:`Symfony\\Component\\Validator\\Constraints\\LessThanOrEqual`
1111
Validator :class:`Symfony\\Component\\Validator\\Constraints\\LessThanOrEqualValidator`
1212
========== ===================================================================
1313

14+
.. include:: /reference/constraints/_php7-string-and-number.rst.inc
15+
1416
Basic Usage
1517
-----------
1618

reference/constraints/Negative.rst

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ Class :class:`Symfony\\Component\\Validator\\Constraints\\Negative`
1111
Validator :class:`Symfony\\Component\\Validator\\Constraints\\LessThanValidator`
1212
========== ===================================================================
1313

14+
.. include:: /reference/constraints/_php7-string-and-number.rst.inc
15+
1416
Basic Usage
1517
-----------
1618

reference/constraints/NegativeOrZero.rst

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ Class :class:`Symfony\\Component\\Validator\\Constraints\\NegativeOrZero`
1010
Validator :class:`Symfony\\Component\\Validator\\Constraints\\LessThanOrEqualValidator`
1111
========== ===================================================================
1212

13+
.. include:: /reference/constraints/_php7-string-and-number.rst.inc
14+
1315
Basic Usage
1416
-----------
1517

reference/constraints/Positive.rst

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ Class :class:`Symfony\\Component\\Validator\\Constraints\\Positive`
1111
Validator :class:`Symfony\\Component\\Validator\\Constraints\\GreaterThanValidator`
1212
========== ===================================================================
1313

14+
.. include:: /reference/constraints/_php7-string-and-number.rst.inc
15+
1416
Basic Usage
1517
-----------
1618

reference/constraints/PositiveOrZero.rst

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ Class :class:`Symfony\\Component\\Validator\\Constraints\\PositiveOrZero`
1010
Validator :class:`Symfony\\Component\\Validator\\Constraints\\GreaterThanOrEqualValidator`
1111
========== ===================================================================
1212

13+
.. include:: /reference/constraints/_php7-string-and-number.rst.inc
14+
1315
Basic Usage
1416
-----------
1517

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.. caution::
2+
3+
When using PHP 7.x, if the value is a string (e.g. ``1234asd``), the validator
4+
will not trigger an error. In this case, you must also use the
5+
:doc:`Type constraint </reference/constraints/Type>` with
6+
``numeric``, ``integer`, etc. to reject strings.

0 commit comments

Comments
 (0)