1.2.864. Nullable With Constant

Arguments are automatically nullable with a literal null. They used to also be nullable with a constant null, before PHP 8.0.

<?php

// Extracted from https://github.com/php/php-src/blob/master/UPGRADING

// Replace
function test(int $arg = CONST_RESOLVING_TO_NULL) {}
// With
function test(?int $arg = CONST_RESOLVING_TO_NULL) {}
// Or
function test(int $arg = null) {}

?>

1.2.864.1. Suggestions

  • Use the valid syntax

1.2.864.2. Specs

Short name

Functions/NullableWithConstant

Rulesets

All, CE, CompatibilityPHP80

Exakat since

2.1.9

PHP Version

All

Severity

Minor

Time To Fix

Quick (30 mins)

Precision

High

Features

constant

Available in

Entreprise Edition, Community Edition, Exakat Cloud