PER 3.1 "opening bracket of a multiline array" ambiguity
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 35/100
- issue の種類
- ドキュメント
- 明瞭さ
- 説明が足りない
- 活発さ
- 活発
- 技術スタック
- php
調査の方向性
Start with section 11 of the PER 3.1 migration document and specification, then compare its nested-array examples with section 4.7's argument-list rules. The work is done when the wording consistently defines how multiline arrays interact with single- and multi-line calls and the examples no longer conflict.
索引モデルが issue の本文から書いたものです。
説明
The PER 3.1 migration document states in section 11:
The opening bracket of a multiline array MUST NOT be placed on its own line. This rule applies to arrays in all contexts, not only assignments. For example:
<?php return [ 'foo', 'bar', ]; someFunction([ 'foo', 'bar', ]);
And the section 11 of the spec states
When an array declaration is split across multiple lines, the opening bracket MUST NOT be placed on its own line.
But the example shown violates this already with the 2nd nested array as in
$arr2 = [ 'multi', 'line', 'declaration', ['values' => 1, 5, 7], [ 'nested', 'array', ], ];
This gets even worse when combined with call argument rules in section 4.7:
Argument lists MAY be split across multiple lines, where each subsequent line is indented once. When doing so, the first item in the list MUST be on the next line, and there MUST be only one argument per line. A single argument being split across multiple lines (as might be the case with a closure or array) does not constitute splitting the argument list itself.
A multi-argument call written in multi-line style always violates either rules of section 4.7 or 11:
someFunction(
$baz, [
'foo',
'bar',
],
);
I think what the addendum in PER 3.1 wants to say is that an array written in multi-line style needs to be treated as a compact single-line item when applying other rules. "Compact single-line item" is no term specified yet and there might be better ones to describe this, but basically similar to a scalar or a variable etc.
This automatically fixes the nested array example in section 11 and its in line with the example shown in the PER 3.1 diff section 11
someFunction([
'foo',
'bar',
]);
if this is interpreted as a function call in single-line style.
This is also in line with the example showing a multi-argument call in single-line style in section 4.7:
somefunction($foo, $bar, [
// ...
], $baz);
As a consequence, it would clarify the ambiguity in multi-argument calls in multi-line style to be
someFunction(
$baz,
[
'foo',
'bar',
],
);
but also (!):
someFunction(
[
'foo',
'bar',
],
$baz,
);
It would also mean that a single-argument call written in multi-line style such as
someFunction(
$someVar,
);
(which is valid according to PER) still enables to write
someFunction(
[
'foo',
'bar',
],
);
unless there is a rule enforcing to write single-array-argument calls in single-line style always...
- 主要言語
- 言語のデータがありません
- スター
- 284
- フォーク
- 27
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
php-fig/per-coding-style のほかの issue
-
Should the single space around `=>` be stated as a general rule instead of per construct?対応中かも @samdark が 50 日前に担当しました。 オープンenhancement
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
php-fig/per-coding-style#154 · コメント 3 件 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 48/100
php-fig/per-coding-style#149 · コメント 1 件 ·
-
難易度 1/5 1〜3時間 初心者へのやさしさ 35/100
php-fig/per-coding-style#131 · コメント 1 件 ·
-
Destructuring syntax (list() and [])対応中かも @samdark が 50 日前に担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 58/100
php-fig/per-coding-style#119 · コメント 8 件 ·
php-fig/per-coding-style の issue をすべて見る
似ている issue
-
documentation glm5 llm-model
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
vllm-project/vllm-ascend#19062 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1〜3時間 初心者へのやさしさ 78/100
tursodatabase/turso#10052 ·
メンテナーはふだん 1 日以内に返信
-
Mac mini M6 (16 GB): Q2_0 streaming works - measured 11.7->27.2 tok/s + arena fix for sub-32 GB Macsオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
enhancement needs triage
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
elastic/docs-builder#4495 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
cellrishi-code/claude-skills-atlas#165 ·
メンテナーはふだん 1 日以内に返信