Firesphere/silverstripe-solr-search

View on GitHub
src/Helpers/FieldResolver.php

Summary

Maintainability
A
2 hrs
Test Coverage
A
98%

Method getFoundOriginData has 6 arguments (exceeds 4 allowed). Consider refactoring.
Wontfix

        $field,
        $fullField,
        $fieldOptions,
        $dataclass,
        $type,
Severity: Minor
Found in src/Helpers/FieldResolver.php - About 45 mins to fix

    Method getOriginForType has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

            $field,
            $fullfield,
            array $found,
            $fieldOptions,
            $dataclass,
    Severity: Minor
    Found in src/Helpers/FieldResolver.php - About 45 mins to fix

      Method resolveNext has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          protected function resolveNext(array $options, $lookup, $dataClass, string $source, array $next): array
      Severity: Minor
      Found in src/Helpers/FieldResolver.php - About 35 mins to fix

        Method findOrigin has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Confirmed

            protected function findOrigin($field, $fullfield, array $found, $class, $fieldOptions): array
        Severity: Minor
        Found in src/Helpers/FieldResolver.php - About 35 mins to fix

          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
          Severity: Minor
          Found in src/Helpers/FieldResolver.php by phpmd

          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);
          Severity: Minor
          Found in src/Helpers/FieldResolver.php by phpmd

          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;
                  }
          Severity: Minor
          Found in src/Helpers/FieldResolver.php by phpmd

          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));
          Severity: Minor
          Found in src/Helpers/FieldResolver.php by phpmd

          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;
                  }
          Severity: Minor
          Found in src/Helpers/FieldResolver.php by phpmd

          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();
          Severity: Minor
          Found in src/Helpers/FieldResolver.php by phpmd

          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);
          Severity: Minor
          Found in src/Helpers/FieldResolver.php by phpmd

          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)));
          Severity: Minor
          Found in src/Helpers/FieldResolver.php by phpmd

          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();
          Severity: Minor
          Found in src/Helpers/FieldResolver.php by phpmd

          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;
                  }
          Severity: Minor
          Found in src/Helpers/FieldResolver.php by phpmd

          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

          There are no issues that match your filters.

          Category
          Status