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

Brackets vanish in Recursive IIFE

Open bardware opened this issue 2 years ago • 0 comments

@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);

bardware avatar Nov 14 '23 21:11 bardware