plugin-php icon indicating copy to clipboard operation
plugin-php copied to clipboard

Parentheses around nested ternary expressions are removed, causing syntax error in PHP 8.0

Open villermen opened this issue 3 years ago • 1 comments

@prettier/plugin-php v0.19.2 Playground link

Input:

<?php

var_dump((1 ? 2 : 3) ?: 4);

Output:

<?php

var_dump(1 ? 2 : 3 ?: 4);

Leads to this syntax error in PHP 8.1:

Nested ternary expressions are deprecated since PHP 7.4

Note: It does work as expected when you don't make use of a shorthand ternary operator (?:).

villermen avatar Nov 28 '22 16:11 villermen

The issue is still present in @prettier/plugin-php v0.22.4, is there any chance it gets fixed soon ?

fchalal avatar Mar 28 '25 02:03 fchalal