prettier / prettier/plugin-php

[Bug] 2 snippets which make the file no more valid PHP.

Open
#1,321 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug comments inline
Dominant language
PHP
Stars
1.9k
Forks
139
PR merge metrics
No merged PRs in 30d

Description

Hello,

On the last prettier version at this time and last php plugin version, those 2 code snippets make the php file invalid after.

SNIPPET 1

Before:

<?=$this->input('before') ?><?=$this->numeric('value');?><?=$this->input('after') ?>

After:

<?=
      $this->input('before')
      $this->numeric('value')
      $this->input('after')
?>

SNIPPET 2

Before:

<?php /* Some text */ 
if ($this->context ==='cars' || ($this->context !=='cars' && $this->editmode)) : ?>

After:

 /* Some text */<?php
/* Some text */
?>if (
    $this->context === 'cars' ||
    ($this->context !== 'cars' && $this->editmode)
): ?>

Hope it help to achieve a stable version.
Big thumbs up for this wonderfull plugin !

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the formatter output with the two PHP snippets shown in the issue using the current Prettier PHP plugin. Trace the formatting path responsible for combining or moving PHP tags, then add regression coverage confirming both formatted results remain valid PHP.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.