Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Brackets vanish in Recursive IIFE #2277

Open
bardware opened this issue Nov 14, 2023 · 0 comments
Open

Brackets vanish in Recursive IIFE #2277

bardware opened this issue Nov 14, 2023 · 0 comments

Comments

@bardware
Copy link

@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);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant