Skip to content
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

New Utils\Context class #219

Merged
merged 1 commit into from
Sep 21, 2020
Merged

New Utils\Context class #219

merged 1 commit into from
Sep 21, 2020

Conversation

jrfnl
Copy link
Member

@jrfnl jrfnl commented Sep 21, 2020

This class introduces five new utility methods to examine the context in which an arbitrary token is used.

The class currently contains the following methods:

  • inEmpty() - to check whether an arbitrary token is used within the empty() language construct. Returns boolean.
  • inIsset() - to check whether an arbitrary token is used within the isset() language construct. Returns boolean.
  • inUnset() - to check whether an arbitrary token is used within the unset() language construct. Returns boolean.
  • inForeachCondition() - to check whether an arbitrary token is used within the condition of a foreach() control structure and if so, in what part. Returns string beforeAs, as or afterAs or false when not in a foreach condition or in case of a parse error.
  • inForCondition() - to check whether an arbitrary token is used within the condition of a for() control structure and if so, in what part. Returns string expr1, expr2 or expr3 or false when not in a for condition or in case of a parse error.

Includes dedicated unit tests for each method.

This class introduces five new utility methods to examine the context in which an arbitrary token is used.

The class currently contains the following methods:
* `inEmpty()` - to check whether an arbitrary token is used within the `empty()` language construct. Returns boolean.
* `inIsset()` - to check whether an arbitrary token is used within the `isset()` language construct. Returns boolean.
* `inUnset()` - to check whether an arbitrary token is used within the `unset()` language construct. Returns boolean.
* `inForeachCondition()` - to check whether an arbitrary token is used within the condition of a `foreach()` control structure and if so, in what part. Returns string `beforeAs`, `as` or `afterAs` or `false` when not in a foreach condition or in case of a parse error.
* `inForCondition()` - to check whether an arbitrary token is used within the condition of a `for()` control structure and if so, in what part. Returns string `expr1`, `expr2` or `expr3` or `false` when not in a for condition or in case of a parse error.

Includes dedicated unit tests for each method.
@jrfnl
Copy link
Member Author

jrfnl commented Sep 21, 2020

@sirbrillig I imagine the methods in this PR might be useful for you in VariableAnalysis too ?

@jrfnl jrfnl merged commit 6507ea0 into develop Sep 21, 2020
@jrfnl jrfnl deleted the feature/new-context-utils-class branch September 21, 2020 03:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant