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


PHP Robo\Result类代码示例

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


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

示例1: run

 /**
  * {@inheritdoc}
  */
 public function run()
 {
     if (is_null($this->dst) || "" === $this->dst) {
         return Result::error($this, 'You must specify a destination file with to() method.');
     }
     if (!$this->checkResources($this->files, 'file')) {
         return Result::error($this, 'Source files are missing!');
     }
     if (file_exists($this->dst) && !is_writable($this->dst)) {
         return Result::error($this, 'Destination already exists and cannot be overwritten.');
     }
     $dump = '';
     foreach ($this->files as $path) {
         foreach (glob($path) as $file) {
             $dump .= file_get_contents($file) . "\n";
         }
     }
     $this->printTaskInfo('Writing {destination}', ['destination' => $this->dst]);
     $dst = $this->dst . '.part';
     $write_result = file_put_contents($dst, $dump);
     if (false === $write_result) {
         @unlink($dst);
         return Result::error($this, 'File write failed.');
     }
     // Cannot be cross-volume; should always succeed.
     @rename($dst, $this->dst);
     return Result::success($this);
 }
开发者ID:greg-1-anderson,项目名称:Robo,代码行数:31,代码来源:Concat.php

示例2: process

 /**
  * @param \Robo\Result|\Robo\Contract\TaskInterface $result
  * @param \Consolidation\AnnotatedCommand\CommandData $commandData
  *
  * @return null|\Robo\Result
  */
 public function process($result, CommandData $commandData)
 {
     if ($result instanceof TaskInterface) {
         try {
             return $result->run();
         } catch (\Exception $e) {
             return Result::fromException($result, $e);
         }
     }
 }
开发者ID:jjok,项目名称:Robo,代码行数:16,代码来源:CollectionProcessHook.php

示例3: printSuccess

 /**
  * Log the result of a Robo task that was successful.
  */
 protected function printSuccess(Result $result)
 {
     $task = $result->getTask();
     $context = $result->getContext() + ['timer-label' => 'in'];
     $time = $result->getExecutionTime();
     if ($time) {
         $this->printMessage(ConsoleLogLevel::SUCCESS, 'Done', $context);
     }
     return false;
 }
开发者ID:greg-1-anderson,项目名称:Robo,代码行数:13,代码来源:ResultPrinter.php

示例4: testStopOnFail

 public function testStopOnFail()
 {
     $exceptionClass = false;
     $task = new ResultDummyTask();
     Result::$stopOnFail = true;
     $result = Result::success($task, "Something that worked");
     try {
         $result = Result::error($task, "Something that did not work");
         // stopOnFail will cause Result::error() to throw an exception,
         // so we will never get here. If we did, the assert below would fail.
         $this->assertTrue($result->wasSuccessful());
         $this->assertTrue(false);
     } catch (\Exception $e) {
         $exceptionClass = get_class($e);
     }
     $this->assertEquals(TaskExitException::class, $exceptionClass);
     $this->assertTrue($result->wasSuccessful());
     /*
     // This gives an error:
     //    Exception of class Robo\Exception\TaskExitException expected to
     //    be thrown, but PHPUnit_Framework_Exception caught
     // This happens whether or not the expected exception is thrown
     $this->guy->expectException(TaskExitException::class, function() {
         // $result = Result::error($task, "Something that did not work");
         $result = Result::success($task, "Something that worked");
     });
     */
     Result::$stopOnFail = false;
 }
开发者ID:jjok,项目名称:Robo,代码行数:29,代码来源:ResultTest.php

示例5: run

 /**
  * {@inheritdoc}
  */
 public function run()
 {
     if (!$this->skip()) {
         return $this->exec()->arg('locale-update')->run();
     }
     return Result::success($this);
 }
开发者ID:burdamagazinorg,项目名称:robo,代码行数:10,代码来源:LocaleUpdate.php

示例6: run

 public function run()
 {
     foreach ($this->dirs as $dir) {
         $this->fs->remove($dir);
         $this->printTaskInfo("deleted <info>{$dir}</info>...");
     }
     return Result::success($this);
 }
开发者ID:lamenath,项目名称:fbp,代码行数:8,代码来源:DeleteDir.php

示例7: run

 public function run()
 {
     foreach ($this->dirs as $dir) {
         $this->emptyDir($dir);
         $this->printTaskInfo("Cleaned <info>{$dir}</info>");
     }
     return Result::success($this);
 }
开发者ID:rdeutz,项目名称:Robo,代码行数:8,代码来源:CleanDir.php

示例8: run

 /**
  * {@inheritdoc}
  */
 public function run()
 {
     Environment::set($this->environment);
     if (Environment::isDevdesktop()) {
         $this->ensureDevdesktopPath();
     }
     return Result::success($this);
 }
开发者ID:burdamagazinorg,项目名称:robo,代码行数:11,代码来源:Initialize.php

示例9: run

 public function run()
 {
     foreach ($this->dirs as $src => $dst) {
         $this->copyDir($src, $dst);
         $this->printTaskInfo("Copied from <info>{$src}</info> to <info>{$dst}</info>");
     }
     return Result::success($this);
 }
开发者ID:lamenath,项目名称:fbp,代码行数:8,代码来源:CopyDir.php

