1 | <?php |
||
2 | |||
3 | namespace Lyco\User; |
||
4 | |||
5 | use Anax\Commons\ContainerInjectableInterface; |
||
6 | use Anax\Commons\ContainerInjectableTrait; |
||
7 | use Lyco\User\HTMLForm\UserLoginForm; |
||
8 | use Lyco\User\HTMLForm\CreateUserForm; |
||
9 | |||
10 | // use Anax\Route\Exception\ForbiddenException; |
||
11 | // use Anax\Route\Exception\NotFoundException; |
||
12 | // use Anax\Route\Exception\InternalErrorException; |
||
13 | |||
14 | /** |
||
15 | * A sample controller to show how a controller class can be implemented. |
||
16 | */ |
||
17 | class UserController implements ContainerInjectableInterface |
||
18 | { |
||
19 | use ContainerInjectableTrait; |
||
20 | |||
21 | /** |
||
22 | * Description. |
||
23 | * |
||
24 | * @param datatype $variable Description |
||
0 ignored issues
–
show
|
|||
25 | * |
||
26 | * @throws Exception |
||
27 | * |
||
28 | * @return object as a response object |
||
29 | */ |
||
30 | public function indexActionGet() : object |
||
31 | { |
||
32 | $page = $this->di->get("page"); |
||
33 | |||
34 | $page->add("anax/v2/article/default", [ |
||
35 | "content" => "An index page", |
||
36 | ]); |
||
37 | |||
38 | return $page->render([ |
||
39 | "title" => "A index page", |
||
40 | ]); |
||
41 | } |
||
42 | |||
43 | /** |
||
44 | * Description. |
||
45 | * |
||
46 | * @param datatype $variable Description |
||
47 | * |
||
48 | * @throws Exception |
||
49 | * |
||
50 | * @return object as a response object |
||
51 | */ |
||
52 | public function loginAction() : object |
||
53 | { |
||
54 | $page = $this->di->get("page"); |
||
55 | $form = new UserLoginForm($this->di); |
||
56 | $form->check(); |
||
57 | |||
58 | $page->add("anax/v2/article/default", [ |
||
59 | "content" => $form->getHTML(), |
||
60 | ]); |
||
61 | |||
62 | return $page->render([ |
||
63 | "title" => "A login page", |
||
64 | ]); |
||
65 | } |
||
66 | |||
67 | |||
68 | |||
69 | /** |
||
70 | * Description. |
||
71 | * |
||
72 | * @param datatype $variable Description |
||
73 | * |
||
74 | * @throws Exception |
||
75 | * |
||
76 | * @return object as a response object |
||
77 | */ |
||
78 | public function createAction() : object |
||
79 | { |
||
80 | $page = $this->di->get("page"); |
||
81 | $form = new CreateUserForm($this->di); |
||
82 | $form->check(); |
||
83 | |||
84 | $page->add("anax/v2/article/default", [ |
||
85 | "content" => $form->getHTML(), |
||
86 | ]); |
||
87 | |||
88 | return $page->render([ |
||
89 | "title" => "A create user page", |
||
90 | ]); |
||
91 | } |
||
92 | |||
93 | /** |
||
94 | * Description. |
||
95 | * |
||
96 | * @throws Exception |
||
97 | * |
||
98 | * @return object as a response object |
||
99 | */ |
||
100 | public function logoutAction() : object |
||
101 | { |
||
102 | $this->di->get("session")->delete("userId"); |
||
103 | $this->di->get("response")->redirect("user/login"); |
||
0 ignored issues
–
show
In this branch, the function will implicitly return
null which is incompatible with the type-hinted return object . Consider adding a return statement or allowing null as return value.
For hinted functions/methods where all return statements with the correct type are only reachable via conditions, ?null? gets implicitly returned which may be incompatible with the hinted type. Let?s take a look at an example: interface ReturnsInt {
public function returnsIntHinted(): int;
}
class MyClass implements ReturnsInt {
public function returnsIntHinted(): int
{
if (foo()) {
return 123;
}
// here: null is implicitly returned
}
}
![]() |
|||
104 | } |
||
105 | } |
||
106 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths