plugin-php icon indicating copy to clipboard operation
plugin-php copied to clipboard

Invoked import/require callable removes necessary parentheses

Open adamaveray opened this issue 1 year ago • 0 comments

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')();

adamaveray avatar Feb 22 '24 08:02 adamaveray