The class VTExpressionParser has 12 public methods. Consider refactoring VTExpressionParser to keep number of public methods under 10. Open
class VTExpressionParser
{
public function __construct($tokens)
{
$this->tokens = $tokens;
- Read upRead up
- Exclude checks
TooManyPublicMethods
Since: 0.1
A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.
By default it ignores methods starting with 'get' or 'set'.
Example
Source https://phpmd.org/rules/codesize.html#toomanypublicmethods
Function expression
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function expression()
{
$la1 = $this->la(1);
$la2 = $this->la(2);
if ($this->checkSymbol($la1, 'if')) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Avoid too many return
statements within this method. Open
return $val;
Reduce the number of returns of this function 5, down to the maximum allowed 3. Open
public function atom()
- Read upRead up
- Exclude checks
Having too many return statements in a function increases the function's essential complexity because the flow of execution is broken each time a return statement is encountered. This makes it harder to read and understand the logic of the function.
Noncompliant Code Example
With the default threshold of 3:
function myFunction(){ // Noncompliant as there are 4 return statements if (condition1) { return true; } else { if (condition2) { return false; } else { return true; } } return false; }
Missing class import via use statement (line '135', column '16'). Open
throw new \App\Exceptions\AppException('Was expecting a closing bracket');
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '167', column '16'). Open
return new VTExpressionTreeNode([$operator, $lhs, $rhs]);
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '97', column '15'). Open
throw new \App\Exceptions\AppException('Token not found: ' . $token->label);
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '114', column '14'). Open
return new VTExpressionTreeNode([new VTExpressionSymbol('if'), $cond, $ifTrue, $ifFalse]);
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '138', column '41'). Open
$this->consume('CLOSE_BRACKET', new VTExpressionSymbol(')'));
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '54', column '32'). Open
$this->consume('SYMBOL', new VTExpressionSymbol($sym));
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '48', column '14'). Open
throw new \App\Exceptions\AppException("Was expecting a $label of value $value got a {$token->label} of {$token->value} instead.");
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '114', column '40'). Open
return new VTExpressionTreeNode([new VTExpressionSymbol('if'), $cond, $ifTrue, $ifFalse]);
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '73', column '45'). Open
return $this->check($token, 'SYMBOL', new VTExpressionSymbol($sym));
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '141', column '15'). Open
return new VTExpressionTreeNode($arr);
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '92', column '16'). Open
throw new \App\Exceptions\AppException('Was expecting a close bracket');
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '182', column '15'). Open
return new VTExpressionTreeNode([$operator, $operand]);
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
The method expression uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$this->consume('CLOSE_BRACKET', new VTExpressionSymbol(')'));
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method ifCondition uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$ifFalse = $this->expression();
$this->consumeSymbol('end');
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Define a constant instead of duplicating this literal "SYMBOL" 4 times. Open
$this->consume('SYMBOL', new VTExpressionSymbol($sym));
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "CLOSE_BRACKET" 4 times. Open
if ('CLOSE_BRACKET' !== $close->label) {
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Reference to undeclared property \VTExpressionParser->tokens
(Did you mean $tokens) Open
$this->tokens = $tokens;
- Exclude checks
Reference to undeclared property \VTExpressionParser->tokenQueue
Open
$this->tokenQueue = [];
- Exclude checks
Reference to undeclared property \VTExpressionToken->label
(Did you mean $label) Open
return $token->label == $label && $token->value == $value;
- Exclude checks
Reference to undeclared property \VTExpressionTokenizer->label
Open
if ('OPERATOR' == $la->label && \in_array($la->value->value, $this->precedence[$prec])) {
- Exclude checks
Reference to undeclared property \VTExpressionParser->tokens
Open
return $this->tokens->nextToken();
- Exclude checks
Reference to undeclared property \VTExpressionTokenizer->label
Open
if ('SYMBOL' == $la1->label && 'OPEN_BRACKET' == $la2->label) {
- Exclude checks
Reference to undeclared property \VTExpressionTokenizer->value
Open
if ('OPERATOR' == $la->label && \in_array($la->value->value, $this->precedence[$prec])) {
- Exclude checks
Reference to undeclared property \VTExpressionTokenizer->value
Open
if ('OPERATOR' == $la->label && \in_array($la->value->value, ['+', '-'])) {
- Exclude checks
Reference to undeclared property \VTExpressionParser->tokenQueue
Open
if (0 == \count($this->tokenQueue)) {
- Exclude checks
Reference to undeclared property \VTExpressionParser->tokenQueue
Open
return array_shift($this->tokenQueue);
- Exclude checks
Reference to undeclared property \VTExpressionToken->value
(Did you mean $value) Open
return $token->label == $label && $token->value == $value;
- Exclude checks
Reference to undeclared property \VTExpressionParser->tokens
Open
$token = $this->tokens->nextToken();
- Exclude checks
Argument 1 (token)
is \VTExpressionTokenizer
but \VTExpressionParser::check()
takes \VTExpressionToken
defined at /code/modules/com_vtiger_workflow/expression_engine/VTExpressionParser.php:66
Open
return $this->check($token, 'SYMBOL', new VTExpressionSymbol($sym));
- Exclude checks
Reference to undeclared property \VTExpressionTokenizer->label
Open
if ('CLOSE_BRACKET' != $this->la()->label) {
- Exclude checks
Reference to undeclared property \VTExpressionTokenizer->label
Open
if ('OPERATOR' == $la->label && \in_array($la->value->value, ['+', '-'])) {
- Exclude checks
Reference to undeclared property \VTExpressionTokenizer->value
Open
$operator = $la->value;
- Exclude checks
Return type of check()
is undeclared type \type
Open
public function check(VTExpressionToken $token, $label, $value)
- Exclude checks
Returning type bool
but check()
is declared to return \type
Open
return $token->label == $label && $token->value == $value;
- Exclude checks
This case's code block is the same as the block for the case on line 80. Open
case 'FLOAT':
return $token->value;
- Read upRead up
- Exclude checks
Having two cases
in a switch
statement or two branches in an if
chain with the same implementation is at
best duplicate code, and at worst a coding error. If the same logic is truly needed for both instances, then in an if
chain they should
be combined, or for a switch
, one should fall through to the other.
Noncompliant Code Example
switch ($i) { case 1: doSomething(); break; case 2: doSomethingDifferent(); break; case 3: // Noncompliant; duplicates case 1's implementation doSomething(); break; default: doTheRest(); } if ($a >= 0 && $a < 10) { doTheThing(); else if ($a >= 10 && $a < 20) { doTheOtherThing(); } else if ($a >= 20 && $a < 50) { doTheThing(); // Noncompliant; duplicates first condition } else { doTheRest(); } if ($b == 0) { doOneMoreThing(); } else { doOneMoreThing(); // Noncompliant; duplicates then-branch } var b = a ? 12 > 4 : 4; // Noncompliant; always results in the same value
Compliant Solution
switch ($i) { case 1: case 3: doSomething(); break; case 2: doSomethingDifferent(); break; default: doTheRest(); } if (($a >= 0 && $a < 10) || ($a >= 20 && $a < 50)) { doTheThing(); else if ($a >= 10 && $a < 20) { doTheOtherThing(); } else { doTheRest(); } doOneMoreThing(); b = 4;
or
switch ($i) { case 1: doSomething(); break; case 2: doSomethingDifferent(); break; case 3: doThirdThing(); break; default: doTheRest(); } if ($a >= 0 && $a < 10) { doTheThing(); else if ($a >= 10 && $a < 20) { doTheOtherThing(); } else if ($a >= 20 && $a < 50) { doTheThirdThing(); } else { doTheRest(); } if ($b == 0) { doOneMoreThing(); } else { doTheRest(); } int b = a ? 12 > 4 : 8;
Exceptions
Blocks in an if
chain that contain a single line of code are ignored, as are blocks in a switch
statement that contain a
single line of code with or without a following break
.
This case's code block is the same as the block for the case on line 80. Open
case 'SYMBOL':
return $token->value;
- Read upRead up
- Exclude checks
Having two cases
in a switch
statement or two branches in an if
chain with the same implementation is at
best duplicate code, and at worst a coding error. If the same logic is truly needed for both instances, then in an if
chain they should
be combined, or for a switch
, one should fall through to the other.
Noncompliant Code Example
switch ($i) { case 1: doSomething(); break; case 2: doSomethingDifferent(); break; case 3: // Noncompliant; duplicates case 1's implementation doSomething(); break; default: doTheRest(); } if ($a >= 0 && $a < 10) { doTheThing(); else if ($a >= 10 && $a < 20) { doTheOtherThing(); } else if ($a >= 20 && $a < 50) { doTheThing(); // Noncompliant; duplicates first condition } else { doTheRest(); } if ($b == 0) { doOneMoreThing(); } else { doOneMoreThing(); // Noncompliant; duplicates then-branch } var b = a ? 12 > 4 : 4; // Noncompliant; always results in the same value
Compliant Solution
switch ($i) { case 1: case 3: doSomething(); break; case 2: doSomethingDifferent(); break; default: doTheRest(); } if (($a >= 0 && $a < 10) || ($a >= 20 && $a < 50)) { doTheThing(); else if ($a >= 10 && $a < 20) { doTheOtherThing(); } else { doTheRest(); } doOneMoreThing(); b = 4;
or
switch ($i) { case 1: doSomething(); break; case 2: doSomethingDifferent(); break; case 3: doThirdThing(); break; default: doTheRest(); } if ($a >= 0 && $a < 10) { doTheThing(); else if ($a >= 10 && $a < 20) { doTheOtherThing(); } else if ($a >= 20 && $a < 50) { doTheThirdThing(); } else { doTheRest(); } if ($b == 0) { doOneMoreThing(); } else { doTheRest(); } int b = a ? 12 > 4 : 8;
Exceptions
Blocks in an if
chain that contain a single line of code are ignored, as are blocks in a switch
statement that contain a
single line of code with or without a following break
.
This case's code block is the same as the block for the case on line 80. Open
case 'INTEGER':
return $token->value;
- Read upRead up
- Exclude checks
Having two cases
in a switch
statement or two branches in an if
chain with the same implementation is at
best duplicate code, and at worst a coding error. If the same logic is truly needed for both instances, then in an if
chain they should
be combined, or for a switch
, one should fall through to the other.
Noncompliant Code Example
switch ($i) { case 1: doSomething(); break; case 2: doSomethingDifferent(); break; case 3: // Noncompliant; duplicates case 1's implementation doSomething(); break; default: doTheRest(); } if ($a >= 0 && $a < 10) { doTheThing(); else if ($a >= 10 && $a < 20) { doTheOtherThing(); } else if ($a >= 20 && $a < 50) { doTheThing(); // Noncompliant; duplicates first condition } else { doTheRest(); } if ($b == 0) { doOneMoreThing(); } else { doOneMoreThing(); // Noncompliant; duplicates then-branch } var b = a ? 12 > 4 : 4; // Noncompliant; always results in the same value
Compliant Solution
switch ($i) { case 1: case 3: doSomething(); break; case 2: doSomethingDifferent(); break; default: doTheRest(); } if (($a >= 0 && $a < 10) || ($a >= 20 && $a < 50)) { doTheThing(); else if ($a >= 10 && $a < 20) { doTheOtherThing(); } else { doTheRest(); } doOneMoreThing(); b = 4;
or
switch ($i) { case 1: doSomething(); break; case 2: doSomethingDifferent(); break; case 3: doThirdThing(); break; default: doTheRest(); } if ($a >= 0 && $a < 10) { doTheThing(); else if ($a >= 10 && $a < 20) { doTheOtherThing(); } else if ($a >= 20 && $a < 50) { doTheThirdThing(); } else { doTheRest(); } if ($b == 0) { doOneMoreThing(); } else { doTheRest(); } int b = a ? 12 > 4 : 8;
Exceptions
Blocks in an if
chain that contain a single line of code are ignored, as are blocks in a switch
statement that contain a
single line of code with or without a following break
.
Avoid using short method names like VTExpressionParser::la(). The configured minimum method name length is 3. Open
public function la($n = 1)
{
for ($i = \count($this->tokenQueue); $i < $n; ++$i) {
$token = $this->tokens->nextToken();
$this->tokenQueue[] = $token;
- Read upRead up
- Exclude checks
ShortMethodName
Since: 0.2
Detects when very short method names are used.
Example
class ShortMethod {
public function a( $index ) { // Violation
}
}
Source https://phpmd.org/rules/naming.html#shortmethodname
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class VTExpressionParser
- Exclude checks
Avoid variables with short names like $la. Configured minimum length is 3. Open
$la = $this->la();
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Avoid variables with short names like $la. Configured minimum length is 3. Open
$la = $this->la();
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Avoid variables with short names like $n. Configured minimum length is 3. Open
public function la($n = 1)
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Spaces must be used to indent lines; tabs are not allowed Open
public function __construct($tokens)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* The function returns a queue of tokens.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($token->label != $label || $token->value != $value) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$la1 = $this->la(1);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ('CLOSE_BRACKET' != $comma->label) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return new VTExpressionTreeNode([$operator, $operand]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param int $n
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function la($n = 1)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $value
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
switch ($token->label) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'INTEGER':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$la2 = $this->la(2);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ('SYMBOL' == $la1->label && 'OPEN_BRACKET' == $la2->label) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ('CLOSE_BRACKET' != $this->la()->label) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$comma = $this->nextToken();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (0 == \count($this->tokenQueue)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return array_shift($this->tokenQueue);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
for ($i = \count($this->tokenQueue); $i < $n; ++$i) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->consumeSymbol('if');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->consumeSymbol('end');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function expression()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$arr = [$this->nextToken()->value];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$comma = $this->nextToken();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function binOp()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
echo "Was expecting a $label of value $value got a {$token->label} of {$token->value} instead.";
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $label
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function check(VTExpressionToken $token, $label, $value)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($this->checkSymbol($this->la(), 'if')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return new VTExpressionTreeNode([new VTExpressionSymbol('if'), $cond, $ifTrue, $ifFalse]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->consume('CLOSE_BRACKET', new VTExpressionSymbol(')'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
throw new \App\Exceptions\AppException("Was expecting a $label of value $value got a {$token->label} of {$token->value} instead.");
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $token->value;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private function binOpPrec($prec)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $token->label == $label && $token->value == $value;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function atom()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->consumeSymbol('else');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ('OPERATOR' == $la->label && \in_array($la->value->value, ['+', '-'])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this->tokens->nextToken();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$token = $this->nextToken();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'FLOAT':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->tokenQueue[] = $token;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this->tokenQueue[$n - 1];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* The function returns labels and values.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
while ('COMMA' == $comma->label) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
['+', '-'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this->check($token, 'SYMBOL', new VTExpressionSymbol($sym));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function unaryOp()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
throw new \App\Exceptions\AppException('Was expecting a close bracket');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return new VTExpressionTreeNode($arr);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this->binOp();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return new VTExpressionTreeNode([$operator, $lhs, $rhs]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$ifFalse = $this->expression();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$la = $this->la();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this->unaryOp();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$operand = $this->unaryOp();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->tokenQueue = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function nextToken()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Line exceeds 120 characters; contains 143 characters Open
throw new \App\Exceptions\AppException("Was expecting a $label of value $value got a {$token->label} of {$token->value} instead.");
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->consume('SYMBOL', new VTExpressionSymbol($sym));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return type
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
default:
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$operator = $la->value;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $token->value;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'SYMBOL':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'OPEN_BRACKET':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$close = $this->nextToken();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($this->checkSymbol($la1, 'if')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$arr[] = $this->expression();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $precedence = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
['==', '>=', '<=', '>', '<'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this->binOpPrec(\count($this->precedence) - 1);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$lhs = $this->binOpPrec($prec - 1);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$operator = $this->nextToken()->value;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this->atom();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return VTExpressionTokenizer
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function consumeSymbol($sym)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function checkSymbol($token, $sym)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$cond = $this->expression();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->nextToken();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
['and', 'or'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$rhs = $this->binOpPrec($prec);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param \VTExpressionToken $token
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $token->value;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$val = $this->expression();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
throw new \App\Exceptions\AppException('Token not found: ' . $token->label);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ('OPERATOR' == $la->label && \in_array($la->value->value, $this->precedence[$prec])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $lhs;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->nextToken();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->tokens = $tokens;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$token = $this->tokens->nextToken();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$token = $this->nextToken();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $token->value;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $val;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function ifCondition()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->consumeSymbol('then');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$arr[] = $this->expression();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($prec >= 0) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$la = $this->la();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function consume($label, $value)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'STRING':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ('CLOSE_BRACKET' !== $close->label) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$ifTrue = $this->expression();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$ifFalse = $this->ifCondition();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this->ifCondition();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
throw new \App\Exceptions\AppException('Was expecting a closing bracket');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
['*', '/'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks