Skip to content

Fix extra PHP opener after short if comment - #2532

Open
sean0407 wants to merge 1 commit into
prettier:mainfrom
sean0407:codex/plugin-php-2494-invalid-close-tag-comment-20261020
Open

sean0407 wants to merge 1 commit into
prettier:mainfrom
sean0407:codex/plugin-php-2494-invalid-close-tag-comment-20261020

Conversation

@sean0407

Copy link
Copy Markdown

Summary

Avoid inserting a second <?php opener when a line comment in an alternative-syntax if is immediately followed by a PHP close tag and inline HTML. Treat the commented inline node as nested in the existing short-form if block so the printer keeps the current PHP context.

Evidence

The reproducer from #2494 formatted as <?php if (true):<?php, which introduces a syntax error. The new tests/inline/mixed-2494.php fixture now formats without the extra opener.

Checks run:

  • node node_modules/jest/bin/jest.js --runInBand — 101 suites, 597 tests, and 581 snapshots passed.
  • node --check src/printer.mjs — passed.
  • git diff --check — passed.
  • Repro formatting is idempotent and retains two PHP open tags, matching the input.

Merge Danger

Door: two-way

Blast Radius: localized

Fixes #2494

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant