1 | <?php |
||
14 | class Authorization implements MiddlewareInterface |
||
15 | { |
||
16 | /** |
||
17 | * Slim App |
||
18 | * |
||
19 | * @var Slim\App |
||
20 | */ |
||
21 | private $slim; |
||
22 | |||
23 | /** |
||
24 | * OAuth2 Server |
||
25 | * |
||
26 | * @var OAuth2\Server |
||
27 | */ |
||
28 | private $server; |
||
29 | |||
30 | /** |
||
31 | * Array of scopes required for authorization. |
||
32 | * |
||
33 | * @var array |
||
34 | */ |
||
35 | private $scopes; |
||
36 | |||
37 | /** |
||
38 | * Create a new instance of the Authroization middleware. |
||
39 | * |
||
40 | * @param Slim\App $slim The slim framework application instance. |
||
41 | * @param OAuth2\Server $server The configured OAuth2 server. |
||
42 | * @param array $scopes Scopes required for authorization. $scopes can be given as an array of arrays. OR |
||
43 | * logic will use with each grouping. Example: |
||
44 | * Given ['superUser', ['basicUser', 'aPermission']], the request will be verified if |
||
45 | * the request token has 'superUser' scope OR 'basicUser' and 'aPermission' as its |
||
46 | * scope. |
||
47 | */ |
||
48 | public function __construct(Slim\App $slim, OAuth2\Server $server, array $scopes = []) |
||
54 | |||
55 | /** |
||
56 | * Execute this middleware. |
||
57 | * |
||
58 | * @param ServerRequestInterface $request The PSR7 request. |
||
59 | * @param ResponseInterface $response The PSR7 response. |
||
60 | * @param callable $next The Next middleware. |
||
61 | * |
||
62 | * @return Slim\Http\Response |
||
63 | */ |
||
64 | public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $next) |
||
86 | |||
87 | /** |
||
88 | * Returns a callable function to be used as a authorization middleware with a specified scope. |
||
89 | * |
||
90 | * @param array $scopes Scopes require for authorization. |
||
91 | * |
||
92 | * @return Authorization |
||
93 | */ |
||
94 | public function withRequiredScope(array $scopes) |
||
100 | } |
||
101 |
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: