當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Result::success方法代碼示例

本文整理匯總了PHP中Robo\Result::success方法的典型用法代碼示例。如果您正苦於以下問題:PHP Result::success方法的具體用法?PHP Result::success怎麽用?PHP Result::success使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Robo\Result的用法示例。


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

 /**
  * {@inheritdoc}
  */
 public function run()
 {
     if (!$this->skip()) {
         return $this->exec()->arg('locale-update')->run();
     }
     return Result::success($this);
 }
開發者ID:burdamagazinorg,項目名稱:robo,代碼行數:10,代碼來源:LocaleUpdate.php

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

示例5: run

 /**
  * {@inheritdoc}
  */
 public function run()
 {
     Environment::set($this->environment);
     if (Environment::isDevdesktop()) {
         $this->ensureDevdesktopPath();
     }
     return Result::success($this);
 }
開發者ID:burdamagazinorg,項目名稱:robo,代碼行數:11,代碼來源:Initialize.php

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

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

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

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

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

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

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

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

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

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


注:本文中的Robo\Result::success方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。