Plugin-php: Comment moved to previous if statement

Created on 25 Mar 2018  路  4Comments  路  Source: prettier/plugin-php

if ($foo) {
}

// A comment
if ($bar) {
}

becomes

if ($foo) {
    // A comment
}
if ($bar) {

}

This doesn't seem to be because of the empty if blocks, I simply removed them to make the example smaller.

All 4 comments

may be related with https://github.com/glayzzle/php-parser/issues/141 - it's related to the way php-parser calculate statements offsets (and includes also the comment)

I believe this should have been fixed with #251 - @aboyton can you confirm?

@mgrip I can confirm that this issue is fixed. However while looking at this I found a similar (but different) issue, which I'll go ahead and open an issue on.

Yes, this does now seem fixed thanks. (Being in Sydney Australia means my replies are sometimes a bit delayed.)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

czosel picture czosel  路  5Comments

mgrip picture mgrip  路  3Comments

alexander-akait picture alexander-akait  路  3Comments

sgruetter picture sgruetter  路  5Comments

czosel picture czosel  路  6Comments