From b37daa4553ae2531ca88740333e53c8a66c0d339 Mon Sep 17 00:00:00 2001 From: Josh Date: Mon, 27 Apr 2026 21:23:18 -0400 Subject: [PATCH 1/2] docs: clarify in_array() strict comparison for modern PHP Update the note for the strict parameter to accurately reflect PHP 8.0.0 changes and highlight ongoing loose comparison risks with booleans. --- reference/array/functions/in-array.xml | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/reference/array/functions/in-array.xml b/reference/array/functions/in-array.xml index 8b2da4cc4c40..a59e1b1c2b5f 100644 --- a/reference/array/functions/in-array.xml +++ b/reference/array/functions/in-array.xml @@ -55,12 +55,16 @@ - Prior to PHP 8.0.0, a string needle will match an array - value of 0 in non-strict mode, and vice versa. That may lead to undesireable - results. Similar edge cases exist for other types, as well. If not absolutely certain of the - types of values involved, always use the strict flag to avoid unexpected behavior. - - + Prior to PHP 8.0.0, a string needle would loosely match + a numeric haystack value of 0, and vice versa. + As of PHP 8.0.0, this behavior is restricted to numeric strings. However, non-strict mode + still employs loose comparison (==), which allows for matches across + unrelated types. For example, a boolean &true; value in the + haystack will match any non-empty string + needle. It is recommended to use the strict + flag to ensure type-safe results + + From a70c895482e8696b0e5a2eb7f1865b7a6679b959 Mon Sep 17 00:00:00 2001 From: Josh Date: Mon, 27 Apr 2026 21:28:22 -0400 Subject: [PATCH 2/2] chore: linting/tidying new in-array note --- reference/array/functions/in-array.xml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/reference/array/functions/in-array.xml b/reference/array/functions/in-array.xml index a59e1b1c2b5f..d1dccc2794ad 100644 --- a/reference/array/functions/in-array.xml +++ b/reference/array/functions/in-array.xml @@ -55,14 +55,14 @@ - Prior to PHP 8.0.0, a string needle would loosely match - a numeric haystack value of 0, and vice versa. - As of PHP 8.0.0, this behavior is restricted to numeric strings. However, non-strict mode - still employs loose comparison (==), which allows for matches across - unrelated types. For example, a boolean &true; value in the - haystack will match any non-empty string - needle. It is recommended to use the strict - flag to ensure type-safe results + Prior to PHP 8.0.0, a string needle would loosely match + a numeric haystack value of 0, and vice versa. + As of PHP 8.0.0, this behavior is restricted to numeric strings. However, non-strict mode + still employs loose comparison (==), which allows for matches across + unrelated types. For example, a boolean &true; value in the + haystack will match any non-empty string + needle. It is recommended to use the strict + flag to ensure type-safe results.