Avoid using static access to class '\QuackCompiler\Intl\Localization' in method 'injectScope'. Open
throw new ScopeError(Localization::message('SCO020', [$this->name]));
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
The method injectScope uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$parent_scope->setMeta(Meta::M_REF_COUNT, $this->name, $refcount + 1);
}
- Read upRead up
- Exclude checks
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
Avoid using static access to class '\QuackCompiler\Intl\Localization' in method 'getType'. Open
throw new TypeError(Localization::message('TYP190', [$this->name]));
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid unused parameters such as '$parser'. Open
public function format(Parser $parser)
- Read upRead up
- Exclude checks
UnusedFormalParameter
Since: 0.2
Avoid passing parameters to methods or constructors and then not using those parameters.
Example
class Foo
{
private function bar($howdy)
{
// $howdy is not used
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter
TODO found Open
// TODO: Assert a variable is initialized in order to use it. We need
- Exclude checks
The parameter $parent_scope is not named in camelCase. Open
public function injectScope($parent_scope)
{
$this->scope = $parent_scope;
$symbol = $parent_scope->lookup($this->name);
- 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 variable $parent_scope is not named in camelCase. Open
public function injectScope($parent_scope)
{
$this->scope = $parent_scope;
$symbol = $parent_scope->lookup($this->name);
- 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 $parent_scope is not named in camelCase. Open
public function injectScope($parent_scope)
{
$this->scope = $parent_scope;
$symbol = $parent_scope->lookup($this->name);
- 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 $parent_scope is not named in camelCase. Open
public function injectScope($parent_scope)
{
$this->scope = $parent_scope;
$symbol = $parent_scope->lookup($this->name);
- 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 $parent_scope is not named in camelCase. Open
public function injectScope($parent_scope)
{
$this->scope = $parent_scope;
$symbol = $parent_scope->lookup($this->name);
- 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 $parent_scope is not named in camelCase. Open
public function injectScope($parent_scope)
{
$this->scope = $parent_scope;
$symbol = $parent_scope->lookup($this->name);
- 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();
}
}