當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。