1 | <?php |
||
18 | final class CsvReader |
||
19 | { |
||
20 | /** |
||
21 | * @var resource |
||
22 | */ |
||
23 | private $stream; |
||
24 | |||
25 | /** |
||
26 | * @var string |
||
27 | */ |
||
28 | private $delimiter; |
||
29 | |||
30 | /** |
||
31 | * @var string |
||
32 | */ |
||
33 | private $enclosure; |
||
34 | |||
35 | /** |
||
36 | * @var string |
||
37 | */ |
||
38 | private $escape; |
||
39 | |||
40 | /** |
||
41 | * @var string |
||
42 | */ |
||
43 | private $encoding; |
||
44 | |||
45 | /** |
||
46 | * @var int |
||
47 | */ |
||
48 | private $fetchRowLineCounter = 0; |
||
49 | |||
50 | /** |
||
51 | * @var array |
||
52 | */ |
||
53 | private $fetchRowKeys = array(); |
||
54 | |||
55 | /** |
||
56 | * @param resource $stream |
||
57 | * @param string $encoding |
||
58 | * @param string $delimiter |
||
59 | * @param string $enclosure |
||
60 | * @param string $escape |
||
61 | * @throws Exception |
||
62 | */ |
||
63 | public function __construct($stream, $encoding = 'UTF-8', $delimiter = ',', $enclosure = '"', $escape = '\\') |
||
74 | |||
75 | /** |
||
76 | * @return array |
||
77 | */ |
||
78 | public function fetchAll() |
||
88 | |||
89 | /** |
||
90 | * @param array $keys If not empty, use as array keys. Otherwise read keys |
||
91 | * from first line of input data |
||
92 | * @return array |
||
93 | * @throws Exception |
||
94 | */ |
||
95 | public function fetchAllAssoc(array $keys = array()) |
||
123 | |||
124 | /** |
||
125 | * @param array $keys |
||
126 | * @return array|bool |
||
127 | */ |
||
128 | public function fetchAssoc(array $keys = array()) |
||
153 | |||
154 | /** |
||
155 | * @return array|bool |
||
156 | */ |
||
157 | private function getNextRow() |
||
169 | |||
170 | /** |
||
171 | * @throws Exception |
||
172 | */ |
||
173 | private function assertStream() |
||
183 | |||
184 | /** |
||
185 | * @param array $elements |
||
186 | * @return array |
||
187 | */ |
||
188 | private function negotiateEncoding(array $elements) |
||
199 | } |
||
200 |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.