1 | <?php |
||
23 | final class TokenEndpointAuthMethodManager |
||
24 | { |
||
25 | /** |
||
26 | * @var TokenEndpointAuthMethodInterface[] |
||
27 | */ |
||
28 | private $tokenEndpointAuthMethodNames = []; |
||
29 | |||
30 | /** |
||
31 | * @var TokenEndpointAuthMethodInterface[] |
||
32 | */ |
||
33 | private $tokenEndpointAuthMethods = []; |
||
34 | |||
35 | /** |
||
36 | * @param TokenEndpointAuthMethodInterface $tokenEndpointAuthMethod |
||
37 | * |
||
38 | * @return TokenEndpointAuthMethodManager |
||
39 | */ |
||
40 | public function add(TokenEndpointAuthMethodInterface $tokenEndpointAuthMethod): TokenEndpointAuthMethodManager |
||
41 | { |
||
42 | $this->tokenEndpointAuthMethods[] = $tokenEndpointAuthMethod; |
||
43 | foreach ($tokenEndpointAuthMethod->getSupportedAuthenticationMethods() as $method_name) { |
||
44 | $this->tokenEndpointAuthMethodNames[$method_name] = $tokenEndpointAuthMethod; |
||
45 | } |
||
46 | |||
47 | return $this; |
||
48 | } |
||
49 | |||
50 | /** |
||
51 | * @return string[] |
||
52 | */ |
||
53 | public function all(): array |
||
54 | { |
||
55 | return array_keys($this->tokenEndpointAuthMethodNames); |
||
56 | } |
||
57 | |||
58 | /** |
||
59 | * @param string $tokenEndpointAuthMethod |
||
60 | * |
||
61 | * @return bool |
||
62 | */ |
||
63 | public function has(string $tokenEndpointAuthMethod): bool |
||
64 | { |
||
65 | return array_key_exists($tokenEndpointAuthMethod, $this->tokenEndpointAuthMethodNames); |
||
66 | } |
||
67 | |||
68 | /** |
||
69 | * @param string $tokenEndpointAuthMethod |
||
70 | * |
||
71 | * @throws \InvalidArgumentException |
||
72 | * |
||
73 | * @return TokenEndpointAuthMethodInterface |
||
74 | */ |
||
75 | public function get(string $tokenEndpointAuthMethod): TokenEndpointAuthMethodInterface |
||
76 | { |
||
77 | Assertion::true($this->has($tokenEndpointAuthMethod), sprintf('The token endpoint authentication method \'%s\' is not supported. Please use one of the following values: %s', $tokenEndpointAuthMethod, implode(', ', $this->all()))); |
||
78 | |||
79 | return $this->tokenEndpointAuthMethodNames[$tokenEndpointAuthMethod]; |
||
80 | } |
||
81 | |||
82 | /** |
||
83 | * @return TokenEndpointAuthMethodInterface[] |
||
84 | */ |
||
85 | public function getTokenEndpointAuthMethods(): array |
||
89 | |||
90 | /** |
||
91 | * @param ServerRequestInterface $request |
||
92 | * @param TokenEndpointAuthMethodInterface $authenticationMethod |
||
|
|||
93 | * @param mixed $clientCredentials The client credentials found in the request |
||
94 | * |
||
95 | * @throws OAuth2Exception |
||
96 | * |
||
97 | * @return null|ClientId |
||
98 | */ |
||
99 | public function findClientInformationInTheRequest(ServerRequestInterface $request, TokenEndpointAuthMethodInterface &$authenticationMethod = null, &$clientCredentials = null) |
||
126 | |||
127 | /** |
||
128 | * @param ServerRequestInterface $request |
||
129 | * @param Client $client |
||
130 | * @param TokenEndpointAuthMethodInterface $authenticationMethod |
||
131 | * @param mixed $clientCredentials |
||
132 | * |
||
133 | * @return bool |
||
134 | */ |
||
135 | public function isClientAuthenticated(ServerRequestInterface $request, Client $client, TokenEndpointAuthMethodInterface $authenticationMethod, $clientCredentials): bool |
||
148 | } |
||
149 |
This check looks for
@param
annotations where the type inferred by our type inference engine differs from the declared type.It makes a suggestion as to what type it considers more descriptive.
Most often this is a case of a parameter that can be null in addition to its declared types.