-
Notifications
You must be signed in to change notification settings - Fork 1
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
Overrides the file with some log output? #5
Comments
UGH. You're kidding me. 🔥 PHPCBF writes to @muuvmuuv I'd really appreciate a Pull Request adding unit tests -- reproducing the error you're experiencing -- and hopefully a bug fix, too. Example test: https://github.com/Unibeautify/beautifier-php-codesniffer/tree/master/test/preferBeautifierConfig/subFolder The applicable code for CLI args to Thank you! |
Oh, that is bad. 😄. I‘ll create a unit test if I have time, but I think I‘ll not finding time fixing it. This would take too long to dig into. Should we refer an issue on phpcf to this issue? |
@Glavin001 I can not get a test working because I don‘t know how to change the files language programmatically (I don‘t event think it is possible), but I found some flags that could help maybe.
maybe they will fix it? I‘ll try them in my brake later |
Could you elaborate? I do not understand what you're having trouble trying to accomplish.
Let's hope. I have no clue, since I do not personally use PHPCBF 😆. |
I don't think so. Feel free, however, I suspect they did this for their own reasons. And we also want to support old and new versions of PHPCBF, so in the end we need at least a workaround on our (Unibeautify) end 👎 . |
Ok I tried it and it changes nothing. I‘ll be fine for now as it is just happening when I have a txt language file that I manually change into a php file. Normal php language files are working fine 😁 |
What did you try? I would like to add a unit tests so we can see this issue and fix it. |
I tried to add the flags I commented above. So to reproduce create a .phpcs file with the content in my first comment and run unibeautify formatter after changing the language from plain text to php. |
Turns out I used the wrong Beautifier: PHP_CodeSniffer uses I was so confused haha. The bug still persists but it has nothing to do with my config I posted above. I'll try to add tests today and maybe a fix. |
@Vader699 found this issue, too. Duplicate: Unibeautify/unibeautify#224 |
Looks like the same issue. I switched over to PHP-CS-Fixer and it does not overwrite the file like PHP_CodeSniffer does. |
Haven't looked into this (no time...), but I think we would just need to check the output against a regex to determine if it is an error output and return false instead of replacing the content. |
Applicable code: https://github.com/Unibeautify/beautifier-php-codesniffer/blob/master/src/index.ts#L105 Pull Requests very welcome! |
Stupid question(probably), what's the best way to run this to test changes? |
normal .php files are working fine, but when I select a plain text as php template and run the formatter this weird thing happen:
Before:
After:
So it outputs some log into the file and removes everything
The text was updated successfully, but these errors were encountered: