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