YetiForceCompany/YetiForceCRM

View on GitHub
modules/com_vtiger_workflow/expression_engine/VTExpressionParser.php

Summary

Maintainability
A
1 hr
Test Coverage
F
0%

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;

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')) {

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;
Severity: Major
Found in modules/com_vtiger_workflow/expression_engine/VTExpressionParser.php - About 30 mins to fix

    Reduce the number of returns of this function 5, down to the maximum allowed 3.
    Open

        public function atom()

    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');

    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]);

    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);

    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]);

    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(')'));

    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));

    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.");

    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]);

    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));

    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);

    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');

    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]);

    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(')'));
                }

    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');
            }

    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));

    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) {

    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;

    Reference to undeclared property \VTExpressionParser->tokenQueue
    Open

            $this->tokenQueue = [];

    Reference to undeclared property \VTExpressionToken->label (Did you mean $label)
    Open

            return $token->label == $label && $token->value == $value;

    Reference to undeclared property \VTExpressionTokenizer->label
    Open

                if ('OPERATOR' == $la->label && \in_array($la->value->value, $this->precedence[$prec])) {

    Reference to undeclared property \VTExpressionParser->tokens
    Open

                return $this->tokens->nextToken();

    Reference to undeclared property \VTExpressionTokenizer->label
    Open

            if ('SYMBOL' == $la1->label && 'OPEN_BRACKET' == $la2->label) {

    Reference to undeclared property \VTExpressionTokenizer->value
    Open

                if ('OPERATOR' == $la->label && \in_array($la->value->value, $this->precedence[$prec])) {

    Reference to undeclared property \VTExpressionTokenizer->value
    Open

            if ('OPERATOR' == $la->label && \in_array($la->value->value, ['+', '-'])) {

    Reference to undeclared property \VTExpressionParser->tokenQueue
    Open

            if (0 == \count($this->tokenQueue)) {

    Reference to undeclared property \VTExpressionParser->tokenQueue
    Open

            return array_shift($this->tokenQueue);

    Reference to undeclared property \VTExpressionToken->value (Did you mean $value)
    Open

            return $token->label == $label && $token->value == $value;

    Reference to undeclared property \VTExpressionParser->tokens
    Open

                $token = $this->tokens->nextToken();

    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));

    Reference to undeclared property \VTExpressionTokenizer->label
    Open

                if ('CLOSE_BRACKET' != $this->la()->label) {

    Reference to undeclared property \VTExpressionTokenizer->label
    Open

            if ('OPERATOR' == $la->label && \in_array($la->value->value, ['+', '-'])) {

    Reference to undeclared property \VTExpressionTokenizer->value
    Open

                $operator = $la->value;

    Return type of check() is undeclared type \type
    Open

        public function check(VTExpressionToken $token, $label, $value)

    Returning type bool but check() is declared to return \type
    Open

            return $token->label == $label && $token->value == $value;

    This case's code block is the same as the block for the case on line 80.
    Open

                case 'FLOAT':
                    return $token->value;

    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;

    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;

    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;

    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

    Avoid variables with short names like $la. Configured minimum length is 3.
    Open

                $la = $this->la();

    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();

    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)

    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)

    Spaces must be used to indent lines; tabs are not allowed
    Open

         * The function returns a queue of tokens.

    Spaces must be used to indent lines; tabs are not allowed
    Open

        {

    Spaces must be used to indent lines; tabs are not allowed
    Open

        {

    Spaces must be used to indent lines; tabs are not allowed
    Open

            if ($token->label != $label || $token->value != $value) {

    Spaces must be used to indent lines; tabs are not allowed
    Open

         *

    Spaces must be used to indent lines; tabs are not allowed
    Open

        }

    Spaces must be used to indent lines; tabs are not allowed
    Open

        {

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $la1 = $this->la(1);

    Spaces must be used to indent lines; tabs are not allowed
    Open

                    if ('CLOSE_BRACKET' != $comma->label) {

    Spaces must be used to indent lines; tabs are not allowed
    Open

                return new VTExpressionTreeNode([$operator, $operand]);

    Spaces must be used to indent lines; tabs are not allowed
    Open

         * @param int $n

    Spaces must be used to indent lines; tabs are not allowed
    Open

        public function la($n = 1)

    Spaces must be used to indent lines; tabs are not allowed
    Open

         * @param string             $value

    Spaces must be used to indent lines; tabs are not allowed
    Open

            switch ($token->label) {

    Spaces must be used to indent lines; tabs are not allowed
    Open

                case 'INTEGER':

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $la2 = $this->la(2);

    Spaces must be used to indent lines; tabs are not allowed
    Open

            if ('SYMBOL' == $la1->label && 'OPEN_BRACKET' == $la2->label) {

    Spaces must be used to indent lines; tabs are not allowed
    Open

                if ('CLOSE_BRACKET' != $this->la()->label) {

    Spaces must be used to indent lines; tabs are not allowed
    Open

                        $comma = $this->nextToken();

    Spaces must be used to indent lines; tabs are not allowed
    Open

        }

    Spaces must be used to indent lines; tabs are not allowed
    Open

            if (0 == \count($this->tokenQueue)) {

    Spaces must be used to indent lines; tabs are not allowed
    Open

            return array_shift($this->tokenQueue);

    Spaces must be used to indent lines; tabs are not allowed
    Open

            for ($i = \count($this->tokenQueue); $i < $n; ++$i) {

    Spaces must be used to indent lines; tabs are not allowed
    Open

         */

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $this->consumeSymbol('if');

    Spaces must be used to indent lines; tabs are not allowed
    Open

                $this->consumeSymbol('end');

    Spaces must be used to indent lines; tabs are not allowed
    Open

        public function expression()

    Spaces must be used to indent lines; tabs are not allowed
    Open

                $arr = [$this->nextToken()->value];

    Spaces must be used to indent lines; tabs are not allowed
    Open

                    $comma = $this->nextToken();

    Spaces must be used to indent lines; tabs are not allowed
    Open

            }

    Spaces must be used to indent lines; tabs are not allowed
    Open

        public function binOp()

    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.";

    Spaces must be used to indent lines; tabs are not allowed
    Open

         * @param string             $label

    Spaces must be used to indent lines; tabs are not allowed
    Open

        public function check(VTExpressionToken $token, $label, $value)

    Spaces must be used to indent lines; tabs are not allowed
    Open

        {

    Spaces must be used to indent lines; tabs are not allowed
    Open

                    }

    Spaces must be used to indent lines; tabs are not allowed
    Open

            if ($this->checkSymbol($this->la(), 'if')) {

    Spaces must be used to indent lines; tabs are not allowed
    Open

            return new VTExpressionTreeNode([new VTExpressionSymbol('if'), $cond, $ifTrue, $ifFalse]);

    Spaces must be used to indent lines; tabs are not allowed
    Open

                    $this->consume('CLOSE_BRACKET', new VTExpressionSymbol(')'));

    Spaces must be used to indent lines; tabs are not allowed
    Open

        {

    Spaces must be used to indent lines; tabs are not allowed
    Open

        }

    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.");

    Spaces must be used to indent lines; tabs are not allowed
    Open

        }

    Spaces must be used to indent lines; tabs are not allowed
    Open

                    return $token->value;

    Spaces must be used to indent lines; tabs are not allowed
    Open

                    }

    Spaces must be used to indent lines; tabs are not allowed
    Open

                } else {

    Spaces must be used to indent lines; tabs are not allowed
    Open

        private function binOpPrec($prec)

    Spaces must be used to indent lines; tabs are not allowed
    Open

                }

    Spaces must be used to indent lines; tabs are not allowed
    Open

            }

    Spaces must be used to indent lines; tabs are not allowed
    Open

        }

    Spaces must be used to indent lines; tabs are not allowed
    Open

        /**

    Spaces must be used to indent lines; tabs are not allowed
    Open

            return $token->label == $label && $token->value == $value;

    Spaces must be used to indent lines; tabs are not allowed
    Open

        public function atom()

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $this->consumeSymbol('else');

    Spaces must be used to indent lines; tabs are not allowed
    Open

        }

    Spaces must be used to indent lines; tabs are not allowed
    Open

        {

    Spaces must be used to indent lines; tabs are not allowed
    Open

                    }

    Spaces must be used to indent lines; tabs are not allowed
    Open

            if ('OPERATOR' == $la->label && \in_array($la->value->value, ['+', '-'])) {

    Spaces must be used to indent lines; tabs are not allowed
    Open

                return $this->tokens->nextToken();

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $token = $this->nextToken();

    Spaces must be used to indent lines; tabs are not allowed
    Open

        {

    Spaces must be used to indent lines; tabs are not allowed
    Open

                case 'FLOAT':

    Spaces must be used to indent lines; tabs are not allowed
    Open

        {

    Spaces must be used to indent lines; tabs are not allowed
    Open

                $this->tokenQueue[] = $token;

    Spaces must be used to indent lines; tabs are not allowed
    Open

            return $this->tokenQueue[$n - 1];

    Spaces must be used to indent lines; tabs are not allowed
    Open

         * The function returns labels and values.

    Spaces must be used to indent lines; tabs are not allowed
    Open

                    while ('COMMA' == $comma->label) {

    Spaces must be used to indent lines; tabs are not allowed
    Open

        {

    Spaces must be used to indent lines; tabs are not allowed
    Open

            ['+', '-'],

    Spaces must be used to indent lines; tabs are not allowed
    Open

            return $this->check($token, 'SYMBOL', new VTExpressionSymbol($sym));

    Spaces must be used to indent lines; tabs are not allowed
    Open

        public function unaryOp()

    Spaces must be used to indent lines; tabs are not allowed
    Open

                        throw new \App\Exceptions\AppException('Was expecting a close bracket');

    Spaces must be used to indent lines; tabs are not allowed
    Open

                return new VTExpressionTreeNode($arr);

    Spaces must be used to indent lines; tabs are not allowed
    Open

            return $this->binOp();

    Spaces must be used to indent lines; tabs are not allowed
    Open

                    return new VTExpressionTreeNode([$operator, $lhs, $rhs]);

    Spaces must be used to indent lines; tabs are not allowed
    Open

        /**

    Spaces must be used to indent lines; tabs are not allowed
    Open

         */

    Spaces must be used to indent lines; tabs are not allowed
    Open

         *

    Spaces must be used to indent lines; tabs are not allowed
    Open

        }

    Spaces must be used to indent lines; tabs are not allowed
    Open

                $ifFalse = $this->expression();

    Spaces must be used to indent lines; tabs are not allowed
    Open

                }

    Spaces must be used to indent lines; tabs are not allowed
    Open

        ];

    Spaces must be used to indent lines; tabs are not allowed
    Open

        {

    Spaces must be used to indent lines; tabs are not allowed
    Open

                $la = $this->la();

    Spaces must be used to indent lines; tabs are not allowed
    Open

            return $this->unaryOp();

    Spaces must be used to indent lines; tabs are not allowed
    Open

                $operand = $this->unaryOp();

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $this->tokenQueue = [];

    Spaces must be used to indent lines; tabs are not allowed
    Open

        public function nextToken()

    Spaces must be used to indent lines; tabs are not allowed
    Open

        {

    Spaces must be used to indent lines; tabs are not allowed
    Open

            }

    Spaces must be used to indent lines; tabs are not allowed
    Open

         *

    Spaces must be used to indent lines; tabs are not allowed
    Open

        }

    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.");

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $this->consume('SYMBOL', new VTExpressionSymbol($sym));

    Spaces must be used to indent lines; tabs are not allowed
    Open

         * @return type

    Spaces must be used to indent lines; tabs are not allowed
    Open

        }

    Spaces must be used to indent lines; tabs are not allowed
    Open

                default:

    Spaces must be used to indent lines; tabs are not allowed
    Open

        }

    Spaces must be used to indent lines; tabs are not allowed
    Open

                $operator = $la->value;

    Spaces must be used to indent lines; tabs are not allowed
    Open

        }

    Spaces must be used to indent lines; tabs are not allowed
    Open

         *

    Spaces must be used to indent lines; tabs are not allowed
    Open

                    return $token->value;

    Spaces must be used to indent lines; tabs are not allowed
    Open

                case 'SYMBOL':

    Spaces must be used to indent lines; tabs are not allowed
    Open

                case 'OPEN_BRACKET':

    Spaces must be used to indent lines; tabs are not allowed
    Open

                    $close = $this->nextToken();

    Spaces must be used to indent lines; tabs are not allowed
    Open

            if ($this->checkSymbol($la1, 'if')) {

    Spaces must be used to indent lines; tabs are not allowed
    Open

            }

    Spaces must be used to indent lines; tabs are not allowed
    Open

                        $arr[] = $this->expression();

    Spaces must be used to indent lines; tabs are not allowed
    Open

        public $precedence = [

    Spaces must be used to indent lines; tabs are not allowed
    Open

            ['==', '>=', '<=', '>', '<'],

    Spaces must be used to indent lines; tabs are not allowed
    Open

            return $this->binOpPrec(\count($this->precedence) - 1);

    Spaces must be used to indent lines; tabs are not allowed
    Open

                $lhs = $this->binOpPrec($prec - 1);

    Spaces must be used to indent lines; tabs are not allowed
    Open

                    $operator = $this->nextToken()->value;

    Spaces must be used to indent lines; tabs are not allowed
    Open

            return $this->atom();

    Spaces must be used to indent lines; tabs are not allowed
    Open

         * @return VTExpressionTokenizer

    Spaces must be used to indent lines; tabs are not allowed
    Open

        public function consumeSymbol($sym)

    Spaces must be used to indent lines; tabs are not allowed
    Open

        public function checkSymbol($token, $sym)

    Spaces must be used to indent lines; tabs are not allowed
    Open

            }

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $cond = $this->expression();

    Spaces must be used to indent lines; tabs are not allowed
    Open

            } else {

    Spaces must be used to indent lines; tabs are not allowed
    Open

                $this->nextToken();

    Spaces must be used to indent lines; tabs are not allowed
    Open

            ['and', 'or'],

    Spaces must be used to indent lines; tabs are not allowed
    Open

                    $rhs = $this->binOpPrec($prec);

    Spaces must be used to indent lines; tabs are not allowed
    Open

        {

    Spaces must be used to indent lines; tabs are not allowed
    Open

            }

    Spaces must be used to indent lines; tabs are not allowed
    Open

         * @param \VTExpressionToken $token

    Spaces must be used to indent lines; tabs are not allowed
    Open

        {

    Spaces must be used to indent lines; tabs are not allowed
    Open

                    return $token->value;

    Spaces must be used to indent lines; tabs are not allowed
    Open

                    $val = $this->expression();

    Spaces must be used to indent lines; tabs are not allowed
    Open

                    throw new \App\Exceptions\AppException('Token not found: ' . $token->label);

    Spaces must be used to indent lines; tabs are not allowed
    Open

            }

    Spaces must be used to indent lines; tabs are not allowed
    Open

                if ('OPERATOR' == $la->label && \in_array($la->value->value, $this->precedence[$prec])) {

    Spaces must be used to indent lines; tabs are not allowed
    Open

                return $lhs;

    Spaces must be used to indent lines; tabs are not allowed
    Open

                $this->nextToken();

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $this->tokens = $tokens;

    Spaces must be used to indent lines; tabs are not allowed
    Open

                $token = $this->tokens->nextToken();

    Spaces must be used to indent lines; tabs are not allowed
    Open

            }

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $token = $this->nextToken();

    Spaces must be used to indent lines; tabs are not allowed
    Open

                    return $token->value;

    Spaces must be used to indent lines; tabs are not allowed
    Open

                    return $val;

    Spaces must be used to indent lines; tabs are not allowed
    Open

        public function ifCondition()

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $this->consumeSymbol('then');

    Spaces must be used to indent lines; tabs are not allowed
    Open

                    $arr[] = $this->expression();

    Spaces must be used to indent lines; tabs are not allowed
    Open

            if ($prec >= 0) {

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $la = $this->la();

    Spaces must be used to indent lines; tabs are not allowed
    Open

        public function consume($label, $value)

    Spaces must be used to indent lines; tabs are not allowed
    Open

        }

    Spaces must be used to indent lines; tabs are not allowed
    Open

                case 'STRING':

    Spaces must be used to indent lines; tabs are not allowed
    Open

                    if ('CLOSE_BRACKET' !== $close->label) {

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $ifTrue = $this->expression();

    Spaces must be used to indent lines; tabs are not allowed
    Open

                $ifFalse = $this->ifCondition();

    Spaces must be used to indent lines; tabs are not allowed
    Open

                return $this->ifCondition();

    Spaces must be used to indent lines; tabs are not allowed
    Open

                        throw new \App\Exceptions\AppException('Was expecting a closing bracket');

    Spaces must be used to indent lines; tabs are not allowed
    Open

            ['*', '/'],

    Spaces must be used to indent lines; tabs are not allowed
    Open

        }

    Spaces must be used to indent lines; tabs are not allowed
    Open

            }

    There are no issues that match your filters.

    Category
    Status