1.2.704. Missing Type In Definition

This rule reports any missing typehints, on parameters, return value, property or class constants. It is recommended to add types to all possible structures to make the type system more efficient.

__construct() and __destruct() should not use typehints, and are omitted.

Class constants are typed starting with PHP 8.3

<?php

// No type on return type
// n type on parameter
function missing($parameter) {
    /// code
}

?>

1.2.704.1. Suggestions

  • Add a useful typehint

  • Add the mixed typehint

1.2.704.2. Specs

Short name

Typehints/MissingTypehints

Rulesets

All

Exakat since

2.3.6

PHP Version

With PHP 7.0 and more recent

Severity

Minor

Time To Fix

Quick (30 mins)

Precision

Very high

Features

parameter, property, return-value

Available in

Entreprise Edition, Exakat Cloud