fix PHP templates#144
Merged
Merged
Conversation
Owner
|
Thanks for the contributions! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR fixes some errors in PHP templates.
On
src/plugins/php/templates/tokenizer.template.php$to the$statevariable on methodTokenizer::begin()On
src/plugins/php/templates/ll.template.phpcall_user_func()to callstatic::$on_parse_beginhook, instead of assigning it to a temporary variablestatic::$on_parse_beginis a callable usingis_callable(available since PHP 5.3)php.inidirectiveOn
src/plugins/php/templates/lr.template.php$startinstead of a non-existent$staticvariable, within the check to see if either$startor$endare valid valuescall_user_func()to callstatic::$on_parse_beginhook, instead of assigning it to a temporary variablestatic::$on_parse_beginis a callable usingis_callable(available since PHP 4.0.6)php.inidirectiveget_class()instead of the'self'string when callingforward_static_call_array()on line 270 (of original code). Using the string'self'and'static'on callable array syntax is deprecated as of PHP 8.2, and generates a warning.get_class()is available since PHP 4call_user_func()to callstatic::$on_parse_endhook, instead of assigning it to a temporary variablestatic::$on_parse_endis a callable usingis_callable(available since PHP 4.0.6)Notes:
I wasn't sure which PHP version the parser generator targets, so I tried to keep the most backwards-compatible approach possible.
From the built-in functions used,
forward_static_call()was introduced in PHP 5.3, that is why I replacedarray('self', $production[2]), byarray(get_class(), $production[2])- to avoid a deprecation warning on PHP 8.2 - instead of replacing it byarray(self::class, $production[2]), as::classnotation was introduced in PHP 5.5.I had to skip git hooks when committing and pushing, as tests were failing. But they were already failing when I ran
npm cito install dependencies, and none of the failures were related to the PHP template changes I made.I can try fixing those errors, if you'd like me to, but I prefer to do it on a separate PR, as none of them are related to the changes on this PR.
References:
Epilogue
By the way, thanks for this tool. =)
I discovered it when watching your "Building a Parser from Scratch" course, and was very surprised to discover it supported PHP.
Greetings from Brazil.