Method getFoundOriginData
has 6 arguments (exceeds 4 allowed). Consider refactoring. Wontfix
$field,
$fullField,
$fieldOptions,
$dataclass,
$type,
Method getOriginForType
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
$field,
$fullfield,
array $found,
$fieldOptions,
$dataclass,
Method resolveNext
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
protected function resolveNext(array $options, $lookup, $dataClass, string $source, array $next): array
Method findOrigin
has 5 arguments (exceeds 4 allowed). Consider refactoring. Confirmed
protected function findOrigin($field, $fullfield, array $found, $class, $fieldOptions): array
The method getHierarchy has a boolean flag argument $dataOnly, which is a certain sign of a Single Responsibility Principle violation. Invalid
public static function getHierarchy($class, $dataOnly = false): array
- 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 using static access to class '\SilverStripe\Core\ClassInfo' in method 'isSubclassOf'. Open
$ancestry = self::$ancestry[$class] ?? self::$ancestry[$class] = ClassInfo::ancestry($class);
- 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 assigning values to variables in if clauses and the like (line '271', column '13'). Open
protected function getRelationData($lookup, DataObjectSchema $schema, $className, array &$options)
{
if ($hasOne = $schema->hasOneComponent($className, $lookup)) {
return $hasOne;
}
- Read upRead up
- Exclude checks
IfStatementAssignment
Since: 2.7.0
Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.
Example
class Foo
{
public function bar($flag)
{
if ($foo = 'bar') { // possible typo
// ...
}
if ($baz = 0) { // always false
// ...
}
}
}
Source http://phpmd.org/rules/cleancode.html#ifstatementassignment
Avoid using static access to class '\SilverStripe\Core\ClassInfo' in method 'getHierarchyClasses'. Open
self::$ancestry[$class] = array_values(ClassInfo::ancestry($class));
- 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 assigning values to variables in if clauses and the like (line '268', column '13'). Open
protected function getRelationData($lookup, DataObjectSchema $schema, $className, array &$options)
{
if ($hasOne = $schema->hasOneComponent($className, $lookup)) {
return $hasOne;
}
- Read upRead up
- Exclude checks
IfStatementAssignment
Since: 2.7.0
Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.
Example
class Foo
{
public function bar($flag)
{
if ($foo = 'bar') { // possible typo
// ...
}
if ($baz = 0) { // always false
// ...
}
}
}
Source http://phpmd.org/rules/cleancode.html#ifstatementassignment
Avoid using static access to class '\SilverStripe\ORM\DataObject' in method 'resolveNext'. Open
$schema = DataObject::getSchema();
- 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 using static access to class '\SilverStripe\Core\ClassInfo' in method 'getSubClasses'. Open
$subClasses = ClassInfo::subclassesFor($class);
- 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 using static access to class '\SilverStripe\Core\ClassInfo' in method 'findOrigin'. Open
$dataclasses = array_diff($dataclasses, array_values(ClassInfo::subclassesFor($dataclass)));
- 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 using static access to class '\SilverStripe\ORM\DataObject' in method 'getBuildSources'. Invalid
$schemaHelper = DataObject::getSchema();
- 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 assigning values to variables in if clauses and the like (line '264', column '13'). Open
protected function getRelationData($lookup, DataObjectSchema $schema, $className, array &$options)
{
if ($hasOne = $schema->hasOneComponent($className, $lookup)) {
return $hasOne;
}
- Read upRead up
- Exclude checks
IfStatementAssignment
Since: 2.7.0
Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.
Example
class Foo
{
public function bar($flag)
{
if ($foo = 'bar') { // possible typo
// ...
}
if ($baz = 0) { // always false
// ...
}
}
}