1.2.1447. Wrong Type With Call

This analysis checks that a call to a method uses the types.

This analysis is compatible with Union types and with Intersection types. Currently, this analysis doesn’t take into account strict_types = 1. As such, int and string won’t be compatible.

<?php

function foo(string $a) {

}

// wrong type used
foo(1);

// wrong type used
foo("1");

?>

1.2.1447.1. Suggestions

  • Use the right type with all arguments

  • Force the type with a cast

  • Check the type before calling

1.2.1447.2. Specs

Short name

Functions/WrongTypeWithCall

Rulesets

All, Analyze, CE, CI-checks, Typechecks

Exakat since

1.9.9

PHP Version

All

Severity

Minor

Time To Fix

Quick (30 mins)

Precision

Very high

Features

union-type, intersection-type

Available in

Entreprise Edition, Community Edition, Exakat Cloud