1.2.1406. Useless Short Ternary

The short ternary operates on empty or null values. When the type of the condition is not false, boolean or null, the operator is useless.

<?php

function foo() : A { return new A; }

// This is useless
$b = foo() ? 1;

?>

1.2.1406.1. Connex PHP features

1.2.1406.1.1. Suggestions

  • Remove the ternary operator

  • Refactor the types to allow for empty values

1.2.1406.1.2. Specs

Short name

Structures/UselessShortTernary

Rulesets

All, Analyze, Changed Behavior

Exakat since

2.6.5

PHP Version

All

Severity

Minor

Time To Fix

Quick (30 mins)

Precision

High

Available in

Entreprise Edition, Exakat Cloud