How to fix empty PHP_Beautifier strings?

I am currently using PHP_Beautifier to format the code with the following command, e.g. with parameters

-t -l "ArrayNested() IndentStyles(style=bsd) NewLines(before=T_CLASS:function:T_COMMENT,after=T_COMMENT)"

It works fine except that it deletes all empty lines. After a short search, I found it in the form of a bug , which has been open since 2007.

I tried to learn codebase but could not find the specific code that does this. I appreciate any help I can get in the right direction.

+3
source share
2 answers

clwustos, PHP_Beautifier. , . , , , PHP_Beautifier:: removeWhitespace

+3

, .

script, ( PHP dvpr...): beautifier.php public function removeWhitespace()

 for ($i = count($this->aOut) -1 ; $i >= 0 ; $i--) { // go backwards
            $cNow = &$this->aOut[$i];
            if (strlen(trim($cNow)) == 0) { // only space
                if (!$this->addedBlankLine || ($cNow!="\r" && $cNow!="\n")) {
                      //array_pop($this->aOut); // delete it!
                      //$pop++;****
                }
            } else { // we find something!
                $cNow = rtrim($cNow); // rtrim out
                break;
            }
        }

, : , , , ...

+1

Source: https://habr.com/ru/post/1714960/


All Articles