rspec/rules/S2194/php/rule.adoc
Fred Tingaud 16f6c0aecf
Inline adoc when include has no additional value (#1940)
Inline adoc files when they are included exactly once.

Also fix language tags because this inlining gives us better information
on what language the code is written in.
2023-05-25 14:18:12 +02:00

47 lines
870 B
Plaintext

== Why is this an issue?
``++include_once++`` and ``++include++`` only generate a warning if an error occurs during the operation. Because of this they should only be used after possible error conditions have been checked.
=== Noncompliant code example
[source,php]
----
include_once $user.'_history.php'; // Noncompliant
----
=== Compliant solution
[source,php]
----
if (is_member($user)) {
include_once $user.'_history.php';
}
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
Check possible error conditions before calling "include_once".
'''
== Comments And Links
(visible only on this page)
=== on 24 Oct 2014, 13:35:39 Ann Campbell wrote:
assigned to you for approval [~linda.martin]
=== on 19 May 2015, 15:50:33 Linda Martin wrote:
Reviewed.
endif::env-github,rspecator-view[]