Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Improve formatting of heredoc/nowdoc

オープン
#1,590 コメント 1 件 リアクション 3 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
45/100
issue の種類
機能追加
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
php
領域
tooling

調査の方向性

heredoc と nowdoc のフォーマットに関するリンク先の playground の例から始め、現在の出力と想定される出力を比較します。完了の条件は、開始タグが単独の行にあるかコードに続いているかに応じて、formatter が内容と終了タグを一貫して揃え、示されているケースをカバーすることです。

索引モデルが issue の本文から書いたものです。

説明

enhancement

As suggested in https://github.com/prettier/plugin-php/issues/1274#issuecomment-570709723:

I'd say, it would be The Prettier Way™ (and also the prettier way ) to figure out one way to print heredocs and to enforce that.

One process which sounds reasonable to me: If the starting tag goes on its own line, align the content with that. Otherwise indent it one tabWidth further.

Examples of the described rule

Example 1

The heredoc-opening tag goes on its own line.

Input:

some_function(<<<'EOT'
Hello World!
EOT
);

Current output:

some_function(
    <<<'EOT'
Hello World!
EOT
);

Envisioned output:

some_function(
    <<<'EOT'
    Hello World!
    EOT
);
Example 2

The heredoc-opening tag goes on the same line as the preceding code.

Input:

$string = <<<'EOT'
Hello World!
EOT;

Current output:

$string = <<<'EOT'
Hello World!
EOT;

Envisioned output:

$string = <<<'EOT'
    Hello World!
    EOT;

The first example is actually already printed correctly, but the second one isn't (playground)

主要言語
PHP
スター
1.9k
フォーク
139
PR マージ指標
30日以内にマージされた PR はありません

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

prettier/plugin-php のほかの issue

prettier/plugin-php の issue をすべて見る

似ている issue

PHP の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。