From 7341079f8999a05ce94616a5017675a51d3f901b Mon Sep 17 00:00:00 2001 From: Alexis Lefebvre Date: Mon, 8 Apr 2024 15:12:58 +0200 Subject: [PATCH] feat: add warning for number constraints with PHP 7.x --- reference/constraints/GreaterThan.rst | 2 ++ reference/constraints/GreaterThanOrEqual.rst | 2 ++ reference/constraints/LessThan.rst | 2 ++ reference/constraints/LessThanOrEqual.rst | 2 ++ reference/constraints/Negative.rst | 2 ++ reference/constraints/NegativeOrZero.rst | 2 ++ reference/constraints/Positive.rst | 2 ++ reference/constraints/PositiveOrZero.rst | 2 ++ reference/constraints/_php7-string-and-number.rst.inc | 6 ++++++ 9 files changed, 22 insertions(+) create mode 100644 reference/constraints/_php7-string-and-number.rst.inc diff --git a/reference/constraints/GreaterThan.rst b/reference/constraints/GreaterThan.rst index 22331edd957..02659140122 100644 --- a/reference/constraints/GreaterThan.rst +++ b/reference/constraints/GreaterThan.rst @@ -12,6 +12,8 @@ Class :class:`Symfony\\Component\\Validator\\Constraints\\GreaterThan` Validator :class:`Symfony\\Component\\Validator\\Constraints\\GreaterThanValidator` ========== =================================================================== +.. include:: /reference/constraints/_php7-string-and-number.rst.inc + Basic Usage ----------- diff --git a/reference/constraints/GreaterThanOrEqual.rst b/reference/constraints/GreaterThanOrEqual.rst index 79578c5a5f7..38621c1cb1c 100644 --- a/reference/constraints/GreaterThanOrEqual.rst +++ b/reference/constraints/GreaterThanOrEqual.rst @@ -11,6 +11,8 @@ Class :class:`Symfony\\Component\\Validator\\Constraints\\GreaterThanOrEqu Validator :class:`Symfony\\Component\\Validator\\Constraints\\GreaterThanOrEqualValidator` ========== =================================================================== +.. include:: /reference/constraints/_php7-string-and-number.rst.inc + Basic Usage ----------- diff --git a/reference/constraints/LessThan.rst b/reference/constraints/LessThan.rst index 22ebce5c094..d35050826f3 100644 --- a/reference/constraints/LessThan.rst +++ b/reference/constraints/LessThan.rst @@ -12,6 +12,8 @@ Class :class:`Symfony\\Component\\Validator\\Constraints\\LessThan` Validator :class:`Symfony\\Component\\Validator\\Constraints\\LessThanValidator` ========== =================================================================== +.. include:: /reference/constraints/_php7-string-and-number.rst.inc + Basic Usage ----------- diff --git a/reference/constraints/LessThanOrEqual.rst b/reference/constraints/LessThanOrEqual.rst index 05e2dedbfe5..dd32de0fe0f 100644 --- a/reference/constraints/LessThanOrEqual.rst +++ b/reference/constraints/LessThanOrEqual.rst @@ -11,6 +11,8 @@ Class :class:`Symfony\\Component\\Validator\\Constraints\\LessThanOrEqual` Validator :class:`Symfony\\Component\\Validator\\Constraints\\LessThanOrEqualValidator` ========== =================================================================== +.. include:: /reference/constraints/_php7-string-and-number.rst.inc + Basic Usage ----------- diff --git a/reference/constraints/Negative.rst b/reference/constraints/Negative.rst index fa00910e790..078a4cf9b90 100644 --- a/reference/constraints/Negative.rst +++ b/reference/constraints/Negative.rst @@ -11,6 +11,8 @@ Class :class:`Symfony\\Component\\Validator\\Constraints\\Negative` Validator :class:`Symfony\\Component\\Validator\\Constraints\\LessThanValidator` ========== =================================================================== +.. include:: /reference/constraints/_php7-string-and-number.rst.inc + Basic Usage ----------- diff --git a/reference/constraints/NegativeOrZero.rst b/reference/constraints/NegativeOrZero.rst index e356a21d20f..593bd824c05 100644 --- a/reference/constraints/NegativeOrZero.rst +++ b/reference/constraints/NegativeOrZero.rst @@ -10,6 +10,8 @@ Class :class:`Symfony\\Component\\Validator\\Constraints\\NegativeOrZero` Validator :class:`Symfony\\Component\\Validator\\Constraints\\LessThanOrEqualValidator` ========== =================================================================== +.. include:: /reference/constraints/_php7-string-and-number.rst.inc + Basic Usage ----------- diff --git a/reference/constraints/Positive.rst b/reference/constraints/Positive.rst index 326e66e7c9b..ca0d030cb64 100644 --- a/reference/constraints/Positive.rst +++ b/reference/constraints/Positive.rst @@ -11,6 +11,8 @@ Class :class:`Symfony\\Component\\Validator\\Constraints\\Positive` Validator :class:`Symfony\\Component\\Validator\\Constraints\\GreaterThanValidator` ========== =================================================================== +.. include:: /reference/constraints/_php7-string-and-number.rst.inc + Basic Usage ----------- diff --git a/reference/constraints/PositiveOrZero.rst b/reference/constraints/PositiveOrZero.rst index 2d39d0d6d19..808eafd071a 100644 --- a/reference/constraints/PositiveOrZero.rst +++ b/reference/constraints/PositiveOrZero.rst @@ -10,6 +10,8 @@ Class :class:`Symfony\\Component\\Validator\\Constraints\\PositiveOrZero` Validator :class:`Symfony\\Component\\Validator\\Constraints\\GreaterThanOrEqualValidator` ========== =================================================================== +.. include:: /reference/constraints/_php7-string-and-number.rst.inc + Basic Usage ----------- diff --git a/reference/constraints/_php7-string-and-number.rst.inc b/reference/constraints/_php7-string-and-number.rst.inc new file mode 100644 index 00000000000..6da43da6378 --- /dev/null +++ b/reference/constraints/_php7-string-and-number.rst.inc @@ -0,0 +1,6 @@ +.. caution:: + + When using PHP 7.x, if the value is a string (e.g. ``1234asd``), the validator + will not trigger an error. In this case, you must also use the + :doc:`Type constraint ` with + ``numeric``, ``integer`, etc. to reject strings.