prettier / plugin-php

Prettier PHP Plugin
https://loilo.github.io/prettier-php-playground/
MIT License
1.74k stars 126 forks source link

Brackets vanish in Recursive IIFE #2277

Open bardware opened 10 months ago

bardware commented 10 months ago

@prettier/plugin-php v0.21.0 Playground link

I took the code sample from https://stackoverflow.com/a/63649677/577052

Input: This works in PHP 8.2

<?php
$arr = array();
($recursive = function (&$argument)
{
    global $recursive;

    if (count($argument) < 10)
    {
        $argument[] = 'foo';
        $recursive($argument);
    }
})($arr);
print_r($arr);

Output: The pair of brackets is gone. Code does not work

<?php
$arr = [];
$recursive = function (&$argument) {
    global $recursive;

    if (count($argument) < 10) {
        $argument[] = 'foo';
        $recursive($argument);
    }
}($arr);
print_r($arr);