-
Notifications
You must be signed in to change notification settings - Fork 865
Clarify in_array() strict comparison behavior for PHP 8.0+ #5519
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -55,12 +55,16 @@ | |||||||||
| </para> | ||||||||||
| <note> | ||||||||||
| <para> | ||||||||||
| Prior to PHP 8.0.0, a <literal>string</literal> <parameter>needle</parameter> will match an array | ||||||||||
| value of <literal>0</literal> 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 <parameter>strict</parameter> flag to avoid unexpected behavior. | ||||||||||
| </para> | ||||||||||
| </note> | ||||||||||
| Prior to PHP 8.0.0, a <literal>string</literal> <parameter>needle</parameter> would loosely match | ||||||||||
| a numeric <parameter>haystack</parameter> value of <literal>0</literal>, and vice versa. | ||||||||||
| As of PHP 8.0.0, this behavior is restricted to numeric strings. However, non-strict mode | ||||||||||
| still employs loose comparison (<literal>==</literal>), which allows for matches across | ||||||||||
| unrelated types. For example, a boolean <constant>&true;</constant> value in the | ||||||||||
| <parameter>haystack</parameter> will match any non-empty <literal>string</literal> | ||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tiny accuracy nit:
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
| <parameter>needle</parameter>. It is recommended to use the <parameter>strict</parameter> | ||||||||||
| flag to ensure type-safe results. | ||||||||||
| </para> | ||||||||||
| </note> | ||||||||||
|
Comment on lines
+66
to
+67
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should become |
||||||||||
| </listitem> | ||||||||||
| </varlistentry> | ||||||||||
| </variablelist> | ||||||||||
|
|
||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI; This is the cause of why CI tests fail. Because
&true;is an entity that already contains a<constant>