@prettier/plugin-php v0.11.2
Playground link
Input:
<?php
$someVeryVeryLongValue1 = 1;
$someVeryVeryLongValue2 = 2;
var_dump(
($someVeryVeryLongValue1 and $someVeryVeryLongValue2)
? 'true value'
: 'false value'
);
Output:
<?php
$someVeryVeryLongValue1 = 1;
$someVeryVeryLongValue2 = 2;
var_dump(
$someVeryVeryLongValue1 and $someVeryVeryLongValue2
? 'true value'
: 'false value'
);
The above two are not equal in execution.
It would be fine to do this for the && operator, as that has a higher precedence than the ternary, but the same is not true for "and":
https://www.php.net/manual/en/language.operators.precedence.php
PR welcome
Any starting points you would recommend?
Here logic for parens https://github.com/prettier/plugin-php/blob/master/src/needs-parens.js
@czosel @evilebottnawi this is still an issue in v12.
@prettier/plugin-php v0.12.0
Playground link
Strange. I鈥檒l try to look into this in the coming days.
Ah, the answer is simple: The fix is not part of the 0.12.0 release - it should be working in master though.
All right, guess I'll just wait for the next release and re-test then.