/** * * @param <type> $table * @param ArrayIterator $params * @return ArrayObject */ public function search($table, ArrayIterator $params) { $this->searchParams = $params; $this->join(); if ($table == "analysis") { $this->statements->remove("type_event"); } $statement = "SELECT this_.* " . $this->selectAttributes() . " FROM {$table} this_ "; $statement .= $this->join(); $i = 0; $this->searchParams->rewind(); if ($this->searchParams->count() > 0 && !$this->searchParams->offsetExists('true')) { $statement .= " WHERE "; } while ($this->searchParams->valid()) { if ($this->statements->containsKey($this->searchParams->key())) { if ($i++ > 0) { $statement .= " AND "; } $clause = $this->statements->get($this->searchParams->key()); $statement .= str_replace(":" . $this->searchParams->key(), "'" . $this->searchParams->current() . "'", $clause['where']); } $this->searchParams->next(); } return $this->getObject($statement . " ORDER BY this_.date DESC, this_.id DESC"); }
/** * Switches to alternate nicks as needed when nick collisions occur. * * @return void */ public function onResponse() { // If no alternate nick list was found, return if (empty($this->iterator)) { return; } // If the response event indicates that the nick set is in use... $code = $this->getEvent()->getCode(); if ($code == Phergie_Event_Response::ERR_NICKNAMEINUSE) { // Attempt to move to the next nick in the alternate nick list $this->iterator->next(); // If another nick is available... if ($this->iterator->valid()) { // Switch to the new nick $altNick = $this->iterator->current(); $this->doNick($altNick); // Update the connection to reflect the nick change $this->getConnection()->setNick($altNick); } else { // If no other nicks are available... // Terminate the connection $this->doQuit('All specified alternate nicks are in use'); } } }
public function next() { $this->items->next(); if (!$this->items->valid()) { $this->page++; $this->load(); } }
private function dayInfo() { $this->daysInfo = new ArrayIterator(); while ($this->days->valid()) { $day = explode(") - ", $this->days->current()); $infos = explode("/", $day[1]); $this->daysInfo->append($this->buildWeatherDayInfo($day[0], $infos)); $this->days->next(); } }
protected function assertIteratesThrough($values, $iterator) { $valuesIterator = new ArrayIterator($values); $valuesIterator->rewind(); foreach ($iterator as $key => $row) { $this->assertTrue($valuesIterator->valid()); $this->assertEquals($valuesIterator->key(), $key); $this->assertEquals($valuesIterator->current(), $row); $valuesIterator->next(); } $this->assertFalse($valuesIterator->valid()); }
/** * {@inheritDoc} */ public function proceed(CommandMessageInterface $commandProceedWith = null) { if (null !== $commandProceedWith) { $this->command = $commandProceedWith; } if ($this->chain->valid()) { $next = $this->chain->current(); $this->chain->next(); return $next->handle($this->command, $this->unitOfWork, $this); } else { return $this->handler->handle($this->command, $this->unitOfWork); } }
/** * {@inheritdoc} */ public function seek($offset) { $newIterator = new \ArrayIterator($this->baseArray); while ($newIterator->key() != $offset && $newIterator->valid()) { $newIterator->next(); } if (!$newIterator->valid()) { throw new BadOffsetException("OffsetProvider is not valid", 550); } if ($newIterator->key() != $offset) { throw new \Exception("Something went wrong", 550); } $this->arrayIterator = $newIterator; }
/** * handles lazy-loading logic * @return void */ protected function nextThing() { if (!$this->iterator->valid()) { if ($this->collection->pages == $this->currentPage) { $this->row = null; return; } else { $this->currentPage++; $this->fetch($this->currentPage); } } $this->row = $this->transformRow($this->iterator->current()); $this->cursor++; }
/** * Checks if the current position of the cache entry iterator is valid. * * @return boolean TRUE if the current position is valid, otherwise FALSE * @api */ public function valid() { if ($this->cacheEntriesIterator === null) { $this->rewind(); } return $this->cacheEntriesIterator->valid(); }
public function matchesList(array $items) { $itemIterator = new \ArrayIterator($items); $matcherIterator = new \ArrayIterator($this->getMatchers()); $currentMatcher = null; if ($matcherIterator->valid()) { $currentMatcher = $matcherIterator->current(); } while ($itemIterator->valid() && null !== $currentMatcher) { $hasMatch = $currentMatcher->matches($itemIterator->current()); if ($hasMatch) { $matcherIterator->next(); if ($matcherIterator->valid()) { $currentMatcher = $matcherIterator->current(); } else { $currentMatcher = null; } } $itemIterator->next(); } //echo sprintf("%s->%s, %s->%s\n", $itemIterator->key(), $itemIterator->count(), // $matcherIterator->key(), $matcherIterator->count()); if (null !== $currentMatcher && !$currentMatcher->matches(null)) { $this->reportFailed($currentMatcher); return false; } $matcherIterator->next(); return $this->matchRemainder($matcherIterator); }
/** * je-li v rozsahu pole * @return bool */ public function valid() { if ($this->pointer < 0) { return FALSE; } return parent::valid(); }
/** * USU5 function to return the base filename */ function usu5_base_filename() { // Probably won't get past SCRIPT_NAME unless this is reporting cgi location $base = new ArrayIterator(array('SCRIPT_NAME', 'PHP_SELF', 'REQUEST_URI', 'ORIG_PATH_INFO', 'HTTP_X_ORIGINAL_URL', 'HTTP_X_REWRITE_URL')); while ($base->valid()) { if (array_key_exists($base->current(), $_SERVER) && !empty($_SERVER[$base->current()])) { if (false !== strpos($_SERVER[$base->current()], '.php')) { // ignore processing if this script is not running in the catalog directory if (dirname($_SERVER[$base->current()]) . '/' != DIR_WS_HTTP_CATALOG) { return $_SERVER[$base->current()]; } preg_match('@[a-z0-9_]+\\.php@i', $_SERVER[$base->current()], $matches); if (is_array($matches) && array_key_exists(0, $matches) && substr($matches[0], -4, 4) == '.php' && (is_readable($matches[0]) || false !== strpos($_SERVER[$base->current()], 'ext/modules/'))) { return $matches[0]; } } } $base->next(); } // Some odd server set ups return / for SCRIPT_NAME and PHP_SELF when accessed as mysite.com (no index.php) where they usually return /index.php if ($_SERVER['SCRIPT_NAME'] == '/' || $_SERVER['PHP_SELF'] == '/') { return HTTP_SERVER; } trigger_error('USU5 could not find a valid base filename, please inform the developer.', E_USER_WARNING); }
/** * Sets the internal pointer on the next element. * * @return boolean True, if the map has a next element, false otherwise */ public function next() { if ($this->initializeIterator()) { $this->iterator->next(); } return $this->iterator->valid(); }
/** * è‡ªåŠ¨åŠ è½½ * * @param $className */ function zroneClassLoader($className) { $path = array(str_replace("\\", "/", dirname(__FILE__) . DIRECTORY_SEPARATOR . "Vendor/"), str_replace("\\", "/", dirname(__FILE__) . DIRECTORY_SEPARATOR . "FrameWork/"), str_replace("\\", "/", dirname(__FILE__) . DIRECTORY_SEPARATOR . "Application/")); if (isset($path) && is_array($path)) { $Iterator = new ArrayIterator($path); $Iterator->rewind(); $pathString = ""; while ($Iterator->valid()) { $pathString .= $Iterator->current() . ";"; if ($Iterator->key() == count($path) - 1) { $pathString = rtrim($pathString, ";"); } $Iterator->next(); } set_include_path($pathString); spl_autoload_extensions(".php, .class.php"); spl_autoload($className); } else { try { throw new Exception("<code style='color: red; font-size: 22px; display: block; text-align: center; height: 40px; line-height: 40px;'>I'm sorry, my dear! The FrameWork is Wrong……😫</code>"); } catch (Exception $e) { echo $e->getMessage(); } } }
/** * *@param $id_ciu * * **/ public function queryByIC($id_ciu) { $this->conex = DataBase::getInstance(); $stid = oci_parse($this->conex, "SELECT * FROM TBL_REPRESENTANTEEMPRESAS WHERE CLV_REPRESENTANTE=:id_ciu"); if (!$stid) { $e = oci_error($this->conex); trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR); } // Realizar la lógica de la consulta oci_bind_by_name($stid, ':id_ciu', $id_ciu); $r = oci_execute($stid); if (!$r) { $e = oci_error($stid); trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR); } $result = new RepresentanteEmpresa(); // Obtener los resultados de la consulta while ($fila = oci_fetch_array($stid, OCI_ASSOC + OCI_RETURN_NULLS)) { $it = new ArrayIterator($fila); while ($it->valid()) { $result->__SET(strtolower($it->key()), $it->current()); $it->next(); } } //Libera los recursos oci_free_statement($stid); // Cierra la conexión Oracle oci_close($this->conex); //retorna el resultado de la consulta return $result; }
/** * Assert that the given commands have been dispatched in the exact sequence provided. * * @param array $expected The commands expected to have been published on the bus * @throws GovernorAssertionError */ public function assertDispatchedEqualTo(array $expected = array()) { $actual = $this->commandBus->getDispatchedCommands(); if (count($expected) !== count($actual)) { throw new GovernorAssertionError(sprintf("Got wrong number of commands dispatched. Expected <%s>, got <%s>", count($expected), count($actual))); } $actualIterator = new \ArrayIterator($actual); $expectedIterator = new \ArrayIterator($expected); $counter = 0; while ($actualIterator->valid()) { $actualItem = $actualIterator->current(); $expectedItem = $expectedIterator->current(); if ($expectedItem instanceof CommandMessageInterface) { if ($expectedItem->getPayloadType() !== $actualItem->getPayloadType()) { throw new GovernorAssertionError(sprintf("Unexpected payload type of command at position %s (0-based). Expected <%s>, got <%s>", $counter, $expectedItem->getPayloadType(), $actualItem->getPayloadType())); } $this->assertCommandEquality($counter, $expectedItem->getPayloadType(), $actualItem->getPayload()); if ($expectedItem->getMetaData() !== $actualItem->getMetaData()) { throw new GovernorAssertionError(sprintf("Unexpected Meta Data of command at position %s (0-based). Expected <%s>, got <%s>", $counter, $expectedItem->getMetaData(), $actualItem->getMetaData())); } } else { $this->assertCommandEquality($counter, $expectedItem, $actualItem->getPayload()); } $counter++; $actualIterator->next(); $expectedIterator->next(); } }
/** * iterate the complete data collection and execute callback for each key => value pair passing the key * and the value to the callback function/method as first and second parameter. the callback must be * a valid callable that can be executed call_user_func_array * * @error 16307 * @param callable $callback expects the callback function/method * @return void */ public function each(callable $callback) { while ($this->iterator->valid()) { call_user_func_array($callback, array($this->iterator->key(), $this->iterator->current())); $this->iterator->next(); } }
public function valid() { if ($this->iterator === null) { $this->rewind(); } return $this->iterator->valid(); }
/** * *@param $id_ciu * * **/ public function getById($id_jefe) { $this->conex = DataBase::getInstance(); //Consulta SQL $consulta = "SELECT * FROM FISC_JEFE_OFICINA WHERE \n\t\t\t\t\t\tID_JEFE=:id_jefe"; $stid = oci_parse($this->conex, $consulta); if (!$stid) { $e = oci_error($this->conex); trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR); } // Realizar la lógica de la consulta oci_bind_by_name($stid, ':id_jefe', $id_jefe); $r = oci_execute($stid); if (!$r) { $e = oci_error($stid); trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR); } $result = array(); // Obtener los resultados de la consulta while ($fila = oci_fetch_array($stid, OCI_ASSOC + OCI_RETURN_NULLS)) { $it = new ArrayIterator($fila); $alm = new Denuncia(); while ($it->valid()) { $alm->__SET(strtolower($it->key()), $it->current()); $it->next(); } $result[] = $alm; } //Libera los recursos oci_free_statement($stid); // Cierra la conexión Oracle oci_close($this->conex); //retorna el resultado de la consulta return $result; }
function valid() { if ($this->limit && $this->position >= $this->limit) { return false; } return parent::valid(); }
/** * Update = $sql = "UPDATE tabla SET campo1 = ?, campo2 = ?, campo3 = ? * WHERE idcampo = ?" * $stm->bindValue(4, idValor); */ public function update($table, $data, $where, $id) { $result = null; $iterator = new ArrayIterator($data); $sql = "UPDATE {$table} SET "; while ($iterator->valid()) { $sql .= $iterator->key() . " = ?, "; $iterator->next(); } //Se elimina los dos ultimos caracteres (la coma y el espacio) $sql = substr($sql, 0, -2); $sql .= " WHERE {$where} = ?"; $stm = $this->_getDbh()->prepare($sql); $i = 1; foreach ($iterator as $param) { $stm->bindValue($i, $param); $i++; } /** * Se asigna el bindValue para el parametro $id, como no esta contemplado en los ciclos del $data, * se asigna en la posicion ($iterator->count()+1) y se le asigna el tipo de dato: PDO::PARAM_INT */ $stm->bindValue($iterator->count() + 1, $id, PDO::PARAM_INT); $result = $stm->execute(); return $result; }
/** * Helper method for recursively building a parse tree. * * @param ArrayIterator $tokens Stream of tokens * * @return array Token parse tree * * @throws LogicException when nesting errors or mismatched section tags are encountered. */ private function _buildTree(ArrayIterator $tokens) { $stack = array(); do { $token = $tokens->current(); $tokens->next(); if ($token === null) { continue; } else { switch ($token[Handlebars_Tokenizer::TYPE]) { case Handlebars_Tokenizer::T_END_SECTION: $newNodes = array(); $continue = true; do { $result = array_pop($stack); if ($result === null) { throw new LogicException('Unexpected closing tag: /' . $token[Handlebars_Tokenizer::NAME]); } if (!array_key_exists(Handlebars_Tokenizer::NODES, $result) && isset($result[Handlebars_Tokenizer::NAME]) && $result[Handlebars_Tokenizer::NAME] == $token[Handlebars_Tokenizer::NAME]) { $result[Handlebars_Tokenizer::NODES] = $newNodes; $result[Handlebars_Tokenizer::END] = $token[Handlebars_Tokenizer::INDEX]; array_push($stack, $result); break 2; } else { array_unshift($newNodes, $result); } } while (true); break; default: array_push($stack, $token); } } } while ($tokens->valid()); return $stack; }
public function getById($id) { $this->conex = DataBase::getInstance(); $stid = oci_parse($this->conex, "SELECT *\n\t\t\tFROM FISC_CIUDADANO WHERE ID_CIUDADANO=:id"); if (!$stid) { $e = oci_error($this->conex); trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR); } // Realizar la lógica de la consulta oci_bind_by_name($stid, ':id', $id); $r = oci_execute($stid); if (!$r) { $e = oci_error($stid); trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR); } // Obtener los resultados de la consulta $alm = new FiscCiudadano(); while ($fila = oci_fetch_array($stid, OCI_ASSOC + OCI_RETURN_NULLS)) { $it = new ArrayIterator($fila); while ($it->valid()) { $alm->__SET(strtolower($it->key()), $it->current()); $it->next(); } } //Libera los recursos oci_free_statement($stid); // Cierra la conexión Oracle oci_close($this->conex); //retorna el resultado de la consulta return $alm; }
public function processStatesItr(ArrayIterator $statesItr) { // ArrayIterator for ($statesItr; $statesItr->valid(); $statesItr->next()) { echo $statesItr->key() . ' : ' . $statesItr->current() . PHP_EOL; } }
function printer(ArrayIterator $iterator){ while($iterator->valid()){ print_r($iterator->current()); echo "<br /><br />"; $iterator->next(); } }
protected function assertIteratesThrough($values, $iterator) { $valuesIterator = new ArrayIterator($values); $valuesIterator->rewind(); foreach ($iterator as $key => $row) { foreach ($row as &$value) { if ($value instanceof DateTime) { $value = $value->format('Y-m-d H:i'); } } $this->assertTrue($valuesIterator->valid()); $this->assertEquals($valuesIterator->key(), $key); $this->assertEquals($valuesIterator->current(), $row); $valuesIterator->next(); } $this->assertFalse($valuesIterator->valid()); }
/** * @inheritdoc */ public function valid() { if (!$this->iterator->valid()) { $this->autoloadEnabled = false; return false; } return true; }
/** * Checks if current position is valid * * @link http://php.net/manual/en/iterator.valid.php * @return boolean The return value will be casted to boolean and then evaluated. * Returns true on success or false on failure. * @since 5.0.0 */ public function valid() { if (!$this->data->valid()) { $this->offset = $this->offset + $this->limit; $this->findData(); } return $this->data->valid(); }
public function valid() { if (!parent::valid()) { if ($this->source->valid()) { $this->append($this->transform($this->source->current())); } } return parent::valid(); }
function test($a) { $it = new ArrayIterator($a); while ($it->valid()) { var_dump($it->key()); var_dump($it->current()); $it->next(); } }