Plugin-php: Indent complex conditions

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

Input:

                        if (
                            $showNoticeValue === '1' &&
                            !is_null($currentService) &&
                            $currentService->getServiceId() === $activation->getServiceId()
                        ) {

Output:

                        if (
                            $showNoticeValue === '1' &&
                            !is_null($currentService) &&
                            $currentService->getServiceId() ===
                            $activation->getServiceId()
                        ) {

I'd suggest

                        if (
                            $showNoticeValue === '1' &&
                            !is_null($currentService) &&
                            $currentService->getServiceId() ===
                                $activation->getServiceId()
                        ) {
bug

Most helpful comment

yup, all set 馃憤

All 6 comments

/cc @mgrip i think we should fix this next :smile: Maybe use copy/past logic from prettier and adapt for php

sounds good 馃憤 i can try to take a look later today. might see if i can rope in https://github.com/prettier/plugin-php/issues/375 as well

interestingly enough, prettierjs actually prints w/o the indentation

There were a whole bunch of other cases that get addressed in #400 though

It actually does indent once you reach the line limit (see here).

My example above is indented deeply because i copied it out of some existing file including indentation.

Ah got it, that makes sense - let me add a test to that PR to make sure the same happens in ours

yup, all set 馃憤

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mgrip picture mgrip  路  3Comments

aboyton picture aboyton  路  4Comments

alexander-akait picture alexander-akait  路  3Comments

nikulis picture nikulis  路  5Comments

czosel picture czosel  路  5Comments