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);
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);
- 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
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;
- Read upRead up
- Exclude checks
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)
- Read upRead up
- Exclude checks
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));
}
- Read upRead up
- Exclude checks
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);
- Read upRead up
- Exclude checks
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);
- Read upRead up
- Exclude checks
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);
- Read upRead up
- Exclude checks
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);
}
- Read upRead up
- Exclude checks
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);
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}