PER 3.1 "opening bracket of a multiline array" ambiguity
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 35/100
- Tipo de issue
- Documentación
- Claridad
- Necesita aclaración
- Estado de actividad
- Activo
- Stack tecnológico
- php
- Área
- documentation
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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...
- Lenguaje dominante
- Sin datos de lenguaje
- Estrellas
- 284
- Forks
- 27
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de php-fig/per-coding-style
-
Should the single space around `=>` be stated as a general rule instead of per construct?Posiblemente ocupada @samdark la tomó hace 48 días. Abiertoenhancement
Dificultad 4/5 3-5 días Aptitud para principiantes 45/100
php-fig/per-coding-style#154 · 3 comentarios ·
-
Dificultad 3/5 1-2 días Aptitud para principiantes 48/100
php-fig/per-coding-style#149 · 1 comentario ·
-
Dificultad 1/5 1-3 horas Aptitud para principiantes 35/100
php-fig/per-coding-style#131 · 1 comentario ·
-
Destructuring syntax (list() and [])Posiblemente ocupada @samdark la tomó hace 48 días. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 58/100
php-fig/per-coding-style#119 · 8 comentarios ·
Todos los issues de php-fig/per-coding-style
Issues similares
-
bug needs-triage
Dificultad 1/5 Menos de una hora Aptitud para principiantes 78/100
mattpocock/skills#1281 ·
Los mantenedores suelen responder en 1 día
-
sync-en
Dificultad 1/5 1-3 horas Aptitud para principiantes 68/100
Los mantenedores suelen responder en 4 días
-
[oblt-aw][autodoc] Update PR Actions Detective E2E prerequisites and fix dashboard-format table typoAbiertodocumentation
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
elastic/oblt-aw#2382 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
docs(stream-protocol): document messageMetatadata on start/finish and the message-metadata chunkPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abiertofactory-active task-identify-harness-labels-done task-identify-issue-type-done
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
vercel/ai#23375 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
documentation v0.9.2
Dificultad 2/5 Medio día Aptitud para principiantes 72/100
khuisman/mcp-gee-sweet#1033 ·
Los mantenedores suelen responder en 1 día