rspec/rules/S5850/php/rule.adoc

34 lines
331 B
Plaintext
Raw Normal View History

include::../description.adoc[]
== Noncompliant Code Example
2022-02-04 17:28:24 +01:00
[source,php]
----
/^a|b|c$/
----
== Compliant Solution
2022-02-04 17:28:24 +01:00
[source,php]
----
/^(?:a|b|c)$/
----
or
2022-02-04 17:28:24 +01:00
[source,php]
----
/^a$|^b$|^c$/
----
or, if you do want the anchors to only apply to ``++a++`` and ``++c++`` respectively:
2022-02-04 17:28:24 +01:00
[source,php]
----
/(?:^a)|b|(?:c$)/
----