• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP SplObjectStorage类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: listen

 /**
  * {@inheritdoc}
  */
 public function listen(callable $action) : Awaitable
 {
     return new Coroutine(function () use($action) {
         $factory = clone $this->factory;
         $factory->setTcpNoDelay(true);
         $this->server = (yield $factory->createSocketServer());
         $port = $this->server->getPort();
         $peer = $this->server->getAddress() . ($port ? ':' . $port : '');
         $context = new HttpDriverContext($peer, $factory->getPeerName(), $factory->isEncrypted(), $this->middlewares, $this->responders);
         $pending = new \SplObjectStorage();
         try {
             (yield $this->server->listen(function (SocketStream $socket) use($pending, $context, $action) {
                 $conn = new Connection($socket, $context);
                 if ($this->logger) {
                     $conn->setLogger($this->logger);
                 }
                 $pending->attach($conn);
                 while (null !== ($next = (yield $conn->nextRequest()))) {
                     new Coroutine($this->processRequest($conn, $context, $action, ...$next));
                 }
             }));
         } finally {
             $this->server = null;
             foreach ($pending as $task) {
                 $task->cancel(new \RuntimeException('FCGI server stopped'));
             }
         }
     });
 }
开发者ID:koolkode,项目名称:async-http,代码行数:32,代码来源:FcgiEndpoint.php


示例2: getViewHelper

 /**
  * Public such that it is callable from within closures
  *
  * @param integer $uniqueCounter
  * @param RenderingContextInterface $renderingContext
  * @param string $viewHelperName
  * @return AbstractViewHelper
  * @Flow\Internal
  */
 public function getViewHelper($uniqueCounter, RenderingContextInterface $renderingContext, $viewHelperName)
 {
     if (Bootstrap::$staticObjectManager->getScope($viewHelperName) === Configuration::SCOPE_SINGLETON) {
         // if ViewHelper is Singleton, do NOT instantiate with NEW, but re-use it.
         $viewHelper = Bootstrap::$staticObjectManager->get($viewHelperName);
         $viewHelper->resetState();
         return $viewHelper;
     }
     if (isset($this->viewHelpersByPositionAndContext[$uniqueCounter])) {
         /** @var $viewHelpers \SplObjectStorage */
         $viewHelpers = $this->viewHelpersByPositionAndContext[$uniqueCounter];
         if ($viewHelpers->contains($renderingContext)) {
             $viewHelper = $viewHelpers->offsetGet($renderingContext);
             $viewHelper->resetState();
             return $viewHelper;
         } else {
             $viewHelperInstance = new $viewHelperName();
             $viewHelpers->attach($renderingContext, $viewHelperInstance);
             return $viewHelperInstance;
         }
     } else {
         $viewHelperInstance = new $viewHelperName();
         $viewHelpers = new \SplObjectStorage();
         $viewHelpers->attach($renderingContext, $viewHelperInstance);
         $this->viewHelpersByPositionAndContext[$uniqueCounter] = $viewHelpers;
         return $viewHelperInstance;
     }
 }
开发者ID:kszyma,项目名称:flow-development-collection,代码行数:37,代码来源:AbstractCompiledTemplate.php


