prettier / prettier/plugin-php
Brackets vanish in Recursive IIFE
Open
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 1.9k
- Forks
- 139
- PR merge metrics
- No merged PRs in 30d
Description
@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);
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue using the linked Playground example and compare the input with the formatted output. Investigate the plugin's formatting path for recursive immediately invoked functions; done means the brackets are preserved and the formatted PHP remains valid and executable.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100