1.2.1228. Typehint Could Be Iterable

Mark arguments, class constants, properties and return types that can be set to iterable.

<?php

// Accept an array or a traversable Object as input
function foo($b) {
    foreach($b as $c) {

    }

    // Returns an array
    return [$b];
}

?>

1.2.1228.1. Suggestions

  • Add iterable typehint to the code (PHP 8.0+).

1.2.1228.2. Specs

Short name

Typehints/CouldBeIterable

Rulesets

All, Typechecks

Exakat since

2.1.4

PHP Version

All

Severity

Major

Time To Fix

Quick (30 mins)

Precision

High

Features

iterable

Available in

Entreprise Edition, Exakat Cloud