1 | <?php |
||
12 | abstract class Component implements ComponentInterface |
||
13 | { |
||
14 | use HasEvents, |
||
15 | HasNavigation; |
||
16 | |||
17 | /** |
||
18 | * @var |
||
19 | */ |
||
20 | protected $name; |
||
21 | |||
22 | /** |
||
23 | * @var \Illuminate\Foundation\Application |
||
24 | */ |
||
25 | protected $app; |
||
26 | |||
27 | protected $title; |
||
28 | |||
29 | /** |
||
30 | * @var mixed|\Sco\Admin\Contracts\RepositoryInterface |
||
31 | */ |
||
32 | protected $repository; |
||
33 | |||
34 | /** |
||
35 | * @var \Illuminate\Database\Eloquent\Model |
||
36 | */ |
||
37 | protected $model; |
||
38 | |||
39 | protected static $booted = []; |
||
40 | |||
41 | /** |
||
42 | * @var \Illuminate\Contracts\Events\Dispatcher |
||
43 | */ |
||
44 | protected static $dispatcher; |
||
45 | |||
46 | /** |
||
47 | * @var string |
||
48 | */ |
||
49 | protected $permissionObserver; |
||
50 | |||
51 | protected $permissions; |
||
52 | |||
53 | protected $permissionMethods = [ |
||
54 | 'view', 'create', 'edit', |
||
55 | 'delete', 'destroy', 'restore', |
||
56 | ]; |
||
57 | |||
58 | public function __construct(Application $app, $modelClass) |
||
74 | |||
75 | protected function setDefaultName() |
||
79 | |||
80 | protected function getModelClassName() |
||
84 | |||
85 | public function getName() |
||
89 | |||
90 | public function getTitle() |
||
94 | |||
95 | public function getModel() |
||
99 | |||
100 | public function getRepository() |
||
104 | |||
105 | public function get() |
||
115 | |||
116 | |||
117 | /** |
||
118 | * {@inheritdoc} |
||
119 | */ |
||
120 | public function getConfigs() |
||
130 | |||
131 | /** |
||
132 | * @return \Sco\Admin\Contracts\ViewInterface |
||
133 | */ |
||
134 | protected function fireView() |
||
143 | |||
144 | protected function bootIfNotBooted() |
||
156 | |||
157 | public function boot() |
||
161 | |||
162 | public function isView() |
||
166 | |||
167 | public function isCreate() |
||
171 | |||
172 | public function isEdit() |
||
176 | |||
177 | public function isDelete() |
||
181 | |||
182 | public function isDestroy() |
||
186 | |||
187 | public function isRestore() |
||
191 | |||
192 | protected function isRestorableModel() |
||
196 | |||
197 | public function registerObserver($class = null) |
||
211 | |||
212 | public function registerPermission($permission, $callback) |
||
216 | |||
217 | public function can($permission) |
||
224 | |||
225 | public function getPermissions() |
||
238 | } |
||
239 |
PHP Analyzer performs a side-effects analysis of your code. A side-effect is basically anything that might be visible after the scope of the method is left.
Let’s take a look at an example:
If we look at the
getEmail()
method, we can see that it has no side-effect. Whether you call this method or not, no future calls to other methods are affected by this. As such code as the following is useless:On the hand, if we look at the
setEmail()
, this method _has_ side-effects. In the following case, we could not remove the method call: