1.2.1068. Scalar Typehint Usage

Spot usage of scalar type hint : int, float, boolean and string.

Scalar typehint are PHP 7.0 and more recent. Some, like object, is 7.2.

Scalar typehint were not supported in PHP 5 and older. Then, the typehint is treated as a class name.

<?php

function withScalarTypehint(string $x) {}

function withoutScalarTypehint(someClass $x) {}

?>

See also PHP RFC: Scalar Type Hints and Type declarations.

1.2.1068.1. Connex PHP features

1.2.1068.1.1. Specs

Short name

Php/ScalarTypehintUsage

Rulesets

All, Appinfo, CE, Changed Behavior

Exakat since

0.8.4

PHP Version

With PHP 7.0 and more recent

Severity

Major

Time To Fix

Quick (30 mins)

Changed Behavior

PHP 7.0

Precision

Very high

Available in

Entreprise Edition, Community Edition, Exakat Cloud