Lint not correct for a switch/case with ternary operator
jimmyklein-actual opened this issue · comments
Pint Version
1.3.8
PHP Version
8.2.12
Description
Hello,
We encountered a bug when we lint a file containing a switch
with a case
with a ternary operator.
This is a example class before lauching pint
<?php
declare(strict_types=1);
namespace App;
class testPintClass
{
public function test($foo): string
{
switch ($foo) {
case 1:
case 2:
return 3 ? '2': '';
case 3:
case 4:
return 'more';
}
}
}
Notice that there is no space between '2'
and :
.
This is the pint.json file
{
"preset": "laravel",
"rules": {
"operator_linebreak": {
"position": "beginning"
}
}
}
Launching pint
Result with Pint version 1.3.7 👍
public function test($foo): string
{
switch ($foo) {
case 1:
case 2:
return 3 ? '2' : '';
case 3:
case 4:
return 'more';
}
}
- The space between
'2'
and:
is added - The code is 👍
Result with Pint version 1.3.8 ❌
public function test($foo): string
{
switch ($foo) {
case 1:
case 2:
return 3 ? '2' : '';
case 3
:case 4
:return 'more';
}
}
- The space between
'2'
and:
is added - The code from
:case 4
line is awful
More infos
This problem is not present when using preset symfony
(but present with preset psr12
)
I'm available to give more informations.
Steps To Reproduce
Everything is in the description.
Thank you, this seems more of an issue with PHP CS Fixer itself. Could you open an issue on their repo and provide them with a reproducible example using just PHP CS fixer? Thanks
The laravel
preset is given by pint ? Where can I find the php-cs-fixer configuration for laravel
preset ?
"operator_linebreak": {
"position": "beginning"
}
We don't create these rules. If your issue is with one of these it's best to provide a reproducible example for PHP CS Fixer.