daften/addressing-bundle

View on GitHub

Showing 213 of 213 total issues

Avoid using static access to class '\CommerceGuys\Addressing\AddressFormat\AddressFormatHelper' in method 'preSubmit'.
Open

        foreach (AddressFormatHelper::getGroupedFields($addressFormat->getFormat(), $this->getFieldOverrides($form)) as $line_index => $line_fields) {

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 preSetData() has a Cyclomatic Complexity of 10. The configured cyclomatic complexity threshold is 10.
Open

    public function preSetData(FormEvent $event): void
    {
        /** @var AddressEmbeddable $address */
        $address = $event->getData();
        $form = $event->getForm();

CyclomaticComplexity

Since: 0.1

Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

Example

// Cyclomatic Complexity = 11
class Foo {
1   public function example() {
2       if ($a == $b) {
3           if ($a1 == $b1) {
                fiddle();
4           } elseif ($a2 == $b2) {
                fiddle();
            } else {
                fiddle();
            }
5       } elseif ($c == $d) {
6           while ($c == $d) {
                fiddle();
            }
7        } elseif ($e == $f) {
8           for ($n = 0; $n < $h; $n++) {
                fiddle();
            }
        } else {
            switch ($z) {
9               case 1:
                    fiddle();
                    break;
10              case 2:
                    fiddle();
                    break;
11              case 3:
                    fiddle();
                    break;
                default:
                    fiddle();
                    break;
            }
        }
    }
}

Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

The method preSubmit() has a Cyclomatic Complexity of 11. The configured cyclomatic complexity threshold is 10.
Open

    public function preSubmit(FormEvent $event): void
    {
        $data = $event->getData();
        if (!is_array($data) || !array_key_exists('countryCode', $data)) {
            return;

CyclomaticComplexity

Since: 0.1

Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

Example

// Cyclomatic Complexity = 11
class Foo {
1   public function example() {
2       if ($a == $b) {
3           if ($a1 == $b1) {
                fiddle();
4           } elseif ($a2 == $b2) {
                fiddle();
            } else {
                fiddle();
            }
5       } elseif ($c == $d) {
6           while ($c == $d) {
                fiddle();
            }
7        } elseif ($e == $f) {
8           for ($n = 0; $n < $h; $n++) {
                fiddle();
            }
        } else {
            switch ($z) {
9               case 1:
                    fiddle();
                    break;
10              case 2:
                    fiddle();
                    break;
11              case 3:
                    fiddle();
                    break;
                default:
                    fiddle();
                    break;
            }
        }
    }
}

Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

Line exceeds 120 characters; contains 125 characters
Open

        method_exists(TreeBuilder::class, 'getRootNode') ? $treeBuilder->getRootNode() : $treeBuilder->root(self::ROOT_NODE);

Line exceeds 120 characters; contains 125 characters
Open

            new TwigFunction('address_plain', [$this, 'addressPlain'], ['is_safe' => ['html'], 'needs_environment' => true]),
Severity: Minor
Found in Twig/AddressExtension.php by phpcodesniffer

Line exceeds 120 characters; contains 150 characters
Open

        foreach (AddressFormatHelper::getGroupedFields($addressFormat->getFormat(), $this->getFieldOverrides($form)) as $line_index => $line_fields) {

Line exceeds 120 characters; contains 127 characters
Open

            new TwigFunction('address_inline', [$this, 'addressInline'], ['is_safe' => ['html'], 'needs_environment' => true]),
Severity: Minor
Found in Twig/AddressExtension.php by phpcodesniffer

Line exceeds 120 characters; contains 146 characters
Open

        // When upgrading the min requirements to Symfony 5.1, use https://symfony.com/doc/current/reference/forms/types/choice.html#choice-filter

Line exceeds 120 characters; contains 134 characters
Open

        foreach (AddressFormatHelper::getGroupedFields($addressFormat->getFormat(), $fieldOverrides) as $line_index => $line_fields) {

Line exceeds 120 characters; contains 123 characters
Open

            $parents[] = $index ? $original_values[$subdivision_fields[$index - 1]] : $addressEmbeddable->getCountryCode();

Line exceeds 120 characters; contains 135 characters
Open

                'help' => 'This field is used to search an address on Google and fill it out below. This could override other values!',

Line exceeds 120 characters; contains 123 characters
Open

            $parents[] = $index ? $original_values[$subdivision_fields[$index - 1]] : $addressEmbeddable->getCountryCode();

Line exceeds 120 characters; contains 129 characters
Open

            new TwigFunction('address_default', [$this, 'addressDefault'], ['is_safe' => ['html'], 'needs_environment' => true]),
Severity: Minor
Found in Twig/AddressExtension.php by phpcodesniffer

Line indented incorrectly; expected 4 spaces, found 2
Open

  }

Line indented incorrectly; expected at least 8 spaces, found 4
Open

    $property_mapping = [
Severity: Minor
Found in FieldHelper.php by phpcodesniffer

Line indented incorrectly; expected at least 8 spaces, found 6
Open

      AddressField::POSTAL_CODE => 'postal_code',
Severity: Minor
Found in FieldHelper.php by phpcodesniffer

Expected 1 space after closing brace; newline found
Open

        }

Expected 1 space after closing brace; newline found
Open

            }

Opening brace should be on a new line
Open

  public static function getPropertyName($field) {
Severity: Minor
Found in FieldHelper.php by phpcodesniffer

Line indented incorrectly; expected 4 spaces, found 2
Open

  public function __construct($options = null, $fieldOverrides = [])
Severity
Category
Status
Source
Language