1.2.257. Could Be Float

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

<?php

// Accept an int as input
function foo($b) {
    // Returns a float (cubic root of $b);
    return pow($b, 1 / 3);
}

?>

1.2.257.1. Suggestions

  • Add float typehint to the code.

1.2.257.2. Specs

Short name

Typehints/CouldBeFloat

Rulesets

All, CE, Typechecks

Exakat since

2.1.4

PHP Version

All

Severity

Major

Time To Fix

Quick (30 mins)

Precision

High

Features

float

Available in

Entreprise Edition, Community Edition, Exakat Cloud