Use regex to make the newer PHP syntax work in the older PHP Parser we're using. #248
+103
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
See #246, #228.
Since I have no hope of personally being able to upgrade the parser any time soon, I took a different approach of making the existing parser work with current-day WordPress.
This requires "downgrading" PHP syntax used in Core to a syntax that the parser recognises.
I've attempted to not edit the source files on disk, such that the source importer gets the correct source.
I've attempted to keep the syntax that it's converted to mostly the same meaning as the existing code, this ensures that any fancyness in resolving that the parser includes still works.
There may have been libraries to transpile WordPress into PHP5 syntax, but I didn't want to use this as it would alter the line numbers of code, causing the source extractor to fail to find the correct code.
This has been tested within the included wp-env environment only.
Unfortunately I didn't take note of examples of the code that each regex is affecting, so you might just have to take my word for it..
I'll try running this on WordPress.org tomorrow to update developer.w.org