@@ -52,7 +52,7 @@ class JwtAuthenticate extends BaseAuthenticate
5252 /**
5353 * Exception.
5454 *
55- * @var \Exception
55+ * @var \Throwable|null
5656 */
5757 protected $ _error ;
5858
@@ -115,7 +115,7 @@ public function __construct(ComponentRegistry $registry, array $config)
115115 *
116116 * @param \Cake\Http\ServerRequest $request The request object.
117117 * @param \Cake\Http\Response $response Response object.
118- * @return bool |array User record array or false on failure.
118+ * @return false |array User record array or false on failure.
119119 */
120120 public function authenticate (ServerRequest $ request , Response $ response )
121121 {
@@ -126,7 +126,7 @@ public function authenticate(ServerRequest $request, Response $response)
126126 * Get user record based on info available in JWT.
127127 *
128128 * @param \Cake\Http\ServerRequest $request Request object.
129- * @return bool |array User record array or false on failure.
129+ * @return false |array User record array or false on failure.
130130 */
131131 public function getUser (ServerRequest $ request )
132132 {
@@ -198,6 +198,7 @@ public function getToken(?ServerRequest $request = null)
198198 if (!empty ($ this ->_config ['cookie ' ])) {
199199 $ token = $ request ->getCookie ($ this ->_config ['cookie ' ]);
200200 if ($ token !== null ) {
201+ /** @psalm-suppress PossiblyInvalidCast */
201202 $ token = (string )$ token ;
202203 }
203204
@@ -207,6 +208,7 @@ public function getToken(?ServerRequest $request = null)
207208 if (!empty ($ this ->_config ['parameter ' ])) {
208209 $ token = $ request ->getQuery ($ this ->_config ['parameter ' ]);
209210 if ($ token !== null ) {
211+ /** @psalm-suppress PossiblyInvalidCast */
210212 $ token = (string )$ token ;
211213 }
212214
@@ -264,6 +266,7 @@ public function unauthenticated(ServerRequest $request, Response $response)
264266 ? $ this ->_error ->getMessage ()
265267 : $ this ->_registry ->get ('Auth ' )->getConfig ('authError ' );
266268
269+ /** @var \Throwable $exception */
267270 $ exception = new $ this ->_config ['unauthenticatedException ' ]($ message );
268271 throw $ exception ;
269272 }
0 commit comments