I just installed the phpfmt on my latest update of the Sublime Text and I appreciate the developers for the work done thus far.
Some of my switch cases are like this:
switch ($action_to_perform) {
case 'save_dataload':
// Code for 'save_dataload' case
break;
}
but I want to achieve this:
switch ($action_to_perform) {
case 'save_dataload':
// Code for 'save_dataload' case
break;
}
I didn't find a settings to achieve this, so chat-GPT gave me a custom function to add to C:\Users\Michael\AppData\Roaming\Sublime Text\Packages\phpfmt
<?php
use Fmt\AdditionalPass;
class UnindentSwitchCaseBreak extends AdditionalPass
{
public function candidate($source, $foundTokens)
{
// Check if the source code contains switch statements
return (bool) strpos($source, 'switch');
}
public function format($source)
{
// Remove indentation from case and break statements
$source = preg_replace('/\n(\s*)(case|break)/', "\n$1$2", $source);
return $source;
}
}
and I added UnindentSwitchCaseBreak to my [passes section], but it throws this error
[08-Aug-2023 11:00:31 Europe/Berlin] PHP Warning: Undefined array key "_" in C:\Users\Michael\AppData\Roaming\Sublime Text\Packages\phpfmt\fmt.stub.php on line 3397
[08-Aug-2023 11:00:31 Europe/Berlin] PHP Notice: fwrite(): Write of 56371 bytes failed with errno=32 Broken pipe in C:\Users\Michael\AppData\Roaming\Sublime Text\Packages\phpfmt\fmt.stub.php on line 3412
I just installed the phpfmt on my latest update of the Sublime Text and I appreciate the developers for the work done thus far.
Some of my switch cases are like this:
but I want to achieve this:
I didn't find a settings to achieve this, so chat-GPT gave me a custom function to add to
C:\Users\Michael\AppData\Roaming\Sublime Text\Packages\phpfmt
and I added
UnindentSwitchCaseBreak
to my [passes section], but it throws this errorThis is my settings file
I am on a windows 11 machine running PHP 8.1.2
Pls help