1.2.1332. Use DNF

This rule detects the usage of the DNF. DNF is the disjunctive Normal Form. It is a syntax to handle union and intersectional types at the same time. It was introducted in PHP 8.2.

DNF is available for every typed element of PHP : properties, arguments and returntype. It was extended to class constants on PHP 8.3.

<?php

class x {
     const (A&B)|string C = 'string';

     function foo((A&B)|(C&D) $e) {}

}

?>

See also PHP 8.2: DNF Types.

1.2.1332.1. Connex PHP features

1.2.1332.1.1. Specs

Short name

Php/UseDNF

Rulesets

All, Appinfo

Exakat since

2.5.3

PHP Version

With PHP 8.2 and more recent

Severity

Minor

Time To Fix

Quick (30 mins)

Precision

Very high

Available in

Entreprise Edition, Exakat Cloud