1.2.65. Avoid Real

PHP has two float data type : real and double. real is rarely used, and might be deprecated in PHP 7.4.

To prepare code, avoid using is_real() and the (real) typecast.

<?php

// safe way to check for float
if (!is_float($a)) {
    $a = (float) $a;
}

// Avoid doing that
if (!is_real($a)) {
    $a = (real) $a;
}

?>

See also PHP RFC: Deprecations for PHP 7.4.

1.2.65.1. Suggestions

  • Replace is_real() by is_float()

  • Replace (real) by (float)

1.2.65.2. Specs

Short name

Php/AvoidReal

Rulesets

All, Changed Behavior, Suggestions, Top10

Exakat since

1.3.9

PHP Version

With PHP 8.0 and older

Severity

Minor

Time To Fix

Quick (30 mins)

Precision

High

Features

real

Available in

Entreprise Edition, Exakat Cloud