示例3: it_should_process_the_tiebreaker_round_and_return_the_loser

 function it_should_process_the_tiebreaker_round_and_return_the_loser()
 {
     // less
     $answer1 = json_decode('{"answer":0.019,"token":"token-goes-here"}');
     $answer2 = json_decode('{"answer":0.020,"token":"token-goes-here"}');
     // more
     $answer3 = json_decode('{"answer":0.021,"token":"token-goes-here"}');
     $answer4 = json_decode('{"answer":0.020,"token":"token-goes-here"}');
     // equal
     $answer5 = json_decode('{"answer":0.020,"token":"token-goes-here"}');
     $answer6 = json_decode('{"answer":0.020,"token":"token-goes-here"}');
     // create Dummy objects
     $clients = new \SplObjectStorage();
     $conn1 = new \StdClass();
     $conn2 = new \StdClass();
     // less - answer1 wins
     $clients->attach($conn1, $answer1);
     $clients->attach($conn2, $answer2);
     $this->processTiebreaker($clients)->shouldReturn($conn2);
     // more - answer2 wins
     $clients->attach($conn1, $answer3);
     $clients->attach($conn2, $answer4);
     $this->processTiebreaker($clients)->shouldReturn($conn1);
     // equal - answer1 wins ( I know its cheating a little )
     $clients->attach($conn1, $answer5);
     $clients->attach($conn2, $answer6);
     $this->processTiebreaker($clients)->shouldReturn($conn2);
 }
开发者ID:Techbot,项目名称:ratchet-based-game,代码行数:28,代码来源:RoundProcessorSpec.php


示例4: get

 public function get()
 {
     $storage = new \SplObjectStorage();
     $storage->attach($this->exampleA);
     $storage->attach($this->exampleB);
     return $storage;
 }
开发者ID:cheevauva,项目名称:container,代码行数:7,代码来源:ExampleF.php


示例5: convertDependenciesToObjects

 /**
  * Converts string dependencies to an object storage of dependencies
  *
  * @param string $dependencies
  * @return \SplObjectStorage
  */
 public function convertDependenciesToObjects($dependencies)
 {
     $dependenciesObject = new \SplObjectStorage();
     $unserializedDependencies = unserialize($dependencies);
     if (!is_array($unserializedDependencies)) {
         return $dependenciesObject;
     }
     foreach ($unserializedDependencies as $dependencyType => $dependencyValues) {
         // Dependencies might be given as empty string, e.g. conflicts => ''
         if (!is_array($dependencyValues)) {
             continue;
         }
         foreach ($dependencyValues as $dependency => $versions) {
             if ($dependencyType && $dependency) {
                 $versionNumbers = \TYPO3\CMS\Core\Utility\VersionNumberUtility::convertVersionsStringToVersionNumbers($versions);
                 $lowest = $versionNumbers[0];
                 if (count($versionNumbers) === 2) {
                     $highest = $versionNumbers[1];
                 } else {
                     $highest = '';
                 }
                 /** @var $dependencyObject \TYPO3\CMS\Extensionmanager\Domain\Model\Dependency */
                 $dependencyObject = $this->objectManager->get(\TYPO3\CMS\Extensionmanager\Domain\Model\Dependency::class);
                 $dependencyObject->setType($dependencyType);
                 $dependencyObject->setIdentifier($dependency);
                 $dependencyObject->setLowestVersion($lowest);
                 $dependencyObject->setHighestVersion($highest);
                 $dependenciesObject->attach($dependencyObject);
                 unset($dependencyObject);
             }
         }
     }
     return $dependenciesObject;
 }
开发者ID:adrolli,项目名称:TYPO3.CMS,代码行数:40,代码来源:ExtensionModelUtility.php


示例6: __construct

 public function __construct(array $users = array())
 {
     $this->users = new SplObjectStorage();
     foreach ($users as $user) {
         $this->users->attach(new User(new UserId($user['id']), new Name($user['name']), new EmailAddress($user['email'])));
     }
 }
开发者ID:kolah,项目名称:recruitment,代码行数:7,代码来源:UserRepository.php


示例7: analyse

 /**
  * {@inheritdoc}
  */
 public function analyse(OccurrencesInterface $occurences)
 {
     $storage = new \SplObjectStorage();
     /** @var OccurrenceInterface $occurence */
     foreach ($occurences->getFirstOccurrences() as $occurence) {
         $rule = $occurence->getRule();
         $expectedCount = count($rule->getConditions());
         $counter = 1;
         $current = $occurence;
         $previous = null;
         $this->dynamicCapabilitiesProcessor->process($current);
         while ($next = $occurences->getNext($current)) {
             $previous = $current;
             $current = $next;
             if ($this->incrementation->oughtToBeIncrement($current, $previous)) {
                 $counter++;
                 $this->dynamicCapabilitiesProcessor->process($current);
             }
         }
         if ($counter === $expectedCount && !$storage->contains($rule)) {
             $storage->attach($rule);
         }
     }
     return $storage;
 }
