1 | <?php |
||
29 | class JavascriptWebToken extends AbstractToken |
||
30 | { |
||
31 | /** |
||
32 | * The token. |
||
33 | * |
||
34 | * @var string |
||
35 | */ |
||
36 | private $token; |
||
37 | |||
38 | /** |
||
39 | * The provider key. |
||
40 | * |
||
41 | * @var string |
||
42 | */ |
||
43 | private $providerKey; |
||
44 | |||
45 | /** |
||
46 | * Constructor. |
||
47 | * |
||
48 | * @param string $token The user credentials |
||
49 | * |
||
50 | * @param string $providerKey The provider key |
||
51 | * |
||
52 | * @param string|object $user The user |
||
53 | * |
||
54 | * @param RoleInterface[]|string[] $roles An array of roles |
||
55 | * |
||
56 | * @throws \InvalidArgumentException When the provider key is empty. |
||
57 | */ |
||
58 | public function __construct($token, $providerKey, $user = 'anon.', array $roles = []) |
||
74 | |||
75 | /** |
||
76 | * Returns the provider key. |
||
77 | * |
||
78 | * @return string The provider key |
||
79 | */ |
||
80 | public function getProviderKey() |
||
84 | |||
85 | /** |
||
86 | * {@inheritdoc} |
||
87 | */ |
||
88 | public function getCredentials() |
||
92 | |||
93 | /** |
||
94 | * {@inheritdoc} |
||
95 | */ |
||
96 | public function eraseCredentials() |
||
102 | |||
103 | /** |
||
104 | * {@inheritdoc} |
||
105 | */ |
||
106 | public function serialize() |
||
110 | |||
111 | /** |
||
112 | * {@inheritdoc} |
||
113 | */ |
||
114 | public function unserialize($str) |
||
119 | } |
||
120 |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)
or! empty(...)
instead.