1 | <?php |
||
14 | class ApiKeyAuthenticator implements SimplePreAuthenticatorInterface |
||
15 | { |
||
16 | /** |
||
17 | * @var ManagerRegistry |
||
18 | */ |
||
19 | private $registry; |
||
20 | |||
21 | /** |
||
22 | * @param ManagerRegistry $registry |
||
23 | */ |
||
24 | public function __construct(ManagerRegistry $registry) |
||
25 | { |
||
26 | $this->registry = $registry; |
||
27 | } |
||
28 | |||
29 | /** |
||
30 | * @param Request $request |
||
31 | * @param string $providerKey |
||
32 | * @return PreAuthenticatedToken |
||
33 | */ |
||
34 | public function createToken(Request $request, $providerKey) |
||
35 | { |
||
36 | $apiKey = $request->headers->get('API-Key-Token'); |
||
37 | if (!$apiKey) { |
||
38 | throw new BadCredentialsException(); |
||
39 | } |
||
40 | |||
41 | return new PreAuthenticatedToken( |
||
42 | 'customer', |
||
43 | $apiKey, |
||
44 | $providerKey |
||
45 | ); |
||
46 | } |
||
47 | |||
48 | /** |
||
49 | * @param TokenInterface $token |
||
50 | * @param string $providerKey |
||
51 | * @return bool |
||
52 | */ |
||
53 | public function supportsToken(TokenInterface $token, $providerKey) |
||
54 | { |
||
55 | return $token instanceof PreAuthenticatedToken && $token->getProviderKey() === $providerKey; |
||
56 | } |
||
57 | |||
58 | /** |
||
59 | * @param TokenInterface $token |
||
60 | * @param UserProviderInterface $userProvider |
||
61 | * @param string $providerKey |
||
62 | * @return PreAuthenticatedToken |
||
63 | */ |
||
64 | public function authenticateToken(TokenInterface $token, UserProviderInterface $userProvider, $providerKey) |
||
95 | } |
||
96 |
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: