1 | <?php |
||
34 | class Php extends AbstractFileParser |
||
35 | { |
||
36 | /** |
||
37 | * Loads a PHP file and gets its contents as an array. |
||
38 | * |
||
39 | * @param string $path File path |
||
40 | * |
||
41 | * @throws ParseException If the PHP file throws an exception |
||
42 | * @throws UnsupportedFormatException If the PHP file does not return an array |
||
43 | * |
||
44 | * @return array The parsed data |
||
45 | * |
||
46 | * @since 0.1.0 |
||
47 | */ |
||
48 | 12 | public function parse($path) |
|
79 | |||
80 | /** |
||
81 | * {@inheritdoc} |
||
82 | * |
||
83 | * @return array Supported extensions |
||
84 | * |
||
85 | * @since 0.1.0 |
||
86 | */ |
||
87 | 3 | public function getSupportedFileExtensions() |
|
91 | |||
92 | /** |
||
93 | * Loads in the given file and parses it. |
||
94 | * |
||
95 | * @param string|bool|null $file File to load |
||
96 | * |
||
97 | * @return array The parsed file data |
||
98 | * |
||
99 | * @since 0.2.4 |
||
100 | * @codeCoverageIgnore |
||
101 | */ |
||
102 | protected function loadFile($file = null) |
||
108 | |||
109 | /** |
||
110 | * Returns the formatted configuration file contents. |
||
111 | * |
||
112 | * @param array $contents configuration array |
||
113 | * |
||
114 | * @return string formatted configuration file contents |
||
115 | * |
||
116 | * @since 0.2.4 |
||
117 | * @codeCoverageIgnore |
||
118 | */ |
||
119 | protected function exportFormat($contents = null) |
||
125 | |||
126 | /** |
||
127 | * __toString. |
||
128 | * |
||
129 | * @return string |
||
130 | * @since 0.1.2 |
||
131 | * @codeCoverageIgnore |
||
132 | */ |
||
133 | public function __toString() |
||
137 | } |
||
138 | |||
140 |
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.