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 Lab404\Impersonate\Models; |
||
4 | |||
5 | use Illuminate\Database\Eloquent\Model; |
||
6 | use Lab404\Impersonate\Services\ImpersonateManager; |
||
7 | |||
8 | trait Impersonate |
||
9 | { |
||
10 | /** |
||
11 | * Return true or false if the user can impersonate an other user. |
||
12 | * |
||
13 | * @param void |
||
14 | * @return bool |
||
15 | */ |
||
16 | public function canImpersonate() |
||
17 | { |
||
18 | return true; |
||
19 | } |
||
20 | |||
21 | /** |
||
22 | * Return true or false if the user can be impersonate. |
||
23 | * |
||
24 | * @param Model $user |
||
0 ignored issues
–
show
|
|||
25 | * @return bool |
||
26 | */ |
||
27 | public function canBeImpersonated() |
||
28 | { |
||
29 | return true; |
||
30 | } |
||
31 | |||
32 | /** |
||
33 | * Impersonate the given user. |
||
34 | * |
||
35 | * @param Model $user |
||
36 | * @return bool |
||
37 | */ |
||
38 | public function impersonate(Model $user) |
||
39 | { |
||
40 | return app(ImpersonateManager::class)->take($this, $user); |
||
41 | } |
||
42 | |||
43 | /** |
||
44 | * Check if the current user is impersonated. |
||
45 | * |
||
46 | * @param void |
||
47 | * @return bool |
||
48 | */ |
||
49 | public function isImpersonated() |
||
50 | { |
||
51 | return app(ImpersonateManager::class)->isImpersonating(); |
||
52 | } |
||
53 | |||
54 | /** |
||
55 | * Leave the current impersonation. |
||
56 | * |
||
57 | * @param void |
||
58 | * @return bool |
||
59 | */ |
||
60 | public function leaveImpersonation() |
||
61 | { |
||
62 | if ($this->isImpersonated()) |
||
63 | { |
||
64 | return app(ImpersonateManager::class)->leave(); |
||
65 | } |
||
66 | } |
||
67 | } |
||
68 |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.