开发者ID:zientalak,项目名称:devicedetector,代码行数:28,代码来源:OccurrencesAnalyser.php


示例8: testCollect

 /**
  * When collecting gift card totals, each gift card to be redeemed should have
  * the amount expected to be redeemed set as the amount to redeem, the order
  * address grand total should be decremented by the amount being redeemed from
  * all gift cards and data should be set on the order address indicating the
  * total amount expected to be redeemed from gift cards.
  * @param float $addressTotal Grand total of the order before gift cards
  * @param array $giftCardAmounts Expected gift card amounts by card number - balance and redeem amount
  * @param float $remainingTotal Expected address total after applying gift cards
  * @param float $redeemTotal Expected gift card amount to redeem
  * @dataProvider dataProvider
  */
 public function testCollect($addressTotal, $giftCardAmounts, $remainingTotal, $redeemTotal)
 {
     // float cast on yaml provided value to ensure it is actually a float
     $addressTotal = (double) $addressTotal;
     $remainingTotal = (double) $remainingTotal;
     $redeemTotal = (double) $redeemTotal;
     // set of gift cards that have been applied to the order and not redeemed
     $giftCards = new SplObjectStorage();
     foreach ($giftCardAmounts as $cardNumber => $amts) {
         $gc = Mage::getModel('ebayenterprise_giftcard/giftcard')->setCardNumber($cardNumber)->setBalanceAmount((double) $amts['balance'])->setIsRedeemed(false);
         $giftCards->attach($gc);
     }
     $container = $this->getModelMock('ebayenterprise_giftcard/container', ['getUnredeemedGiftCards']);
     $container->method('getUnredeemedGiftCards')->willReturn($giftCards);
     $address = Mage::getModel('sales/quote_address', array('base_grand_total' => $addressTotal, 'grand_total' => $addressTotal));
     $totalCollector = Mage::getModel('ebayenterprise_giftcard/total_quote', array('gift_card_container' => $container));
     $totalCollector->collect($address);
     // float casts on yaml provided values to ensure they are actually floats
     $this->assertSame($remainingTotal, $address->getGrandTotal());
     $this->assertSame($redeemTotal, $address->getEbayEnterpriseGiftCardBaseAppliedAmount());
     foreach ($giftCards as $card) {
         // float cast on yaml provided value to ensure it is actually a float
         $this->assertSame((double) $giftCardAmounts[$card->getCardNumber()]['redeem'], $card->getAmountToRedeem());
     }
 }
开发者ID:sirishreddyg,项目名称:magento-retail-order-management,代码行数:37,代码来源:QuoteTest.php


示例9: createBatches

public function createBatches(\SplQueue $queue)
{

 $groups = new \SplObjectStorage();
foreach ($queue as $item) {
if (!$item instanceof RequestInterface) {
throw new InvalidArgumentException('All items must implement Guzzle\Http\Message\RequestInterface');
}
$client = $item->getClient();
if (!$groups->contains($client)) {
$groups->attach($client, array($item));
} else {
$current = $groups[$client];
$current[] = $item;
$groups[$client] = $current;
}
}

$batches = array();
foreach ($groups as $batch) {
$batches = array_merge($batches, array_chunk($groups[$batch], $this->batchSize));
}

return $batches;
}
开发者ID:Ryu0621,项目名称:SaNaVi,代码行数:25,代码来源:BatchRequestTransfer.php


