-
-
Notifications
You must be signed in to change notification settings - Fork 20
fmt
producing bad code - new without parentheses
#20
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
Comments
You may be correct, but I think including a minimal reproduction snippet would help. |
can you please share a code example that results in PHP 8.4 only syntax? i tried couple of options but i couldn't get it to output new without parens. ref: mago/crates/formatter/src/parens.rs Lines 175 to 190 in 6177bc1
|
git clone [email protected]:brick/date-time.git
cd date-time
cp ~/Downloads/mago-0.0.6-aarch64-apple-darwin/mago .
curl https://raw.githubusercontent.com/carthage-software/mago/refs/heads/main/examples/mago-full.toml -o mago.toml
chmod +x mago
xattr -rd com.apple.quarantine mago
./mago fmt
git diff src/Parser/IsoParsers.php |
I think it is equivalent, because the operator precedence of But I think the parenthesis should stay, as it could be confusing otherwise. |
indeed, confirmed equivalent with the test suite and modifying it further. |
@bendavies the reason that paren is removed is that we actually remove all parens from around expressions, and put them back only when needed. we can add a setting to add parens in that case. ref: mago/crates/formatter/src/parens.rs Line 19 in 6177bc1
|
No problem, it's not a bug. Can raise another issue. I hope my reproducer on the original issue was good for you. |
fixed. |
hi
in my
composer.json
I have"php": "^8.3",
fmt
on is formatting code valid forhttps://wiki.php.net/rfc/new_without_parentheses
which is only valid for 8.4
It shouldn't do this, right?
The text was updated successfully, but these errors were encountered: