demo/Entity/Address.php
Method __construct
has 5 arguments (exceeds 4 allowed). Consider refactoring. Wontfix
Wontfix
public function __construct(string $street_1, string $street_2 = null, string $city, string $state, string $zipcode)
Move arguments "$street_2" after arguments without default value Open
Open
public function __construct(string $street_1, string $street_2 = null, string $city, string $state, string $zipcode)
- Read upRead up
- Exclude checks
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
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'));
}
- 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 parameter $street_2 is not named in camelCase. Open
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'));
}
- 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
Expected 1 newline at end of file; 0 found Open
Open
}
- Exclude checks