1 | <?php |
||
21 | class ReflectionFile |
||
22 | { |
||
23 | |||
24 | /** |
||
25 | * Name of the file for reflectino |
||
26 | * |
||
27 | * @var string |
||
28 | */ |
||
29 | protected $fileName; |
||
30 | |||
31 | /** |
||
32 | * List of namespaces in the file |
||
33 | * |
||
34 | * @var ReflectionFileNamespace[]|array |
||
35 | */ |
||
36 | protected $fileNamespaces; |
||
37 | |||
38 | /** |
||
39 | * Top-level nodes for the file |
||
40 | * |
||
41 | * @var Node[] |
||
42 | */ |
||
43 | private $topLevelNodes; |
||
44 | |||
45 | /** |
||
46 | * ReflectionFile constructor. |
||
47 | * |
||
48 | * @param string $fileName Name of the file to reflect |
||
49 | * @param null|array|Node[] $topLevelNodes Optional corresponding list of AST nodes for that file |
||
50 | */ |
||
51 | 3010 | public function __construct($fileName, $topLevelNodes = null) |
|
57 | |||
58 | /** |
||
59 | * Returns a namespace from the file or false if no such a namespace |
||
60 | * |
||
61 | * @param string $namespaceName |
||
62 | * |
||
63 | * @return bool|ReflectionFileNamespace |
||
64 | */ |
||
65 | 2995 | public function getFileNamespace($namespaceName) |
|
73 | |||
74 | /** |
||
75 | * Gets the list of namespaces in the file |
||
76 | * |
||
77 | * @return array|ReflectionFileNamespace[] |
||
78 | */ |
||
79 | 3003 | public function getFileNamespaces() |
|
87 | |||
88 | /** |
||
89 | * Returns the name of current reflected file |
||
90 | * |
||
91 | * @return string |
||
92 | */ |
||
93 | 1 | public function getName() |
|
97 | |||
98 | /** |
||
99 | * Returns the presence of namespace in the file |
||
100 | * |
||
101 | * @param string $namespaceName Namespace to check |
||
102 | * |
||
103 | * @return bool |
||
104 | */ |
||
105 | 2996 | public function hasFileNamespace($namespaceName) |
|
111 | |||
112 | /** |
||
113 | * Checks if the current file is in strict mode |
||
114 | * |
||
115 | * @return bool |
||
116 | */ |
||
117 | 4 | public function isStrictMode() |
|
132 | |||
133 | /** |
||
134 | * Searches for file namespaces in the given AST |
||
135 | * |
||
136 | * @return array|ReflectionFileNamespace[] |
||
137 | */ |
||
138 | 3003 | private function findFileNamespaces() |
|
157 | } |
||
158 |
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.