kokororin / vscode-phpfmt

Integrates phpfmt into VS Code
https://marketplace.visualstudio.com/items?itemName=kokororin.vscode-phpfmt
BSD 3-Clause "New" or "Revised" License
129 stars 30 forks source link

Add a newline after closing bracet #110

Closed l-atome closed 10 months ago

l-atome commented 1 year ago

Hello, I begin to use your extension and i reach to configure your extension to have this format :

if (base::isLog()) { if ('info' == $_GET['ep']) { $subjectFile = 'profEspace/info/index.php'; } elseif ('programme' == $_GET['ep']) { $subjectFile = 'profEspace/programme/index.php'; } elseif ('exoProf' == $_GET['ep']) { $subjectFile = 'profEspace/exoProf/index.php'; }

But i would prefer have this format

if (base::isLog()) { if ('info' == $_GET['ep']) { $subjectFile = 'profEspace/info/index.php'; } elseif ('programme' == $_GET['ep']) { $subjectFile = 'profEspace/programme/index.php'; } elseif ('exoProf' == $_GET['ep']) { $subjectFile = 'profEspace/exoProf/index.php'; }

Is it possible ??

Thnaks for all your work!

l-atome commented 1 year ago

It's seem that I arrive to my goal to comment the line show behind in the "phpfmt/v2/fmt.stub.php" file (line 7160)

                                        $block = self::OTHER_BLOCK;
                                        if ($touchedSwitch) {
                                                $touchedSwitch = false;
                                                $block = T_SWITCH;
                                        }
                                        $blockStack[] = $block;

                                        if ($this->leftUsefulTokenIs([ST_PARENTHESES_CLOSE, T_ELSE, T_FINALLY, T_DO, T_STRING])) {
                                                if (!$this->hasLnLeftToken()) {
                                                        //$this->appendCode($this->getCrlfIndent());
                                                }
                                        }
                                        $indentToken = [
                                                'id' => $id,
                                                'implicit' => true,
                                        ];
                                        $adjustedIndendation = max($currentIndentation - $this->indent, 0);
                                        if ($touchedCaseOrDefault) {
                                                ++$adjustedIndendation;
                                        }
                                        $this->appendCode(str_repeat($this->indentChar, $adjustedIndendation) . $text);
                                        $currentIndentation = 0;
                                        if ($this->hasLnAfter()) {
                                                $indentToken['implicit'] = false;
                                                $this->setIndent(+1);
                                        }
                                        if (
                                                !$this->hasLnAfter() &&
                                                !$this->leftUsefulTokenIs([T_OBJECT_OPERATOR, T_DOUBLE_COLON]) &&
                                                !$this->rightTokenIs([T_COMMENT, T_DOC_COMMENT])
                                        ) {
                                                $this->setIndent(+1);
                                                $this->appendCode($this->getCrlfIndent());
                                                $this->setIndent(-1);
                                        }
                                        $foundStack[] = $indentToken;
                                        break;
driade commented 1 year ago

Hello, good morning. Would you please elaborate the differences between the first and the second example? Please try to format them so we can fund more easily the differences and the expected output you propose.

Thanks.