示例10: valuesProvider

 public function valuesProvider()
 {
     $obj2 = new \stdClass();
     $obj2->foo = 'bar';
     $obj3 = (object) array(1, 2, "Test\r\n", 4, 5, 6, 7, 8);
     $obj = new \stdClass();
     // @codingStandardsIgnoreStart
     $obj->null = null;
     // @codingStandardsIgnoreEnd
     $obj->boolean = true;
     $obj->integer = 1;
     $obj->double = 1.2;
     $obj->string = '1';
     $obj->text = "this\nis\na\nvery\nvery\nvery\nvery\nvery\nvery\rlong\n\rtext";
     $obj->object = $obj2;
     $obj->objectagain = $obj2;
     $obj->array = array('foo' => 'bar');
     $obj->array2 = array(1, 2, 3, 4, 5, 6);
     $obj->array3 = array($obj, $obj2, $obj3);
     $obj->self = $obj;
     $storage = new \SplObjectStorage();
     $storage->attach($obj2);
     $storage->foo = $obj2;
     return array(array($obj, spl_object_hash($obj)), array($obj2, spl_object_hash($obj2)), array($obj3, spl_object_hash($obj3)), array($storage, spl_object_hash($storage)), array($obj->array, 0), array($obj->array2, 0), array($obj->array3, 0));
 }
开发者ID:ngitimfoyo,项目名称:Nyari-AppPHP,代码行数:25,代码来源:ContextTest.php


示例11: startWorkers

 public function startWorkers($workerCount, OutputInterface $output)
 {
     $output->writeln('Workers Manager is about to start ' . $workerCount . ' workers');
     /* @var \Symfony\Component\Process\Process[] $workers */
     $workers = new \SplObjectStorage();
     for ($i = 1; $i <= $workerCount; ++$i) {
         $output->writeln('Starting worker nr: ' . $i . ' - ' . $this->workerExecCommand);
         $worker = new Process($this->workerExecCommand);
         // $worker->disableOutput();
         $workers->attach($worker);
         $worker->start();
         if ($worker->isRunning()) {
             $output->writeln('Worker started [PID = ' . $worker->getPid() . ']');
         } else {
             $output->writeln('<error>Worker start failure. ' . $worker->getErrorOutput() . '</error>');
         }
     }
     while (count($workers) > 0) {
         $output->writeln('Managing ' . count($workers) . ' worker(s) on ' . date('Y-m-d H:i:s'));
         $workersToRemove = [];
         foreach ($workers as $worker) {
             if (!$worker->isRunning()) {
                 $output->writeln('<info>Found non running worker.</info>');
                 $workersToRemove[] = $worker;
             }
         }
         foreach ($workersToRemove as $worker) {
             $workers->detach($worker);
         }
         sleep(1);
     }
     $output->writeln('Workers Manager exits.');
 }
开发者ID:highestgoodlikewater,项目名称:spider-5,代码行数:33,代码来源:WorkersManager.php


示例12: getConnections

 /**
  * @return ConnectionFactory[]
  */
 private function getConnections()
 {
     $connections = new \SplObjectStorage();
     foreach ($this->repositoryMap as $mapper) {
         $connections->attach($mapper->getConnectionFactory());
     }
     return $connections;
 }
开发者ID:mitallast,项目名称:php-db,代码行数:11,代码来源:RepositoryMapper.php


示例13: testAddPaymentsToPayloadAlreadyProcessed

 /**
  * verify
  * - no payments will be processed if all are in the
  *   processed list
  */
 public function testAddPaymentsToPayloadAlreadyProcessed()
 {
     $processedPayments = new SplObjectStorage();
     $processedPayments->attach($this->_paymentStubs[0]);
     $this->_payloadStub->expects($this->never())->method('setAmount');
     $handler = Mage::getModel('ebayenterprise_paypal/order_create_payment');
     $handler->addPaymentsToPayload($this->_orderStub, $this->_paymentContainer, $processedPayments);
 }
