src/parser/StmtParser.php

Summary

Maintainability
A
1 hr
Test Coverage

The class StmtParser has 19 public methods. Consider refactoring StmtParser to keep number of public methods under 10.
Open

class StmtParser
{
    use Attachable;

    public $reader;
Severity: Minor
Found in src/parser/StmtParser.php by phpmd

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

Method _stmt has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function _stmt()
    {
        $stmt_list = [
            Tag::T_IF       => '_ifStmt',
            Tag::T_LET      => '_letStmt',
Severity: Minor
Found in src/parser/StmtParser.php - About 1 hr to fix

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

    class StmtParser
    {
        use Attachable;
    
        public $reader;
    Severity: Minor
    Found in src/parser/StmtParser.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 _foreachStmt uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
    Open

            } else {
                $alias = $this->name_parser->_identifier();
            }
    Severity: Minor
    Found in src/parser/StmtParser.php by phpmd

    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 variable $stmt_list is not named in camelCase.
    Open

        public function _stmt()
        {
            $stmt_list = [
                Tag::T_IF       => '_ifStmt',
                Tag::T_LET      => '_letStmt',
    Severity: Minor
    Found in src/parser/StmtParser.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 $stmt_list is not named in camelCase.
    Open

        public function startsStmt()
        {
            static $stmt_list = [
                Tag::T_IF, Tag::T_LET, Tag::T_WHILE, Tag::T_DO, Tag::T_FOREACH,
                Tag::T_BREAK, Tag::T_CONTINUE, Tag::T_BEGIN, Tag::T_FN, '^', '[',
    Severity: Minor
    Found in src/parser/StmtParser.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 $stmt_list is not named in camelCase.
    Open

        public function _stmtList()
        {
            $stmt_list = [];
            while ($this->startsStmt()) {
                $stmt_list[] = $this->_stmt();
    Severity: Minor
    Found in src/parser/StmtParser.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 $label_name is not named in camelCase.
    Open

        public function _labelStmt()
        {
            $this->reader->match('[');
            $label_name = $this->name_parser->_identifier();
            $this->reader->match(']');
    Severity: Minor
    Found in src/parser/StmtParser.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 $label_name is not named in camelCase.
    Open

        public function _labelStmt()
        {
            $this->reader->match('[');
            $label_name = $this->name_parser->_identifier();
            $this->reader->match(']');
    Severity: Minor
    Found in src/parser/StmtParser.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 $stmt_list is not named in camelCase.
    Open

        public function _stmtList()
        {
            $stmt_list = [];
            while ($this->startsStmt()) {
                $stmt_list[] = $this->_stmt();
    Severity: Minor
    Found in src/parser/StmtParser.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 $stmt_list is not named in camelCase.
    Open

        public function _stmt()
        {
            $stmt_list = [
                Tag::T_IF       => '_ifStmt',
                Tag::T_LET      => '_letStmt',
    Severity: Minor
    Found in src/parser/StmtParser.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 $stmt_list is not named in camelCase.
    Open

        public function _stmtList()
        {
            $stmt_list = [];
            while ($this->startsStmt()) {
                $stmt_list[] = $this->_stmt();
    Severity: Minor
    Found in src/parser/StmtParser.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 $stmt_list is not named in camelCase.
    Open

        public function _stmt()
        {
            $stmt_list = [
                Tag::T_IF       => '_ifStmt',
                Tag::T_LET      => '_letStmt',
    Severity: Minor
    Found in src/parser/StmtParser.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 _continueStmt is not named in camelCase.
    Open

        public function _continueStmt()
        {
            $this->reader->match(Tag::T_CONTINUE);
            $label = $this->_optLabel();
            return new ContinueStmt($label);
    Severity: Minor
    Found in src/parser/StmtParser.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 _stmtList is not named in camelCase.
    Open

        public function _stmtList()
        {
            $stmt_list = [];
            while ($this->startsStmt()) {
                $stmt_list[] = $this->_stmt();
    Severity: Minor
    Found in src/parser/StmtParser.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 _letStmt is not named in camelCase.
    Open

        public function _letStmt()
        {
            $this->reader->match(Tag::T_LET);
            $mutable = $this->reader->consumeIf(Tag::T_MUT);
            $name = $this->name_parser->_identifier();
    Severity: Minor
    Found in src/parser/StmtParser.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 _exprStmt is not named in camelCase.
    Open

        public function _exprStmt()
        {
            $this->reader->match(Tag::T_DO);
            $expr = $this->expr_parser->_expr();
            return new ExprStmt($expr);
    Severity: Minor
    Found in src/parser/StmtParser.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 _optLabel is not named in camelCase.
    Open

        public function _optLabel()
        {
            return $this->reader->is(Tag::T_IDENT)
                ? $this->name_parser->_identifier()
                : null;
    Severity: Minor
    Found in src/parser/StmtParser.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 _optElse is not named in camelCase.
    Open

        public function _optElse()
        {
            if ($this->reader->consumeIf(Tag::T_ELSE)) {
                return $this->_stmtList();
            }
    Severity: Minor
    Found in src/parser/StmtParser.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 _breakStmt is not named in camelCase.
    Open

        public function _breakStmt()
        {
            $this->reader->match(Tag::T_BREAK);
            $label = $this->_optLabel();
            return new BreakStmt($label);
    Severity: Minor
    Found in src/parser/StmtParser.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 _foreachStmt is not named in camelCase.
    Open

        public function _foreachStmt()
        {
            $key = null;
            $this->reader->match(Tag::T_FOREACH);
    
    
    Severity: Minor
    Found in src/parser/StmtParser.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 _ifStmt is not named in camelCase.
    Open

        public function _ifStmt()
        {
            $this->reader->match(Tag::T_IF);
            $condition = $this->expr_parser->_expr();
            $body = $this->_stmtList();
    Severity: Minor
    Found in src/parser/StmtParser.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 _whileStmt is not named in camelCase.
    Open

        public function _whileStmt()
        {
            $this->reader->match(Tag::T_WHILE);
            $condition = $this->expr_parser->_expr();
            $body = $this->_stmtList();
    Severity: Minor
    Found in src/parser/StmtParser.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 _elifList is not named in camelCase.
    Open

        public function _elifList()
        {
            $elifs = [];
            while ($this->reader->consumeIf(Tag::T_ELIF)) {
                $condition = $this->expr_parser->_expr();
    Severity: Minor
    Found in src/parser/StmtParser.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 _program is not named in camelCase.
    Open

        public function _program()
        {
            $body = [];
            while (!$this->reader->isEOF()) {
                $body[] = $this->_stmt();
    Severity: Minor
    Found in src/parser/StmtParser.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 _labelStmt is not named in camelCase.
    Open

        public function _labelStmt()
        {
            $this->reader->match('[');
            $label_name = $this->name_parser->_identifier();
            $this->reader->match(']');
    Severity: Minor
    Found in src/parser/StmtParser.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 _stmt is not named in camelCase.
    Open

        public function _stmt()
        {
            $stmt_list = [
                Tag::T_IF       => '_ifStmt',
                Tag::T_LET      => '_letStmt',
    Severity: Minor
    Found in src/parser/StmtParser.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 _parameter is not named in camelCase.
    Open

        public function _parameter()
        {
            $name = $this->name_parser->_identifier();
            $type = null;
            if ($this->reader->consumeIf('::')) {
    Severity: Minor
    Found in src/parser/StmtParser.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 _returnStmt is not named in camelCase.
    Open

        public function _returnStmt()
        {
            $this->reader->match('^');
            $expression = $this->expr_parser->_optExpr();
    
    
    Severity: Minor
    Found in src/parser/StmtParser.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 _blockStmt is not named in camelCase.
    Open

        public function _blockStmt()
        {
            $this->reader->match(Tag::T_BEGIN);
            $body = $this->_stmtList();
            $this->reader->match(Tag::T_END);
    Severity: Minor
    Found in src/parser/StmtParser.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