当前位置: 首页>>代码示例>>PHP>>正文


PHP ArrayIterator类代码示例

本文整理汇总了PHP中ArrayIterator的典型用法代码示例。如果您正苦于以下问题:PHP ArrayIterator类的具体用法?PHP ArrayIterator怎么用?PHP ArrayIterator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ArrayIterator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: queryByIC

 /**
  *
  *@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;
 }
开发者ID:vanckruz,项目名称:draftReports,代码行数:37,代码来源:model_representante.php

示例2: testCases

 /**
  * @dataProvider provideCases
  */
 function testCases(array $insert, $limit, array $expect)
 {
     $iterator = new ArrayIterator($insert);
     $limited = $iterator->limit($limit);
     $this->assertCount(count($expect), $limited);
     $this->assertEquals($expect, $limited->toArray());
 }
开发者ID:RadekDvorak,项目名称:Ardent,代码行数:10,代码来源:LimitingIteratorTest.php

示例3: testCases

 /**
  * @dataProvider provideCases
  */
 function testCases(array $insert, callable $map, array $expect)
 {
     $iterator = new ArrayIterator($insert);
     $mapped = $iterator->map($map);
     $this->assertCount(count($expect), $mapped);
     $this->assertEquals($expect, $mapped->toArray());
 }
开发者ID:RadekDvorak,项目名称:Ardent,代码行数:10,代码来源:MappingIteratorTest.php

示例4: execute

 public function execute(InputInterface $input, OutputInterface $output)
 {
     $configuration = new Configuration(file_get_contents(__DIR__ . '/../../../config/config.json'));
     $resolver = new SpawnResolver($configuration, CpuInfo::detect());
     $factory = new Factory();
     $classname = $resolver->getClassName();
     if ($input->getOption('verbose')) {
         $outputLogger = new StreamHandler('php://stdout');
     } else {
         $outputLogger = new NullHandler();
     }
     $workers = new \ArrayIterator();
     for ($i = 1; $i <= $resolver->getSpawnQuantity(); $i++) {
         $output->write("Launching Worker <info>{$i}</info> ...");
         $logger = new Logger('Worker-' . $i);
         $logger->pushHandler($outputLogger);
         $logger->pushHandler(new RotatingFileHandler(__DIR__ . '/../../../logs/worker-' . $i . '.logs', 3));
         $worker = new Worker('Worker-' . $i, new \GearmanWorker(), $logger);
         foreach ($configuration['gearman-servers'] as $server) {
             $worker->addServer($server['host'], $server['port']);
         }
         $worker->setFunction(new $classname($configuration, $logger, $factory));
         $workers->append($worker);
         $output->writeln("Success !");
     }
     $manager = new ProcessManager(new EventDispatcher());
     $manager->process($workers, function (Worker $worker) {
         $worker->run();
     });
 }
开发者ID:nlegoff,项目名称:Worker,代码行数:30,代码来源:RunWorkers.php

示例5: processStatesItr

 public function processStatesItr(ArrayIterator $statesItr)
 {
     // ArrayIterator
     for ($statesItr; $statesItr->valid(); $statesItr->next()) {
         echo $statesItr->key() . ' : ' . $statesItr->current() . PHP_EOL;
     }
 }
开发者ID:jestintab,项目名称:zendphp,代码行数:7,代码来源:typehinting_exm1.php

示例6: _buildTree

 /**
  * 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;
 }
开发者ID:postmatic,项目名称:beta-dist,代码行数:44,代码来源:Parser.php

示例7: usu5_base_filename

/**
 * 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);
}
开发者ID:digideskio,项目名称:oscmax2,代码行数:28,代码来源:application_top.php

示例8: matchesList

 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);
 }
开发者ID:fcm,项目名称:GovernorFramework,代码行数:29,代码来源:SequenceMatcher.php

示例9: setUp

    public function setUp()
    {
        $data = <<<ENDXML
        <permcheck>
            <excludes>
                <file>excluded/file5.txt</file>
                <dir>excluded2</dir>
            </excludes>
            <executables>
                <file>file1.sh</file>
                <file>file3.sh</file>
            </executables>
        </permcheck>
ENDXML;
        $this->config = \Mockery::mock(new Config());
        $this->loader = \Mockery::mock(new XmlLoader($data, $this->config));
        $this->fileSystem = \Mockery::mock(new Filesystem($this->config, '/does/not/exist'));
        $files = new \ArrayIterator();
        $mocks = array('/does/not/exist/file1.sh' => array(true, false), '/does/not/exist/file2.txt' => array(false, false), '/does/not/exist/file3.sh' => array(false, false), '/does/not/exist/file4.txt' => array(true, false), '/does/not/exist/excluded/file5.txt' => array(true, false), '/does/not/exist/excluded2/file6.sh' => array(false, false), '/does/not/exist/symlink' => array(true, true));
        foreach ($mocks as $file => $properties) {
            /** @var MockInterface|\SplFileInfo $file */
            $file = \Mockery::mock(new \SplFileInfo($file));
            $file->shouldReceive('getName')->andReturn($file);
            $file->shouldReceive('isExecutable')->andReturn($properties[0]);
            $file->shouldReceive('isLink')->andReturn($properties[1]);
            $files->append($file);
        }
        $this->fileSystem->shouldReceive('getFiles')->andReturn($files);
        $this->messageBag = \Mockery::mock(new Bag());
        $this->reporter = \Mockery::mock(new XmlReporter());
        $this->permCheck = new PermCheck($this->loader, $this->config, $this->fileSystem, $this->messageBag, $this->reporter, '/does/not/exist');
    }
开发者ID:eXistenZNL,项目名称:PermCheck,代码行数:32,代码来源:PermCheckTest.php

