1.2.863. Null Type Favorite

Null typed may be written in two ways : with ? or with union type and null.

The analyzed code has less than 10% of one of them : for consistency reasons, it is recommended to make them all the same.

<?php

function foo(?A $a) : B|null {
    // some code
}

?>

1.2.863.1. Specs

Short name

Functions/NullTypeFavorite

Rulesets

All, Changed Behavior, Preferences

Exakat since

2.3.2

PHP Version

With PHP 8.0 and more recent

Severity

Minor

Time To Fix

Quick (30 mins)

Precision

High

Features

null

Available in

Entreprise Edition, Exakat Cloud