1 | <?php declare(strict_types=1); |
||
29 | class Auth implements AuthInterface |
||
30 | { |
||
31 | /** |
||
32 | * Tmdb object |
||
33 | * @var TmdbInterface |
||
34 | */ |
||
35 | private $tmdb = null; |
||
36 | /** |
||
37 | * Logger object |
||
38 | * @var \Psr\Log\LoggerInterface |
||
39 | */ |
||
40 | private $logger = null; |
||
41 | /** |
||
42 | * Request token |
||
43 | * @var string |
||
44 | */ |
||
45 | private $request_token = null; |
||
46 | /** |
||
47 | * Expiration date of request token |
||
48 | * @var \DateTime |
||
49 | */ |
||
50 | private $request_token_expiration; |
||
51 | /** |
||
52 | * Session Id |
||
53 | * @var string |
||
54 | */ |
||
55 | private $session_id = null; |
||
56 | |||
57 | /** |
||
58 | * Constructor |
||
59 | * @param TmdbInterface $tmdb |
||
60 | */ |
||
61 | 43 | public function __construct(TmdbInterface $tmdb) |
|
66 | |||
67 | /** |
||
68 | * Connect and valid request token |
||
69 | * @param string $request_token |
||
70 | * @param string|null $redirect_url Redirection url after connection (optional) |
||
71 | * @return bool |
||
72 | */ |
||
73 | 2 | public function connect(string $request_token, ?string $redirect_url = null) : bool |
|
85 | |||
86 | /** |
||
87 | * Get a new request token |
||
88 | * @return string |
||
89 | */ |
||
90 | 2 | public function getRequestToken() : string |
|
102 | |||
103 | /** |
||
104 | * Create a new session Auth |
||
105 | * @param string $request_token |
||
106 | * @return string |
||
107 | */ |
||
108 | 38 | public function createSession(string $request_token) : string |
|
118 | |||
119 | /** |
||
120 | * Magical getter |
||
121 | * @param string $name Name of the variable to get |
||
122 | * @return mixed Value of the variable getted |
||
123 | */ |
||
124 | 2 | public function __get(string $name) |
|
134 | } |
||
135 |
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.
For example, imagine you have a variable
$accountId
that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to theid
property of an instance of theAccount
class. This class holds a proper account, so the id value must no longer be false.Either this assignment is in error or a type check should be added for that assignment.