These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | declare(strict_types=1); |
||
4 | |||
5 | /* |
||
6 | * The MIT License (MIT) |
||
7 | * |
||
8 | * Copyright (c) 2014-2018 Spomky-Labs |
||
9 | * |
||
10 | * This software may be modified and distributed under the terms |
||
11 | * of the MIT license. See the LICENSE file for details. |
||
12 | */ |
||
13 | |||
14 | namespace OAuth2Framework\Component\OpenIdConnect\UserInfo\Claim; |
||
15 | |||
16 | use OAuth2Framework\Component\Core\UserAccount\AuthenticationContextClassReferenceSupport; |
||
17 | use OAuth2Framework\Component\Core\UserAccount\UserAccount; |
||
18 | use OAuth2Framework\Component\Core\UserAccount\UserAccountManager; |
||
19 | |||
20 | final class AuthenticationContextClassReference implements Claim |
||
21 | { |
||
22 | private const CLAIM_NAME = 'acr'; |
||
23 | |||
24 | /** |
||
25 | * @var UserAccountManager|AuthenticationContextClassReferenceSupport |
||
26 | */ |
||
27 | private $userAccountManager; |
||
28 | |||
29 | public function __construct(UserAccountManager $userAccountManager) |
||
30 | { |
||
31 | $this->userAccountManager = $userAccountManager; |
||
32 | } |
||
33 | |||
34 | public function name(): string |
||
35 | { |
||
36 | return self::CLAIM_NAME; |
||
37 | } |
||
38 | |||
39 | public function isAvailableForUserAccount(UserAccount $userAccount, ?string $claimLocale): bool |
||
40 | { |
||
41 | if (null === $this->userAccountManager || !$this->userAccountManager instanceof AuthenticationContextClassReferenceSupport) { |
||
42 | return false; |
||
43 | } |
||
44 | |||
45 | return null !== $this->userAccountManager->getAuthenticationContextClassReferenceFor($userAccount); |
||
46 | } |
||
47 | |||
48 | public function getForUserAccount(UserAccount $userAccount, ?string $claimLocale) |
||
49 | { |
||
50 | return $this->userAccountManager->getAuthenticationContextClassReferenceFor($userAccount); |
||
0 ignored issues
–
show
|
|||
51 | } |
||
52 | } |
||
53 |
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: