prettier / prettier/plugin-php

Some comment positions inside attributes can result in prettier failing with an exception

Offen
#2,283 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Vorherrschende Sprache
PHP
Sterne
1.9k
Forks
139
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

Not sure which cases these include exactly but some cases result in pretter stopping with an error:

Error: Comment "// abc" was not printed. Please report this error!

I know that i was also able to produce that error with other positions, but various other work fine so it is a bit weird.

Playground also shows it: Link to playground

Prettier 2.88.0 (but also tried latest)

PHP Plugin 0.19.6 (but also tried 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\Response;
use Symfony\Component\HttpKernel\Attribute\MapRequestPayload;
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;

class EnrollmentController extends AbstractController
{
    public function save(
        #[
            MapRequestPayload(
                serializationContext: [ // abc
                    AbstractNormalizer::CALLBACKS => [
                        'abc' => 'trim',
                    ],
                ],
            ),
        ]
        BarDto $data,
    ): Response {
        return $this->json(['foo']);
    }
}

Output:

None. Errror as mentioned above.

Expected behavior:
No error and correctly formatted.

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Reproduziere die Ausnahme mit der bereitgestellten PHP-Eingabe im verlinkten Playground oder in der neuesten Plugin-Version und verfolge anschließend die Kommentarverarbeitung des PHP-Plugins für Kommentare innerhalb von Attributen. Erledigt ist die Aufgabe, wenn die Eingabe erfolgreich formatiert wird und der Kommentar ohne den Fehler “Comment was not printed” erhalten bleibt.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
php
Bereich
tooling
Issue-Typ
Bug
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
48/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.