示例10: find

 /**
  * @param string $collection
  * @param array  $query
  *
  * @return \Iterator
  */
 public function find($collection, array $query = [])
 {
     $cursor = $this->getDatabase()->selectCollection($collection)->find($query);
     $iterator = new \ArrayIterator($cursor);
     $iterator->rewind();
     return $iterator;
 }
开发者ID:respect,项目名称:structural,代码行数:13,代码来源:MongoDbDriver.php

示例11: _buildTree

 /**
  * Helper method for recursively building a parse tree.
  *
  * @param \ArrayIterator $tokens Stream of tokens
  *
  * @throws \LogicException when nesting errors or mismatched section tags
  * are encountered.
  * @return array Token parse tree
  *
  */
 private function _buildTree(\ArrayIterator $tokens)
 {
     $stack = array();
     do {
         $token = $tokens->current();
         $tokens->next();
         if ($token !== null) {
             switch ($token[Tokenizer::TYPE]) {
                 case Tokenizer::T_END_SECTION:
                     $newNodes = array();
                     do {
                         $result = array_pop($stack);
                         if ($result === null) {
                             throw new \LogicException('Unexpected closing tag: /' . $token[Tokenizer::NAME]);
                         }
                         if (!array_key_exists(Tokenizer::NODES, $result) && isset($result[Tokenizer::NAME]) && $result[Tokenizer::NAME] == $token[Tokenizer::NAME]) {
                             $result[Tokenizer::NODES] = $newNodes;
                             $result[Tokenizer::END] = $token[Tokenizer::INDEX];
                             array_push($stack, $result);
                             break;
                         } else {
                             array_unshift($newNodes, $result);
                         }
                     } while (true);
                     // There is no break here, since we need the end token to handle the whitespace trim
                 // There is no break here, since we need the end token to handle the whitespace trim
                 default:
                     array_push($stack, $token);
             }
         }
     } while ($tokens->valid());
     return $stack;
 }
开发者ID:lrenhrda,项目名称:patternlab-php,代码行数:43,代码来源:Parser.php

示例12: solveIntermediateOperationChain

 /**
  * @param \Iterator $operatorChain
  * @param \Iterator $input
  *
  * @return \ArrayIterator
  */
 private function solveIntermediateOperationChain(\Iterator $operatorChain, \Iterator $input)
 {
     $results = new \ArrayIterator();
     $input->rewind();
     $continueWIthNextItem = true;
     while ($input->valid() && $continueWIthNextItem) {
         $result = $input->current();
         $useResult = true;
         // do the whole intermediate operation chain for the current input
         $operatorChain->rewind();
         while ($operatorChain->valid() && $useResult) {
             /** @var IntermediateOperationInterface $current */
             $current = $operatorChain->current();
             // apply intermediate operations
             $result = $current->apply($result, $input->key(), $useResult, $returnedCanContinue);
             // track the continuation flags
             $continueWIthNextItem = $continueWIthNextItem && $returnedCanContinue;
             // iterate
             $operatorChain->next();
         }
         if ($useResult) {
             $results->append($result);
         }
         // goto next item
         $input->next();
     }
     return $results;
 }
开发者ID:peekandpoke,项目名称:psi,代码行数:34,代码来源:DefaultOperationChainSolver.php

示例13: smartmobileFolderTree

 /**
  * AJAX action: Check access rights for creation of a submailbox.
  *
  * Variables used:
  *   - all: (integer) If 1, return all mailboxes. Otherwise, return only
  *          INBOX, special mailboxes, and polled mailboxes.
  *
  * @return string  HTML to use for the folder tree.
  */
 public function smartmobileFolderTree()
 {
     $ftree = $GLOBALS['injector']->getInstance('IMP_Ftree');
     /* Poll all mailboxes on initial display. */
     $this->_base->queue->poll($ftree->poll->getPollList(), true);
     $iterator = new AppendIterator();
     /* Add special mailboxes explicitly. INBOX should appear first. */
     $special = new ArrayIterator();
     $special->append($ftree['INBOX']);
     foreach (IMP_Mailbox::getSpecialMailboxesSort() as $val) {
         if (isset($ftree[$val])) {
             $special->append($ftree[$val]);
         }
     }
     $iterator->append($special);
     /* Now add polled mailboxes. */
     $filter = new IMP_Ftree_IteratorFilter($ftree);
     $filter->add(array($filter::CONTAINERS, $filter::REMOTE, $filter::SPECIALMBOXES));
     if (!$this->vars->all) {
         $filter->add($filter::POLLED);
     }
     $filter->mboxes = array('INBOX');
     $iterator->append($filter);
     return $ftree->createTree($this->vars->all ? 'smobile_folders_all' : 'smobile_folders', array('iterator' => $iterator, 'render_type' => 'IMP_Tree_Jquerymobile'))->getTree(true);
 }
开发者ID:horde,项目名称:horde,代码行数:34,代码来源:Smartmobile.php

示例14: __construct

 /**
  * Default constructor to load the iterator. Override the parent
  * LimitIterator as we don't want to return 
  *
  * @access	public
  * @param	ArrayIterator	$it
  */
 public function __construct(ArrayIterator $it, $page = 1, $limit = 10)
 {
     $this->_it = $it;
     $this->_count = $it->count();
     $this->setCurrentPage($page);
     $this->setItemsPerPage($limit);
 }
开发者ID:pixlr,项目名称:ZCE-PHP-Cert,代码行数:14,代码来源:limit-iterator.php

示例15: printer

 function printer(ArrayIterator $iterator){
     while($iterator->valid()){
         print_r($iterator->current());
         echo "<br /><br />";
         $iterator->next();
     }
 }
开发者ID:raigons,项目名称:bureauinteligencia,代码行数:7,代码来源:testDatatoExcel.php


注:本文中的ArrayIterator类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。