src/parser/ExprParser.php

Summary

Maintainability
A
2 hrs
Test Coverage

Method __construct has 55 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function __construct($reader)
    {
        $this->reader = $reader;
        $this->register('&(', new PartialFuncParselet);
        $this->register(Tag::T_INTEGER, new LiteralParselet);
Severity: Major
Found in src/parser/ExprParser.php - About 2 hrs to fix

    Function _expr has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        public function _expr($precedence = 0, $opt = false)
        {
            $token = $this->reader->lookahead;
            $prefix = $this->prefixParseletForToken($token);
    
    
    Severity: Minor
    Found in src/parser/ExprParser.php - About 35 mins to fix

    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

    The class ExprParser has a coupling between objects value of 24. Consider to reduce the number of dependencies under 13.
    Open

    class ExprParser
    {
        use Attachable;
        use Parselet;
    
    
    Severity: Minor
    Found in src/parser/ExprParser.php by phpmd

    CouplingBetweenObjects

    Since: 1.1.0

    A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability

    Example

    class Foo {
        /**
         * @var \foo\bar\X
         */
        private $x = null;
    
        /**
         * @var \foo\bar\Y
         */
        private $y = null;
    
        /**
         * @var \foo\bar\Z
         */
        private $z = null;
    
        public function setFoo(\Foo $foo) {}
        public function setBar(\Bar $bar) {}
        public function setBaz(\Baz $baz) {}
    
        /**
         * @return \SplObjectStorage
         * @throws \OutOfRangeException
         * @throws \InvalidArgumentException
         * @throws \ErrorException
         */
        public function process(\Iterator $it) {}
    
        // ...
    }

    Source https://phpmd.org/rules/design.html#couplingbetweenobjects

    The method _expr has a boolean flag argument $opt, which is a certain sign of a Single Responsibility Principle violation.
    Open

        public function _expr($precedence = 0, $opt = false)
    Severity: Minor
    Found in src/parser/ExprParser.php by phpmd

    BooleanArgumentFlag

    Since: 1.4.0

    A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

    Example

    class Foo {
        public function bar($flag = true) {
        }
    }

    Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

    Avoid unused private methods such as 'postfix'.
    Open

        private function postfix($tag, $precedence)
        {
            $this->register($tag, new PostfixOperatorParselet($precedence));
        }
    Severity: Minor
    Found in src/parser/ExprParser.php by phpmd

    UnusedPrivateMethod

    Since: 0.2

    Unused Private Method detects when a private method is declared but is unused.

    Example

    class Something
    {
        private function foo() {} // unused
    }

    Source https://phpmd.org/rules/unusedcode.html#unusedprivatemethod

    The variable $error_params is not named in camelCase.
    Open

        public function _expr($precedence = 0, $opt = false)
        {
            $token = $this->reader->lookahead;
            $prefix = $this->prefixParseletForToken($token);
    
    
    Severity: Minor
    Found in src/parser/ExprParser.php by phpmd

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $error_params is not named in camelCase.
    Open

        public function _expr($precedence = 0, $opt = false)
        {
            $token = $this->reader->lookahead;
            $prefix = $this->prefixParseletForToken($token);
    
    
    Severity: Minor
    Found in src/parser/ExprParser.php by phpmd

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $error_params is not named in camelCase.
    Open

        public function _expr($precedence = 0, $opt = false)
        {
            $token = $this->reader->lookahead;
            $prefix = $this->prefixParseletForToken($token);
    
    
    Severity: Minor
    Found in src/parser/ExprParser.php by phpmd

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The method _optExpr is not named in camelCase.
    Open

        public function _optExpr()
        {
            return $this->_expr(0, true);
        }
    Severity: Minor
    Found in src/parser/ExprParser.php by phpmd

    CamelCaseMethodName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name methods.

    Example

    class ClassName {
        public function get_name() {
        }
    }

    Source

    The method _expr is not named in camelCase.
    Open

        public function _expr($precedence = 0, $opt = false)
        {
            $token = $this->reader->lookahead;
            $prefix = $this->prefixParseletForToken($token);
    
    
    Severity: Minor
    Found in src/parser/ExprParser.php by phpmd

    CamelCaseMethodName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name methods.

    Example

    class ClassName {
        public function get_name() {
        }
    }

    Source

    There are no issues that match your filters.

    Category
    Status