Total Complexity | 5 |
Total Lines | 63 |
Duplicated Lines | 0 % |
Coverage | 76.92% |
Changes | 0 |
1 | <?php |
||
13 | class Modular extends Composite |
||
14 | { |
||
15 | /** |
||
16 | * @inheritdoc |
||
17 | * |
||
18 | * can accept parameters. |
||
19 | * |
||
20 | * - {moduleId}: the unique module id associated to this rule. |
||
21 | */ |
||
22 | public string $notFoundMessage = 'Unknown route for module `{moduleId}`.'; |
||
23 | |||
24 | /** |
||
25 | * @var string unique id to grab the module from the application that will |
||
26 | * parse the rules. |
||
27 | */ |
||
28 | public string $moduleId; |
||
29 | |||
30 | /** |
||
31 | * @var UrlRuleCreator |
||
32 | */ |
||
33 | protected UrlRuleCreator $module; |
||
34 | |||
35 | /** |
||
36 | * @inheritdoc |
||
37 | */ |
||
38 | 21 | public function init() |
|
39 | { |
||
40 | 21 | } |
|
41 | |||
42 | /** |
||
43 | * @inheritdoc |
||
44 | */ |
||
45 | 21 | protected function isApplicable(string $route): bool |
|
49 | } |
||
50 | |||
51 | /** |
||
52 | * @inheritdoc |
||
53 | |||
54 | */ |
||
55 | 21 | protected function createRules() |
|
56 | { |
||
57 | 21 | return $this->module->createUrlRules($this); |
|
58 | } |
||
59 | |||
60 | /** |
||
61 | * @inheritdoc |
||
62 | */ |
||
63 | protected function createNotFoundException(): NotFoundHttpException |
||
64 | { |
||
65 | return new NotFoundHttpException( |
||
66 | strtr($this->notFoundMessage, ['{moduleId}' => $this->moduleId]) |
||
67 | ); |
||
68 | } |
||
69 | |||
70 | 21 | protected function ensureRules() |
|
76 | } |
||
77 | } |
||
78 |
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.
For example, imagine you have a variable
$accountId
that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to theid
property of an instance of theAccount
class. This class holds a proper account, so the id value must no longer be false.Either this assignment is in error or a type check should be added for that assignment.