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\Controller\User; |
||
4 | |||
5 | use App\Controller\BaseController; |
||
6 | use App\Service\UserService; |
||
7 | use Slim\Container; |
||
8 | |||
9 | /** |
||
10 | * Base User Controller. |
||
11 | */ |
||
12 | View Code Duplication | abstract class BaseUser extends BaseController |
|
13 | { |
||
14 | /** |
||
15 | * @var UserService |
||
16 | */ |
||
17 | protected $userService; |
||
18 | |||
19 | /** |
||
20 | * @param Container $container |
||
21 | */ |
||
22 | public function __construct(Container $container) |
||
23 | { |
||
24 | $this->container = $container; |
||
0 ignored issues
–
show
|
|||
25 | $this->logger = $container->get('logger'); |
||
26 | } |
||
27 | |||
28 | /** |
||
29 | * @return UserService |
||
30 | */ |
||
31 | protected function getUserService() |
||
32 | { |
||
33 | return $this->container->get('user_service'); |
||
34 | } |
||
35 | |||
36 | /** |
||
37 | * @return array |
||
38 | */ |
||
39 | protected function getInput() |
||
40 | { |
||
41 | return $this->request->getParsedBody(); |
||
42 | } |
||
43 | } |
||
44 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: