Closed flap152 closed 1 year ago
Yes, feel free to issue PR. I think this is pretty light on a parsing. It just uses string manipulation. However, the better thing to do would probably be to parse the class and look at the closing offset. Or use the PhpFile
class to find the closing brace.
Fixed in #11.
Issue:
In the AnonymousMigrations task the closing
;
will appear in the wrong location if}
appears after the class (in a comment section for example).We sometimes document migrations with a data sample that could be imported into the table. We put it in a comment after the migration class because it will contain multiple records, sometimes expressed as json.
AnonymousMigrations currently replaces the last } in the file with }; to close the anonymous migration class return statement, but ends up changing the comment and the migration statement remains in error.
This modified fixture makes the test fail
It can be argued that comments belong before the code, not after, and that shift is not expected to cover such a case.
However, I made a fixture and failing test, then a change that parses the class and puts the ; right after it in the file. If wanted, I will gladly submit a PR (be warned it would be my first PR )