Replace the newlines in nl2br()
まだ誰も着手していません。
- 主要言語
- C
- スター
- 40.4k
- フォーク
- 8.2k
- 平均マージ
- 2日 13時間
- マージ済み PR(30日)
- 96
説明
Description
The function name of nl2br() suggests that it is a "replace" operation but is actually an "insert" operation.
Would it be possible to add a 3rd parameter so the function would actually replace the newline characters?
nl2br(string $string, bool $use_xhtml = true, bool $replace = false): string
The confusion with the name and the need for the 3rd parameter is obvious in the user contributed notes (most popular one and following ones): https://www.php.net/manual/en/function.nl2br.php#49516
The advantages of the 3rd parameter (instead of changing the behavior):
- nl2br() would be idempotent when 3rd parameter is set to true. Today n2br() cannot be applied several times to a string without managing extra inserts.
- Simplify the code. We could remove the wrappers to replace the newlines from our code.
- Flexibility. Old behavior could be kept.
- Backward compatible.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず php-src にある nl2br() の実装とそのテストを見つけ、現在の挿入動作と提案されている replace パラメータを比較します。3 番目のパラメータがデフォルトでは既存の動作を維持し、有効にした場合は改行文字を置換し、両方のモードをカバーするテストがある状態を完了とします。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- php
- 領域
- backend
- issue の種類
- 機能追加
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 42/100