prettier / prettier/plugin-php

Invoked import/require callable removes necessary parentheses

Open
#2,333 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

An imported or required file returning a callable value cannot be immediately invoked as Prettier is stripping the surrounding parentheses.

(The below example assumes file.php contains e.g. <?php return function() { echo 'Hello world'; };)

@prettier/plugin-php v0.22.2
Playground link

Input:

<?php
(include 'file.php')();
(require 'file.php')();

Output:

<?php
include "file.php"();
require "file.php"();

Expected behavior:

<?php
(include 'file.php')();
(require 'file.php')();

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

The issue provides a minimal PHP input, incorrect formatted output, and expected output, but names no source file or test path. Start by locating the formatter logic for parenthesized include/require expressions followed by invocation, then add regression coverage that preserves the parentheses and verifies the shown expected output.

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
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.