These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace App\Controllers; |
||
4 | |||
5 | use App\Components\Controller; |
||
6 | use App\Components\View; |
||
7 | use App\Models\User; |
||
8 | |||
9 | /** |
||
10 | * Class RegisterController |
||
11 | * @package App\Controllers |
||
12 | */ |
||
13 | class RegisterController extends Controller |
||
14 | { |
||
15 | public function filters() |
||
16 | { |
||
17 | return [ |
||
18 | [ |
||
19 | 'class' => '\Micro\Filter\AccessFilter', |
||
20 | 'actions' => ['success', 'error', 'index', 'post'], |
||
21 | 'rules' => [ |
||
22 | [ |
||
23 | 'allow' => false, |
||
24 | 'actions' => ['index', 'success', 'error', 'post'], |
||
25 | 'users' => ['@'], |
||
26 | 'message' => 'Only for not authorized!' |
||
27 | ] |
||
28 | ] |
||
29 | ], |
||
30 | [ |
||
31 | 'class' => '\Micro\Filter\CsrfFilter', |
||
32 | 'actions' => ['index'] |
||
33 | ], |
||
34 | [ |
||
35 | 'class' => '\Micro\Filter\XssFilter', |
||
36 | 'actions' => ['post'], |
||
37 | 'clean' => '*' |
||
38 | ] |
||
39 | ]; |
||
40 | } |
||
41 | |||
42 | public function actionIndex() |
||
43 | { |
||
44 | $v = new View($this->container); |
||
45 | $v->addParameter('model', new User($this->container)); |
||
46 | |||
47 | return $v; |
||
48 | } |
||
49 | |||
50 | public function actionSuccess() |
||
51 | { |
||
52 | return new View($this->container); |
||
53 | } |
||
54 | |||
55 | public function actionError() |
||
56 | { |
||
57 | return new View($this->container); |
||
58 | } |
||
59 | |||
60 | public function actionPost() |
||
61 | { |
||
62 | if ($userData = $this->container->request->post('User')) { |
||
0 ignored issues
–
show
|
|||
63 | $user = new User($this->container); |
||
64 | $user->setModelData($userData); |
||
65 | $user->pass = md5($user->pass); |
||
66 | |||
67 | if ($user->validate() && $user->save()) { |
||
68 | $this->redirect('/register/success'); |
||
69 | } |
||
70 | $this->redirect('/register/error'); |
||
71 | } |
||
72 | $this->redirect('/register'); |
||
73 | } |
||
74 | } |
||
75 |
If you access a property on an interface, you most likely code against a concrete implementation of the interface.
Available Fixes
Adding an additional type check:
Changing the type hint: