You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think the preg_match() function should not be used instead of the native str_* functions (PHP 8+).
Example:
if (preg_match('/\.\./', $path) === 1) { // bad, better is str_contains()thrownew \InvalidArgumentException('Path "' . $path . '" could not contains \'..\'.');
}
This rule should apply to cases where the first argument to preg_match() is a string literal and also contains a string of ordinary characters that have no special meaning or have been escaped correctly (the string may be a valid input for str_*).
This improvement may help to better detect old places that are better to refactor.
Thank you.
The text was updated successfully, but these errors were encountered:
janbarasek
changed the title
Function preg_match() function should not be used instead of str_*
Function preg_match() should not be used instead of str_*
Jan 16, 2022
Hello,
I think the
preg_match()
function should not be used instead of the nativestr_*
functions (PHP 8+).Example:
This rule should apply to cases where the first argument to
preg_match()
is astring literal
and also contains a string of ordinary characters that have no special meaning or have been escaped correctly (the string may be a valid input forstr_*
).This improvement may help to better detect old places that are better to refactor.
Thank you.
The text was updated successfully, but these errors were encountered: