rspec/rules/S5856/php/rule.adoc

23 lines
506 B
Plaintext
Raw Normal View History

include::../description.adoc[]
To match a literal string, rather than a regular expression, either all special characters should be escaped or methods that dont use regular expressions should be used.
== Noncompliant Code Example
----
preg_match("/([/", $input);
preg_replace("/[/", "{", $input);
preg_replace("/(\\w+-(\\d+)/", "1234", $input);
----
== Compliant Solution
----
preg_match("/\\(\\[/", $input);
str_replace("([", "{", $input);
preg_replace("/(\\w+)-(\\d+)/", "1234", $input);
----