1 | <?php |
||
27 | class Permission extends MiddlewareAbstract |
||
28 | { |
||
29 | /** |
||
30 | * List of permissions that can be accessed by public users. |
||
31 | * |
||
32 | * @var array |
||
33 | */ |
||
34 | protected $publicAccess = [ |
||
35 | 'issue-view', |
||
36 | ]; |
||
37 | |||
38 | /** |
||
39 | * Ordered list of contexts. |
||
40 | * |
||
41 | * @var array |
||
42 | */ |
||
43 | protected $contexts = [ |
||
44 | 'comment', |
||
45 | 'attachment', |
||
46 | 'issue', |
||
47 | 'project', |
||
48 | ]; |
||
49 | |||
50 | /** |
||
51 | * Handle an incoming request. |
||
52 | * |
||
53 | * @param Request $request |
||
54 | * @param \Closure $next |
||
55 | * |
||
56 | * @return mixed |
||
57 | */ |
||
58 | public function handle(Request $request, Closure $next) |
||
69 | |||
70 | /** |
||
71 | * Whether or not the current context is in public project. |
||
72 | * |
||
73 | * @param Request $request |
||
74 | * @param string $permission |
||
75 | * |
||
76 | * @return bool |
||
77 | 44 | */ |
|
78 | protected function isInPublicProjectContext(Request $request, $permission) |
||
88 | |||
89 | /** |
||
90 | * Whether or not the user can access the current context. |
||
91 | * |
||
92 | * @param Request $request |
||
93 | * @param string $permission |
||
94 | * |
||
95 | * @return bool |
||
96 | */ |
||
97 | 44 | protected function canAccess(Request $request, $permission) |
|
107 | |||
108 | /** |
||
109 | * Whether or not the user has a valid permission in current context |
||
110 | * e.g. can access the issue or the project. |
||
111 | * |
||
112 | * @param User $user |
||
113 | * @param Route $route |
||
114 | * @param string $permission |
||
115 | * |
||
116 | 44 | * @return bool |
|
117 | */ |
||
118 | 44 | public function canAccessContext(User $user, Route $route, $permission) |
|
134 | |||
135 | /** |
||
136 | 41 | * Return the model object of the current context. |
|
137 | 36 | * We check the lowest ( Comment ) first, to the highest ( Project ). |
|
138 | * |
||
139 | * @param Route $route |
||
140 | * |
||
141 | 10 | * @return ModelAbstract|null |
|
142 | 10 | */ |
|
143 | protected function getCurrentContext(Route $route) |
||
154 | |||
155 | /** |
||
156 | * Returns the permission defined in route action. |
||
157 | * |
||
158 | 10 | * @param Request $request |
|
159 | * |
||
160 | 10 | * @return mixed |
|
161 | 10 | */ |
|
162 | 10 | protected function getPermission(Request $request) |
|
168 | } |
||
169 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: