include::../description.adoc[]

== Noncompliant Code Example

----
if ($condition)
  firstActionInBlock();
  secondAction();  // Noncompliant; executed unconditionally
thirdAction();

if($condition) firstActionInBlock(); secondAction();  // Noncompliant; secondAction executed unconditionally

if($condition) firstActionInBlock();  // Noncompliant
  secondAction();  // Executed unconditionally

$str = null;
for ($i = 0; $i < count($array); $i++)
  $str = $array[$i];
  doTheThing($str);  // Noncompliant; executed only on last array element
----

== Compliant Solution

----
if ($condition) {
  firstActionInBlock();
  secondAction();
}
thirdAction();

if($condition) { firstActionInBlock(); secondAction(); }

if($condition) {
  firstActionInBlock();
  secondAction();
}

$str = null;
for ($i = 0; $i < count($array); $i++) {
  $str = $array[$i];
  doTheThing($str);
}
----

include::../see.adoc[]

ifdef::env-github,rspecator-view[]
'''
== Comments And Links
(visible only on this page)

include::../comments-and-links.adoc[]
endif::env-github,rspecator-view[]
