plugin-php
plugin-php copied to clipboard
Brackets vanish in Recursive IIFE
@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);