1 | <?php |
||
49 | class DataReader extends Object implements Iterator, Countable |
||
50 | { |
||
51 | /** |
||
52 | * @var array data |
||
53 | */ |
||
54 | private $entries = []; |
||
55 | /** |
||
56 | * @var Connection |
||
57 | */ |
||
58 | private $_conn; |
||
59 | private $_closed = false; |
||
60 | private $_row; |
||
61 | private $_index = -1; |
||
62 | private $_count = 0; |
||
63 | private $_results; |
||
64 | |||
65 | |||
66 | /** |
||
67 | * Constructor. |
||
68 | * @param Connection $conn connection interact with result |
||
69 | * @param resource[]|resource $results result array of search in ldap directory |
||
70 | * @param array $config name-value pairs that will be used to initialize the object properties |
||
71 | */ |
||
72 | public function __construct(Connection $conn, $results, $config = []) |
||
90 | |||
91 | public function __destruct() |
||
95 | |||
96 | /** |
||
97 | * |
||
98 | * @param resource $result |
||
99 | * @return void |
||
100 | */ |
||
101 | protected function setEntries($result){ |
||
121 | |||
122 | /** |
||
123 | * Get all entries as an array |
||
124 | * @return array |
||
125 | */ |
||
126 | public function toArray() |
||
138 | |||
139 | /** |
||
140 | * Closes the reader. |
||
141 | * This frees up the resources allocated for executing this SQL statement. |
||
142 | * Read attempts after this method call are unpredictable. |
||
143 | */ |
||
144 | public function close() |
||
153 | |||
154 | /** |
||
155 | * whether the reader is closed or not. |
||
156 | * @return boolean whether the reader is closed or not. |
||
157 | */ |
||
158 | public function getIsClosed() |
||
162 | |||
163 | /** |
||
164 | * Returns the number of rows in the result set. |
||
165 | * This method is required by the Countable interface. |
||
166 | * @return integer number of entries stored in the result. |
||
167 | */ |
||
168 | public function count() |
||
172 | |||
173 | /** |
||
174 | * Resets the iterator to the initial state. |
||
175 | * This method is required by the interface [[\Iterator]]. |
||
176 | * @throws InvalidCallException if this method is invoked twice |
||
177 | */ |
||
178 | public function rewind() |
||
189 | |||
190 | /** |
||
191 | * Returns the result of the current item. |
||
192 | * This method is required by the interface [[\Iterator]]. |
||
193 | * @return string the index of the current row. |
||
194 | */ |
||
195 | public function key() |
||
199 | |||
200 | /** |
||
201 | * Returns the current row. |
||
202 | * This method is required by the interface [[\Iterator]]. |
||
203 | * @return mixed the current row. |
||
204 | */ |
||
205 | public function current() |
||
233 | |||
234 | /** |
||
235 | * Moves the internal pointer to the next row. |
||
236 | * This method is required by the interface [[\Iterator]]. |
||
237 | */ |
||
238 | public function next() |
||
245 | |||
246 | /** |
||
247 | * Returns whether there is a row of resource at current position. |
||
248 | * This method is required by the interface [[\Iterator]]. |
||
249 | * @return boolean whether there is a row of data at current position. |
||
250 | */ |
||
251 | public function valid() |
||
255 | } |
||
256 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.