Add condition for fully-qualified global functions#4
Open
LuigiPulcini wants to merge 1 commit intotimelsass:masterfrom
Open
Add condition for fully-qualified global functions#4LuigiPulcini wants to merge 1 commit intotimelsass:masterfrom
LuigiPulcini wants to merge 1 commit intotimelsass:masterfrom
Conversation
When a global function is written as a fully-qualified name (e.g. `\__()`), the PHP parser lists them as `T_NAME_FULLY_QUALIFIED` tokens. This change takes that scenario into account.
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.
The current implementation doesn't cover the case of a WordPress i18n global function written with a leading backslash (e.g.
\__()) because the PHP parser does not identify\__()as aT_STRINGbut rather as aT_NAME_FULLY_QUALIFIED.The proposed change takes that case into account by adding a new condition that is satisfied when the current
tokenisT_NAME_FULLY_QUALIFIEDand its text, starting from the second character (i.e.text.slice(1)), is one of the i18n functions.This case is necessary when a WordPress component uses external libraries that are automatically namespaced by a processor such as PHP Scoper, which transforms the name of every global function into a fully-qualified name (e.g.
esc_html__()becomes\esc_html__()).