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


PHP Result::error方法代码示例

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


在下文中一共展示了Result::error方法的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: 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

示例3: 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

示例4: 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

示例5: 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

示例6: run

 public function run()
 {
     if (!$this->checkResources($this->dirs, 'dir')) {
         return Result::error($this, 'Source directories are missing!');
     }
     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:stefanhuber,项目名称:Robo,代码行数:11,代码来源:CopyDir.php

示例7: run

 /**
  * {@inheritdoc}
  */
 public function run()
 {
     if (!$this->checkResources($this->dirs, 'dir')) {
         return Result::error($this, 'Source directories are missing!');
     }
     foreach ($this->dirs as $dir) {
         $this->fs->remove($dir);
         $this->printTaskInfo("Deleted {dir}...", ['dir' => $dir]);
     }
     return Result::success($this);
 }
开发者ID:jjok,项目名称:Robo,代码行数:14,代码来源:DeleteDir.php

示例8: run

 public function run()
 {
     if (!$this->checkResources($this->dirs, 'dir')) {
         return Result::error($this, 'Source directories are missing!');
     }
     foreach ($this->dirs as $dir) {
         $this->emptyDir($dir);
         $this->printTaskInfo("Cleaned <info>{$dir}</info>");
     }
     return Result::success($this);
 }
开发者ID:stefanhuber,项目名称:Robo,代码行数:11,代码来源:CleanDir.php

示例9: run

 /**
  * {@inheritdoc}
  */
 public function run()
 {
     if (!$this->checkResources($this->dirs, 'dir')) {
         return Result::error($this, 'Source directories are missing!');
     }
     foreach ($this->dirs as $src => $dst) {
         $this->copyDir($src, $dst);
         $this->printTaskInfo('Copied from {source} to {destination}', ['source' => $src, 'destination' => $dst]);
     }
     return Result::success($this);
 }
开发者ID:jjok,项目名称:Robo,代码行数:14,代码来源:CopyDir.php

示例10: run

 public function run()
 {
     $openCommand = $this->getOpenCommand();
     if (empty($openCommand)) {
         return Result::error($this, 'no suitable browser opening command found');
     }
     foreach ($this->urls as $url) {
         passthru(sprintf($openCommand, ProcessUtils::escapeArgument($url)));
         $this->printTaskInfo("Opened <info>{$url}</info>");
     }
     return Result::success($this);
 }
开发者ID:stefanhuber,项目名称:Robo,代码行数:12,代码来源:OpenBrowser.php

示例11: run

 public function run()
 {
     if ($this->check()) {
         return Result::success($this);
     }
     $message = 'One or more requirements failed';
     if ($this->stopOnFail) {
         $requirements = array_keys($this->results);
         $message = array_pop($requirements);
     }
     return Result::error($this, $message);
 }
开发者ID:jadb,项目名称:robot,代码行数:12,代码来源:RequirementStack.php

示例12: run

 /**
  * Create our working directory.
  *
  * @return \Robo\Result
  */
 public function run()
 {
     // Destination cannot be empty
     if (empty($this->finalDestination)) {
         return Result::error($this, "Destination directory not specified.");
     }
     // Before we do anything else, ensure that any directory in the
     // final destination is writable, so that we can at a minimum
     // move it out of the way before placing our results there.
     if (is_dir($this->finalDestination)) {
         if (!is_writable($this->finalDestination)) {
             return Result::error($this, "Destination directory {dir} exists and cannot be overwritten.", ['dir' => $this->finalDestination]);
         }
     }
     return parent::run();
 }
开发者ID:jjok,项目名称:Robo,代码行数:21,代码来源:WorkDir.php

示例13: run

 function run()
 {
     if (!file_exists($this->filename)) {
         $this->printTaskError("File {$this->filename} does not exist");
         return false;
     }
     $text = file_get_contents($this->filename);
     if ($this->regex) {
         $text = preg_replace($this->regex, $this->to, $text, -1, $count);
     } else {
         $text = str_replace($this->from, $this->to, $text, $count);
     }
     $res = file_put_contents($this->filename, $text);
     if ($res === false) {
         return Result::error($this, "Error writing to file {$this->filename}.");
     }
     $this->printTaskSuccess("<info>{$this->filename}</info> updated. {$count} items replaced");
     return Result::success($this, '', ['replaced' => $count]);
 }
开发者ID:roland-d,项目名称:Robo,代码行数:19,代码来源:Replace.php

示例14: 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!');
     }
     $dump = '';
     foreach ($this->files as $path) {
         foreach (glob($path) as $file) {
             $dump .= file_get_contents($file) . "\n";
         }
     }
     $this->printTaskInfo(sprintf('Writing <info>%s</info>', $this->dst));
     $dst = $this->dst . '.part';
     file_put_contents($dst, $dump);
     rename($dst, $this->dst);
     return Result::success($this);
 }
开发者ID:stefanhuber,项目名称:Robo,代码行数:23,代码来源:Concat.php

示例15: 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.');
     }
     $dump = '';
     foreach ($this->files as $path) {
         foreach (glob($path) as $file) {
             if (!file_exists($file)) {
                 return Result::error($this, sprintf('File %s not found', $file));
             }
             $dump .= file_get_contents($file);
         }
     }
     $this->printTaskInfo(sprintf('Writing <info>%s</info>', $this->dst));
     $dst = $this->dst . '.part';
     file_put_contents($dst, $dump);
     rename($dst, $this->dst);
     return Result::success($this);
 }
开发者ID:lamenath,项目名称:fbp,代码行数:23,代码来源:Concat.php


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