1.2.474. Foreach On Object

Foreach on object looks like a typo. This is particularly true when both object and member are variables.

Foreach on an object member is a legit PHP syntax, though it is very rare : blind variables rarely have to be securing in an object to be processed.

<?php

// This is the real thing
foreach($array as $o => $b) {
    doSomething();
}

// Looks suspicious
foreach($array as $o -> $b) {
    doSomething();
}

?>

1.2.474.1. Connex PHP features

1.2.474.1.1. Specs

Short name

Php/ForeachObject

Rulesets

All, Analyze, Changed Behavior

Exakat since

1.1.6

PHP Version

All

Severity

Major

Time To Fix

Instant (5 mins)

Precision

High

Available in

Entreprise Edition, Exakat Cloud