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


PHP Result::merge方法代码示例

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


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

示例1: accumulateResults

 /**
  * Add the results from the most recent task to the accumulated
  * results from all tasks that have run so far, merging data
  * as necessary.
  */
 public function accumulateResults($key, Result $result, Result $taskResult)
 {
     // If the result is not set or is not a Result, then ignore it
     if (isset($result) && $result instanceof Result) {
         // If the task is unnamed, then all of its data elements
         // just get merged in at the top-level of the final Result object.
         if (static::isUnnamedTask($key)) {
             $result->merge($taskResult);
         } elseif (isset($result[$key])) {
             // There can only be one task with a given name; however, if
             // there are tasks added 'before' or 'after' the named task,
             // then the results from these will be stored under the same
             // name unless they are given a name of their own when added.
             $current = $result[$key];
             $result[$key] = $taskResult->merge($current);
         } else {
             $result[$key] = $taskResult;
         }
     }
     return $result;
 }
开发者ID:zondor,项目名称:Robo,代码行数:26,代码来源:Collection.php

示例2: run

 /**
  * {@inheritdoc}
  */
 public function run()
 {
     $finalResult = Result::success($this);
     $this->startProgressIndicator();
     foreach ($this->iterable as $key => $value) {
         $this->showIterationMessage($key, $value);
         try {
             foreach ($this->functionStack as $fn) {
                 $result = call_user_func($fn, $key, $value);
                 $this->advanceProgressIndicator();
                 if (!isset($result)) {
                     $result = Result::success($this);
                 }
                 // If the function returns a result, it must either return
                 // a \Robo\Result or an exit code.  In the later case, we
                 // convert it to a \Robo\Result.
                 if (!$result instanceof Result) {
                     $result = new Result($this, $result);
                 }
                 if (!$result->wasSuccessful()) {
                     return $result;
                 }
                 $finalResult = $result->merge($finalResult);
             }
         } catch (\Exception $e) {
             return Result::fromException($result, $e);
         }
     }
     $this->stopProgressIndicator();
     return $finalResult;
 }
开发者ID:jjok,项目名称:Robo,代码行数:34,代码来源:TaskForEach.php


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