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

Invalid auto-semicolon inside string interpolation #166

Closed
Creeps44 opened this issue Jan 17, 2025 · 2 comments
Closed

Invalid auto-semicolon inside string interpolation #166

Creeps44 opened this issue Jan 17, 2025 · 2 comments

Comments

@Creeps44
Copy link

Description
The formatter automatically inserts a semicolon inside a string interpolation block. For example, a line like:
Error moving file '{$file_name}' to folder: {$e->getMessage()}
is transformed into:
Error moving file '{$file_name}' to folder: {$e->getMessage();}

Interestingly, this seems to manifest inconsistently depending on whether there are multiple such lines in the same file. If at least one line in the file already contains a semicolon when saving, the formatter seems to leave the others untouched. However, if all lines of this pattern (string interpolation with curly braces) lack the semicolon upon saving, the formatter then incorrectly adds the semicolon to all of them.

Expected Behavior
No semicolon should be added inside the braces, preserving the original (and valid) syntax:
echo "Error moving file '{$file_name}' to folder: {$e->getMessage()}";

Thank you for looking into this!

driade added a commit to driade/phpfmt8 that referenced this issue Jan 17, 2025
@driade
Copy link

driade commented Jan 17, 2025

Thanks @Creeps44 this should be fixed in the latest release

@Creeps44
Copy link
Author

@driade I can confirm. :) Thank you so much for the great work!

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

2 participants