aaronbullard/php-schema

View on GitHub
demo/Entity/Address.php

Summary

Maintainability
A
0 mins
Test Coverage

Method __construct has 5 arguments (exceeds 4 allowed). Consider refactoring.
Wontfix

    public function __construct(string $street_1, string $street_2 = null, string $city, string $state, string $zipcode)
Severity: Minor
Found in demo/Entity/Address.php - About 35 mins to fix

    Move arguments "$street_2" after arguments without default value
    Open

        public function __construct(string $street_1, string $street_2 = null, string $city, string $state, string $zipcode)
    Severity: Major
    Found in demo/Entity/Address.php by sonar-php

    The ability to define default values for method arguments can make a method easier to use. Default argument values allow callers to specify as many or as few arguments as they want while getting the same functionality and minimizing boilerplate, wrapper code.

    But all method arguments with default values should be declared after the method arguments without default values. Otherwise, it makes it impossible for callers to take advantage of defaults; they must re-specify the defaulted values in order to "get to" the non-default arguments.

    Noncompliant Code Example

    function makeyogurt($type = "acidophilus", $flavor){...}  // Noncompliant
    
    makeyogurt("raspberry")}}  // Runtime error: Missing argument 2 in call to makeyogurt()
    

    Compliant Solution

    function makeyogurt($flavor, $type = "acidophilus", ){...}
    
    makeyogurt("raspberry")}} // Works as expected
    

    The parameter $street_1 is not named in camelCase.
    Open

        public function __construct(string $street_1, string $street_2 = null, string $city, string $state, string $zipcode)
        {
            parent::__construct(compact('street_1', 'street_2', 'city', 'state', 'zipcode'));
        }
    Severity: Minor
    Found in demo/Entity/Address.php by phpmd

    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 $street_2 is not named in camelCase.
    Open

        public function __construct(string $street_1, string $street_2 = null, string $city, string $state, string $zipcode)
        {
            parent::__construct(compact('street_1', 'street_2', 'city', 'state', 'zipcode'));
        }
    Severity: Minor
    Found in demo/Entity/Address.php by phpmd

    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

    Expected 1 newline at end of file; 0 found
    Open

    }
    Severity: Minor
    Found in demo/Entity/Address.php by phpcodesniffer

    There are no issues that match your filters.

    Category
    Status