Showing 839 of 839 total issues
Avoid using short method names like Lexer::is(). The configured minimum method name length is 3. Open
public function is($symbol)
{
return $this->peek === $symbol;
}
- 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
Method __construct
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function __construct($input)
{
$this->size = strlen($input);
if ($this->size === 0) {
Method parse
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function parse($grammar, Token $token)
{
$parameters = [];
$kind = null;
$body = null;
Avoid using undefined variables such as '$callee_type' which will lead to PHP notices. Open
throw new TypeError(Localization::message('TYP310', [$callee_type]));
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$buffer' which will lead to PHP notices. Open
$atom = implode($buffer);
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$buffer' which will lead to PHP notices. Open
$buffer[] = $this->readChar();
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Method injectScope
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function injectScope($parent_scope)
{
$this->scope = $parent_scope;
$this->left->injectScope($parent_scope);
Method handleListDefinitions
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function handleListDefinitions()
{
$renderer = new CliColorizer();
$context = $this->state('scope')->child;
Method regex
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function regex()
{
$buffer = [];
$buffer[] = $this->readChar();
$buffer[] = $this->readChar();
Method render
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function render()
{
$line = implode('', $this->state('line'));
$column = $this->state('column');
Method getPartialOperators
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function & getPartialOperators()
{
static $op_table = [
'+',
'-',
Method format
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function format(Parser $parser)
{
$first = true;
$size = count($this->clauses);
$processed = 0;
Method __construct
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function __construct(Tokenizer $input)
{
parent::__construct($input);
$name_parser = new NameParser($this);
$type_parser = new TypeParser($this);
Function format
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function format(Parser $parser)
{
$source = '&';
switch (count($this->parameters)) {
- 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
Function getType
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function getType()
{
$left_type = $this->left->getType();
$index_type = $this->index->getType();
- 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
Function compile
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
private function compile($source, $silent = false)
{
if ('' === $source) {
$this->resetState();
return;
- 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 property $scope_level is not named in camelCase. Open
abstract class Parser
{
use Parselet;
public $input;
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
The property $is_generic is not named in camelCase. Open
class NameTypeParselet implements PrefixParselet
{
private $is_generic;
public function __construct($is_generic = false)
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
The parameter $is_generic is not named in camelCase. Open
public function __construct($is_generic = false)
{
$this->is_generic = $is_generic;
}
- Read upRead up
- Exclude checks
CamelCaseParameterName
Since: 0.2
It is considered best practice to use the camelCase notation to name parameters.
Example
class ClassName {
public function doSomething($user_name) {
}
}
Source
The parameter $parent_scope is not named in camelCase. Open
public function injectScope($parent_scope)
{
$this->left->injectScope($parent_scope);
$this->index->injectScope($parent_scope);
}
- Read upRead up
- Exclude checks
CamelCaseParameterName
Since: 0.2
It is considered best practice to use the camelCase notation to name parameters.
Example
class ClassName {
public function doSomething($user_name) {
}
}