1.2.1450. Wrong Typehinted Name

The parameter name doesn’t reflect the typehint used.

There are no restriction on parameter names, except its uniqueness in the signature. Yet, using a scalar typehint as the name for another typehinted value is just misleading. This analysis relies on exact names : calling an array a list of strings is OK with this analysis.

This analysis relies on a few variations of names : bool and boolean, int and integer.

<?php

function foo(string $array,
             int $int) {
    // doSomething()
}

function bar(array $strings) {
    // doSomething()
}

?>

1.2.1450.1. Suggestions

  • Rename the parameter

1.2.1450.2. Specs

Short name

Functions/WrongTypehintedName

Rulesets

All, Coding conventions, Semantics

Exakat since

2.0.2

PHP Version

All

Severity

Minor

Time To Fix

Quick (30 mins)

Precision

High

Features

type

Available in

Entreprise Edition, Exakat Cloud