Closed luxorwannabe closed 8 months ago
Thanks @luxorwannabe I'll check it
May you please share you configuration for the package? I can't reproduce this on my side (the comment gets correctly aligned).
Thanks.
The wrong alignment is comment on top "if", "switch". Btw, I didnt change any configs, I use it as is.
Please copy paste this and try in your side:
function test( $test )
{
// Check for $test
if ( $test ) {
echo 'TOS';
} else {
echo 'TUS';
}
}
function testA()
{
$favcolor = 'red';
// What is my fav color?
switch ( $favcolor ) {
case 'red':
echo 'Your favorite color is red!';
break;
case 'blue':
echo 'Your favorite color is blue!';
break;
default:
echo 'Your favorite color is neither red, blue, nor green!';
}
}
I get this
<?php
function test($test)
{
// Check for $test
if ($test) {
echo 'TOS';
} else {
echo 'TUS';
}
}
function testA()
{
$favcolor = 'red';
// What is my fav color?
switch ($favcolor) {
case 'red':
echo 'Your favorite color is red!';
break;
case 'blue':
echo 'Your favorite color is blue!';
break;
default:
echo 'Your favorite color is neither red, blue, nor green!';
}
}
PHP 8.2. This is my config (I use Sublime Text, but under the hood the package is the same)
{
"autocomplete": false,
"autoimport": false,
"excludes": [
],
"format_on_save": true,
"passes":
[
"AlignDoubleArrow",
"AlignPHPCode",
"SpaceAfterExclamationMark",
"AlignConstVisibilityEquals",
"AutoSemicolon",
"ConvertOpenTagWithEcho",
"AlignEquals",
"MergeNamespaceWithOpenTag",
"RemoveSemicolonAfterCurly",
"RestoreComments",
"ShortArray",
"ExtraCommaInArray",
"AlignDoubleSlashComments"
],
"php_bin": "/usr/local/bin/php",
"psr1": false,
"psr1_naming": true,
"psr2": true,
"readini": false,
"smart_linebreak_after_curly": false,
"version": 4,
"wp": false,
}
Hi thanks for sharing your config, this video will show you the details: Video Demo
SOLVED, I just remove SpaceAroundControlStructures from passes. Thak you very much for your help :)
Dear All,
When I try to format my php code with phpfmt - PHP formatter (visual studio code)from:
It will become:
As you can see the comment // Check for $test is not aligned vertically with IF statement. How to fix this?
Thanks