示例10: run

 public function run()
 {
     foreach ($this->dirs as $src => $dst) {
         $this->fs->mirror($src, $dst, null, ['override' => true, 'copy_on_windows' => true, 'delete' => true]);
         $this->printTaskInfo("Mirrored from {source} to {destination}", ['source' => $src, 'destination' => $dst]);
     }
     return Result::success($this);
 }
开发者ID:greg-1-anderson,项目名称:Robo,代码行数:8,代码来源:MirrorDir.php

示例11: run

 public function run()
 {
     foreach ($this->dirs as $src => $dst) {
         $this->fs->mirror($src, $dst, null, ['override' => true, 'copy_on_windows' => true, 'delete' => true]);
         $this->printTaskInfo("Mirrored from <info>{$src}</info> to <info>{$dst}</info>");
     }
     return Result::success($this);
 }
开发者ID:szymach,项目名称:Robo,代码行数:8,代码来源:MirrorDir.php

示例12: run

 public function run()
 {
     $delegate = new \ReflectionClass($this->className);
     $replacements = [];
     $leadingCommentChars = " * ";
     $methodDescriptions = [];
     $methodImplementations = [];
     $immediateMethods = [];
     foreach ($delegate->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) {
         $methodName = $method->name;
         $getter = preg_match('/^(get|has|is)/', $methodName);
         $setter = preg_match('/^(set|unset)/', $methodName);
         $argPrototypeList = [];
         $argNameList = [];
         $needsImplementation = false;
         foreach ($method->getParameters() as $arg) {
             $argDescription = '$' . $arg->name;
             $argNameList[] = $argDescription;
             if ($arg->isOptional()) {
                 $argDescription = $argDescription . ' = ' . str_replace("\n", "", var_export($arg->getDefaultValue(), true));
                 // We will create wrapper methods for any method that
                 // has default parameters.
                 $needsImplementation = true;
             }
             $argPrototypeList[] = $argDescription;
         }
         $argPrototypeString = implode(', ', $argPrototypeList);
         $argNameListString = implode(', ', $argNameList);
         if ($methodName[0] != '_') {
             $methodDescriptions[] = "@method {$methodName}({$argPrototypeString})";
             if ($getter) {
                 $immediateMethods[] = "    public function {$methodName}({$argPrototypeString})\n    {\n        return \$this->delegate->{$methodName}({$argNameListString});\n    }";
             } elseif ($setter) {
                 $immediateMethods[] = "    public function {$methodName}({$argPrototypeString})\n    {\n        \$this->delegate->{$methodName}({$argNameListString});\n        return \$this;\n    }";
             } elseif ($needsImplementation) {
                 // Include an implementation for the wrapper method if necessary
                 $methodImplementations[] = "    protected function _{$methodName}({$argPrototypeString})\n    {\n        \$this->delegate->{$methodName}({$argNameListString});\n    }";
             }
         }
     }
     $classNameParts = explode('\\', $this->className);
     $delegate = array_pop($classNameParts);
     $delegateNamespace = implode('\\', $classNameParts);
     if (empty($this->wrapperClassName)) {
         $this->wrapperClassName = $delegate;
     }
     $replacements['{delegateNamespace}'] = $delegateNamespace;
     $replacements['{delegate}'] = $delegate;
     $replacements['{wrapperClassName}'] = $this->wrapperClassName;
     $replacements['{taskname}'] = "task{$delegate}";
     $replacements['{methodList}'] = $leadingCommentChars . implode("\n{$leadingCommentChars}", $methodDescriptions);
     $replacements['{immediateMethods}'] = "\n\n" . implode("\n\n", $immediateMethods);
     $replacements['{methodImplementations}'] = "\n\n" . implode("\n\n", $methodImplementations);
     $template = file_get_contents(__DIR__ . "/GeneratedWrapper.tmpl");
     $template = str_replace(array_keys($replacements), array_values($replacements), $template);
     // Returning data in the $message will cause it to be printed.
     return Result::success($this, $template);
 }
开发者ID:greg-1-anderson,项目名称:Robo,代码行数:58,代码来源:GenerateTask.php

示例13: run

 public function run()
 {
     $this->printTaskInfo("Writing {$this->filename}");
     $res = file_put_contents($this->filename, $this->body);
     if ($res === false) {
         return Result::error($this, "File {$this->filename} couldnt be created");
     }
     return Result::success($this);
 }
开发者ID:beejhuff,项目名称:RoboCI,代码行数:9,代码来源:CreateStartScript.php

示例14: checkExtension

 /**
  * Check for availablilty of PHP extensions.
  */
 protected function checkExtension($service, $extensionList)
 {
     foreach ((array) $extensionList as $ext) {
         if (!extension_loaded($ext)) {
             return Result::error($this, "You must use PHP with the {$ext} extension enabled to use {$service}");
         }
     }
     return Result::success($this);
 }
开发者ID:surjit,项目名称:PHP-Robo-Task-Runner,代码行数:12,代码来源:PHPStatus.php

示例15: callTaskMethod

 /**
  * Execute one task method
  */
 protected function callTaskMethod($command, $action)
 {
     try {
         $function_result = call_user_func_array($command, $action);
         return $this->processResult($function_result);
     } catch (IOExceptionInterface $e) {
         $this->printTaskInfo("<error>" . $e->getMessage() . "</error>");
         return Result::error($this, $e->getMessage(), $e->getPath());
     }
 }
开发者ID:zondor,项目名称:Robo,代码行数:13,代码来源:FilesystemStack.php


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