aaronbullard/php-schema

View on GitHub
src/Observers/Observer.php

Summary

Maintainability
A
0 mins
Test Coverage

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

    public function __construct($input = [], Observable $subscriber)
Severity: Major
Found in src/Observers/Observer.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

Arguments with default values must be at the end of the argument list
Open

    public function __construct($input = [], Observable $subscriber)
Severity: Minor
Found in src/Observers/Observer.php by phpcodesniffer

There are no issues that match your filters.

Category
Status