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


PHP SplStack::setIteratorMode方法代码示例

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


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

示例1: seedMiddlewareStack

 /**
  * Seed middleware stack with first callable
  *
  * @param callable $kernel The last item to run as middleware
  *
  * @throws RuntimeException if the stack is seeded more than once
  */
 protected function seedMiddlewareStack(callable $kernel = null)
 {
     if (!is_null($this->stack)) {
         throw new RuntimeException('MiddlewareStack can only be seeded once.');
     }
     if ($kernel === null) {
         $kernel = $this;
     }
     $this->stack = new SplStack();
     $this->stack->setIteratorMode(SplDoublyLinkedList::IT_MODE_LIFO | SplDoublyLinkedList::IT_MODE_KEEP);
     $this->stack[] = $kernel;
 }
开发者ID:aodkrisda,项目名称:slim-3-framework-app,代码行数:19,代码来源:MiddlewareAwareTrait.php

示例2: _validateSection

 /**
  * Validates the section record, determines the section parent and
  * the data format.
  *
  * @internal
  * @param Array &$section The section record.
  */
 private function _validateSection(array &$section)
 {
     // Verify the value of the "order" attribute.
     if ($section['order'] != 'asc' && $section['order'] != 'desc') {
         throw new Opt_InvalidAttributeType_Exception('order', $node->getXmlName(), '"asc" or "desc"');
     }
     // Determine the parent of the specified section.
     // if the attribute is not set, the default behaviour is to find the nearest
     // top-level and active section and link to it. Otherwise we must check if
     // the chosen section exists and is active.
     // Note that "parent" is ignored when we set "datasource"
     if (is_null($section['parent'])) {
         if (self::$_stack->count() > 0) {
             $section['parent'] = self::$_stack->top();
         }
     } elseif ($section['parent'] != '') {
         if (is_null(self::getSection($section['parent']))) {
             $exception = new Opt_SectionNotFound_Exception('parent', $section['parent']);
             $sections = array();
             self::$_stack->setIteratorMode(SplDoublyLinkedList::IT_MODE_LIFO | SplDoublyLinkedList::IT_MODE_KEEP);
             foreach (self::$_stack as $up) {
                 $sections[] = $up;
             }
             $exception->setData($sections);
             throw $exception;
         }
     } else {
         // For the situation, if we had 'parent=""' in the template.
         $section['parent'] = null;
     }
     $section['nesting'] = self::countSections() + 1;
     // Now we need to obtain the information about the data format.
     $section['format'] = $this->_compiler->getFormat($section['name']);
     if (!$section['format']->supports('section')) {
         throw new Opt_FormatNotSupported_Exception($section['format']->getName(), 'section');
     }
 }
开发者ID:OPL,项目名称:Open-Power-Template,代码行数:44,代码来源:BaseSection.php

示例3: close

 /**
  * Close the channel, this operation will terminate all receivers that cannot receive any data.
  * 
  * Closing a closed channel has no effect and does not throw an error!
  * 
  * @param \Throwable $e Error will be propagated to all receivers that cannot receive a buffered value anymore.
  */
 public function close(\Throwable $e = null)
 {
     if ($this->closed) {
         return;
     }
     $this->closed = $e ?? true;
     if ($this->generator) {
         $this->generator->cancel($e ?? new \RuntimeException('Channel closed'));
     }
     // Dispose of queued receivers that cannot receive a value from the channel.
     $sources = ($this->senders ? $this->countActiveSubscriptions($this->senders) : 0) + ($this->buffer ? $this->buffer->count() : 0);
     $sinks = $this->receivers ? $this->countActiveSubscriptions($this->receivers) : 0;
     $fails = new \SplStack();
     $fails->setIteratorMode(\SplStack::IT_MODE_LIFO | \SplStack::IT_MODE_DELETE);
     while ($sinks > $sources) {
         $receiver = $this->receivers->pop();
         if ($receiver->active) {
             $sinks--;
             $fails->push($receiver);
         }
     }
     foreach ($fails as $subscription) {
         if ($e) {
             $subscription->fail($e);
         } else {
             $subscription->resolve($subscription->data);
         }
     }
 }
开发者ID:koolkode,项目名称:async,代码行数:36,代码来源:Channel.php

示例4: SplStack

<?php

$stack = new SplStack();
try {
    $stack->setIteratorMode(SplDoublyLinkedList::IT_MODE_FIFO);
} catch (Exception $e) {
    echo $e->getMessage();
}
开发者ID:badlamer,项目名称:hhvm,代码行数:8,代码来源:SplStack_setIteratorMode.php


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