Order of optional parameters
Expected output and potential fix for issue with InvokableCommandInputAttributeRector
@samsonasik Could you look into this?
I will try
@florisluiten I've updated the rule, so it can keep correct attribute per line formatting. Hopefully it will fix the comma issue. Can you rebase?
Hi guys, thanks for helping me out here.
I rebased on master and cherry-picked the commits. However, the tests still fail with the trailing comma's. Did I perhaps do something wrong?
I did notice that in one situation, the comma between parameters is missing as well:
9) Rector\Symfony\Tests\Symfony73\Rector\Class_\InvokableCommandInputAttributeRector\InvokableCommandInputAttributeRectorTest::test with data set #13 ('/[...].php.inc
')
Failed on fixture file "with_multiple_arguments_options_fluent.php.inc"
Failed asserting that string matches format description.
--- Expected
+++ Actual
@@ @@
#[\Symfony\Component\Console\Attribute\Argument(name: 'argument2', description: 'Argument2 description')]
string $argument2,
#[\Symfony\Component\Console\Attribute\Option(name: 'option1', shortcut: 'o', mode: InputOption::VALUE_NONE, description: 'Option1 description')]
- bool $option1 = false,
+ bool $option1 = false
#[\Symfony\Component\Console\Attribute\Option(name: 'option2', shortcut: 'p', mode: InputOption::VALUE_NONE, description: 'Option2 description')]
- bool $option2 = false
+ bool $option2 = false,
): int
{
So I must conclude that my original thought that these comma's were automatically applied is incorrect. I'm now trying to read into how this all works, hoping that better understanding makes debugging easier.
On the middle params, comma is needed. To debug, you probably needs to create temporary variable, the clear up params, then add one by one params on sort.
Thanks for the pointers! I'm a couple of hours later into this thing and I still haven't figured out how to do this... I give up :disappointed: