1.2.1231. Type Could Be Integer

This rule marks arguments, class constants, properties and return types that can be set to the integer type int.

<?php

// Accept an int as input
function foo($b) {
    // Returns an int
    return $b + 8;
}

?>

1.2.1231.1. Connex PHP features

1.2.1231.1.1. Suggestions

  • Add int typehint to the code.

1.2.1231.1.2. Specs

Short name

Typehints/CouldBeInt

Rulesets

All, CE, Typechecks

Exakat since

2.1.4

PHP Version

All

Severity

Major

Time To Fix

Quick (30 mins)

Precision

High

Available in

Entreprise Edition, Community Edition, Exakat Cloud