Comments in attributes (e.g. for an array item) are weirdly moved to somewhere completely else
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 35/100
Direzione di ricerca
Riproduci il comportamento del formatter usando l’input PHP e l’output previsto nell’issue, oppure il playground collegato, concentrandoti sui commenti all’interno degli array di attributi e di altri parametri. Il lavoro è completato quando la formattazione conserva il commento accanto all’elemento dell’array invece di spostarlo nella dichiarazione della classe; nel report non viene indicato alcun file o test del repository.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Various comments inside attributes are moved to really weird places instead of staying where they were.
The example below is not the only one where something like this happens. There are a few other scenarios like e..g for a parameter etc.
Prettier 2.88.0 (but also tried the latest)
PHP Plugin 0.19.6 (but also tried the latest)
# Options (if any):
--no-options
Input:
<?php declare(strict_types=1);
namespace App\Controller\General;
use App\Dto\BarDto;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
class EnrollmentController extends AbstractController
{
#[Route(path: '/foo', name: 'app.foo', methods: [
Request::METHOD_GET, // GET is required for third party app.
Request::METHOD_POST,
])]
public function save(): Response
{
return $this->json(['foo']);
}
}
Output:
<?php declare(strict_types=1);
namespace App\Controller\General;
use App\Dto\BarDto;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
class EnrollmentController extends AbstractController // GET is required for third party app.
{
#[Route(path: '/foo', name: 'app.foo', methods: [Request::METHOD_GET, Request::METHOD_POST])]
public function save(): Response
{
return $this->json(['foo']);
}
}
Expected behavior:
Output should keep the comment where it was. IT definitely should not be moved to the class:
<?php declare(strict_types=1);
namespace App\Controller\General;
use App\Dto\BarDto;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
class EnrollmentController extends AbstractController
{
#[Route(path: '/foo', name: 'app.foo', methods: [
Request::METHOD_GET, // GET is required for third party app.
Request::METHOD_POST
])]
public function save(): Response
{
return $this->json(['foo']);
}
}
This seems to be the case for quite some time as even the old version on the playground shows the issue: Link to playground
- Lingua principale
- PHP
- Stelle
- 1.9k
- Fork
- 139
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di prettier/plugin-php
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 62/100
prettier/plugin-php#2416 · 2 commenti · 6 reazioni ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 64/100
prettier/plugin-php#2498 ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 55/100
prettier/plugin-php#2495 ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 55/100
prettier/plugin-php#2494 · 1 commento ·
-
strange format issue Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 48/100
prettier/plugin-php#2490 ·
Tutte le issue di prettier/plugin-php
Issue simili
-
status/awaiting_triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
WordPress/plugin-check#1486 ·
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
az-digital/az_quickstart#6019 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
grokability/snipe-it#19688 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100