开发者ID:sirishreddyg,项目名称:magento-retail-order-management,代码行数:13,代码来源:PaymentTest.php


示例14: spl_object_storage_can_be_used_like_a_set

 public function spl_object_storage_can_be_used_like_a_set()
 {
     $spl_storage = new SplObjectStorage();
     $an_object = new ClassWithProperties();
     $spl_storage->attach($an_object);
     $spl_storage->attach($an_object);
     assert_that(count($spl_storage))->is_identical_to(__);
 }
开发者ID:mtvillwock,项目名称:php-inferno,代码行数:8,代码来源:Fraud.php


示例15: onNext

 /**
  * @param EventInterface $value
  * @throws \Exception
  */
 public function onNext($value)
 {
     $uri = $value->getName();
     // TODO add route cache
     foreach ($this->routing as $subject) {
         /* @var ReplaySubject $subject */
         $routes = $this->routing->offsetGet($subject);
         foreach ($routes as $data) {
             if (!preg_match($data['regex'], $uri, $matches)) {
                 continue;
             }
             $vars = [];
             $i = 0;
             foreach ($data['routeMap'] as $varName) {
                 $vars[$varName] = $matches[++$i];
             }
             $labels = $value->getLabels();
             $labels = array_merge($labels, $vars);
             $value->setLabels($labels);
             $subject->onNext($value);
             return;
         }
     }
     throw new \Exception("not found");
 }
开发者ID:domraider,项目名称:rxnet,代码行数:29,代码来源:EventSource.php


示例16: removeHandler

 /**
  * Remove the given log message handler if it is registered.
  * 
  * @param LogHandler $handler
  */
 public function removeHandler(LogHandler $handler)
 {
     if ($this->handlers->contains($handler)) {
         $this->handlers->detach($handler);
         $this->enabled = $this->handlers->count() ? true : false;
     }
 }
开发者ID:koolkode,项目名称:async,代码行数:12,代码来源:Logger.php


示例17: removeValidator

 /**
  * Removes the specified validator.
  *
  * @param \TYPO3\FLOW3\Validation\Validator\ValidatorInterface $validator The validator to remove
  * @throws \TYPO3\FLOW3\Validation\Exception\NoSuchValidatorException
  * @api
  */
 public function removeValidator(\TYPO3\FLOW3\Validation\Validator\ValidatorInterface $validator)
 {
     if (!$this->validators->contains($validator)) {
         throw new \TYPO3\FLOW3\Validation\Exception\NoSuchValidatorException('Cannot remove validator because its not in the conjunction.', 1207020177);
     }
     $this->validators->detach($validator);
 }
开发者ID:nxpthx,项目名称:FLOW3,代码行数:14,代码来源:AbstractCompositeValidator.php


示例18: getBlockId

 protected function getBlockId(Block $block)
 {
     if (!$this->blocks->contains($block)) {
         $this->blocks[$block] = count($this->blocks) + 1;
     }
     return $this->blocks[$block];
 }
开发者ID:ircmaxell,项目名称:php-cfg,代码行数:7,代码来源:DebugVisitor.php


示例19: isVisiting

 public function isVisiting($object)
 {
     if (!is_object($object)) {
         return false;
     }
     return $this->visitingSet->contains($object);
 }
开发者ID:baardbaard,项目名称:bb-twitterfeed,代码行数:7,代码来源:SerializationContext.php


示例20: remove

 /**
  * @param ConnectionInterface $connection
  */
 public function remove(ConnectionInterface $connection)
 {
     Debug::line(__CLASS__ . ': Remove [');
     $this->storage->detach($connection);
     Debug::line('-- WebSocket connection removed');
     Debug::line(']');
 }
开发者ID:iiifx,项目名称:websocket-connect,代码行数:10,代码来源:WebSocketConnections.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP SplPriorityQueue类代码示例发布时间:2022-05-23
下一篇:
PHP SplFixedArray类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap