elevenone /
stardust
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types = 1); |
||
| 4 | |||
| 5 | namespace App\Http\Action; |
||
| 6 | |||
| 7 | // framework |
||
| 8 | use DarkMatter\Http\Response; |
||
| 9 | use DarkMatter\Action\HtmlAction; |
||
| 10 | |||
| 11 | // application |
||
| 12 | use App\Domain\HomeDomainPayloadTwo; |
||
| 13 | use App\Http\PayloadResponder; |
||
| 14 | |||
| 15 | /** |
||
| 16 | * Class HomeActionPayload |
||
| 17 | * |
||
| 18 | * This is an example of a HtmlAction. In every HtmlAction you have access to the HtmlResponder. |
||
| 19 | * |
||
| 20 | * @package DarkMatterApp\Actions |
||
| 21 | */ |
||
| 22 | class HomeActionPayloadTwo extends HtmlAction |
||
| 23 | { |
||
| 24 | /** |
||
| 25 | * @param array $arguments Possible arguments from the URL. |
||
| 26 | * @return Response |
||
| 27 | */ |
||
| 28 | public function __invoke(array $arguments = []) : Response |
||
| 29 | { |
||
| 30 | // default argument / when not specified from the route |
||
| 31 | $id = $arguments['id'] ?? 424; |
||
| 32 | |||
| 33 | // if (!empty($arguments['id'])) {} |
||
| 34 | if (!isset($arguments['id'])) { |
||
| 35 | $arguments['id'] = $id; |
||
| 36 | } |
||
| 37 | |||
| 38 | // new domain |
||
| 39 | $domain = new HomeDomainPayloadTwo($arguments); |
||
| 40 | $payload = $domain->getWelcomePayload($arguments['id']); |
||
|
0 ignored issues
–
show
|
|||
| 41 | |||
| 42 | // set route arguments for domain |
||
| 43 | // $payload->setArguments($arguments['id']); |
||
| 44 | |||
| 45 | // Set Payload responder |
||
| 46 | $this->setResponder(new PayloadResponder($this->config)); |
||
| 47 | $responder = $this->responder->__invoke($payload); |
||
| 48 | |||
| 49 | return $responder; |
||
| 50 | } |
||
| 51 | } |
||
| 52 |
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.