1.2.848. Non Integer Nor String As Index

Report usage of non-integer and non-string types as index in an array syntax.

PHP arrays only accept integers and strings as keys. PHP convert the other types to integer or string, and that may lead to surprises when reading the arrays.

<?php

function foo (float $index, array $array) {
     $array[$index];
}

?>

1.2.848.1. Specs

Short name

Structures/NonIntStringAsIndex

Rulesets

All, Analyze, Changed Behavior

Exakat since

2.6.2

PHP Version

All

Severity

Minor

Time To Fix

Quick (30 mins)

Precision

Low

Available in

Entreprise Edition, Exakat Cloud