Skip to content

Nested ternary expressions are depreceted since 7.4 #7432

@fruitl00p

Description

@fruitl00p

Bug Report

Subject Details
Rector version v0.12

We're trying to upgrade a project from PHP 7.4 to 8.1 and came across a nested ternary expression which will error out in later PHP versions (8.0+)

Minimal PHP Code Causing Issue

    function nested_ternary()
    {
      $a = 1;
      $b = 2
      $value = $a ? $b : $a ?: null;
   }

Expected Behaviour

Since the interpreter used to have some sort of handling it. It might be right to assume the previous working and give some sort of notice to recheck it manually? but also change it according to the previous handling (by adding parathesis RTL):

    function nested_ternary()
    {
      $a = 1;
      $b = 2
      $value = ($a ? $b : $a) ?: null;
   }

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions