-
Notifications
You must be signed in to change notification settings - Fork 25
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
Prevent trailing commas in define() from being included in the extracted value #44
base: main
Are you sure you want to change the base?
Conversation
@SteenSchutt Out of curiosity, what problems did you run into? |
The README just says to run I'm using this Dockerfile:
Getting the following output:
I am just using the PHPUnit 9.x specified in composer.json. Assuming that one should work? |
@SteenSchutt Maybe Try using |
Ah yes. |
Oh boy, I forgot how recent that PHP change allowing for trailing commas was. Any ideas on how to handle this? |
Couple of options:
|
Please let us know if you need help with writing those tests. Would definitely be a nice enhancement. |
Haven't had the time to take a proper look at the tests to do it right (vacations and deadlines 👍). If someone else wants to do it, that'd be great. IIRC my main problem was trying to figure out the test architecture, and whether it would make more sense to create a new fixtures file, or whether they should just be written in the tests directly. (e.g. whether you want a |
The current regex does not support trailing commas in the define construct (To the point where it goes completely bonkers). I'd like to propose a minor change that will address this problem.
Using the following code:
wp-config.php
is the example used in README.MD, but with a few modifications, specifically adding trailing commas with and without the third parameter:The full example is provided here:
https://gist.github.com/SteenSchutt/ca4413bf3aad75f9eb57f2b2e2999004
Output with current version:
Output with my changes:
I tried getting the tests to run so I could add to those as well, but I continuously ran my head against a wall, so I hope you can help by adding some fixtures/tests that can check this. As far as I can tell, everything else still matches as before.
The number of steps required to preg_match the config file appears to be basically the same as before as well.
Thank you for providing this class as a standalone package, it has been massively helpful :)