• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Context\ContextInterface类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: run

 /**
  * {@inheritdoc}
  */
 public function run(ContextInterface $context)
 {
     $files = $context->getFiles()->name('*.php');
     if (0 === count($files)) {
         return;
     }
     // We don't care about changed files here, we want to run the entire suit every time
     $config = $this->getConfiguration();
     $this->processBuilder->setArguments(array($this->getCommandLocation()));
     if ($config['config']) {
         $this->processBuilder->add('--config=' . $config['config']);
     }
     if ($config['format']) {
         $this->processBuilder->add('--format=' . $config['format']);
     }
     if ($config['suite']) {
         $this->processBuilder->add('--suite=' . $config['suite']);
     }
     if ($config['stop_on_failure']) {
         $this->processBuilder->add('--stop-on-failure');
     }
     $process = $this->processBuilder->getProcess();
     $process->run();
     if (!$process->isSuccessful()) {
         throw new RuntimeException($process->getOutput());
     }
 }
开发者ID:hunslater,项目名称:grumphp,代码行数:30,代码来源:Behat.php


示例2: run

 /**
  * @param ContextInterface $context
  * @return TaskResult
  */
 public function run(ContextInterface $context)
 {
     $config = $this->getConfiguration();
     $files = $context->getFiles()->extensions($config['triggered_by']);
     if (0 === count($files)) {
         return TaskResult::createSkipped($this, $context);
     }
     if (is_file('./vendor/bin/fixbom')) {
         $fixCommand = './vendor/bin/fixbom';
     } elseif (is_file('./bin/fixbom')) {
         $fixCommand = './bin/fixbom';
     } else {
         $fixCommand = 'fixbom';
     }
     $shouldGetFixedLog = [];
     /** @var \Symfony\Component\Finder\SplFileInfo $file */
     foreach ($files as $file) {
         $execFile = $file->getPathname();
         $debugLog[] = $execFile;
         if ($this->isFileWithBOM($execFile)) {
             $shouldGetFixedLog[] = $execFile . " has BOM and should be fixed";
             $fixCommand .= " '" . $execFile . "'";
         }
     }
     if (count($shouldGetFixedLog) > 0) {
         return TaskResult::createFailed($this, $context, implode(PHP_EOL, $shouldGetFixedLog) . PHP_EOL . "you can use this to fix them:" . PHP_EOL . $fixCommand);
     }
     return TaskResult::createPassed($this, $context);
 }
开发者ID:andersundsehr,项目名称:grumphp-bom-task,代码行数:33,代码来源:BomFixerTask.php


示例3: run

 /**
  * {@inheritdoc}
  */
 public function run(ContextInterface $context)
 {
     $config = $this->getConfiguration();
     $files = $context->getFiles()->path(pathinfo($config['file'], PATHINFO_DIRNAME))->name(pathinfo($config['file'], PATHINFO_BASENAME));
     if (0 === count($files)) {
         return TaskResult::createSkipped($this, $context);
     }
     $arguments = $this->processBuilder->createArgumentsForCommand('composer');
     $arguments->add('validate');
     $arguments->addOptionalArgument('--no-check-all', $config['no_check_all']);
     $arguments->addOptionalArgument('--no-check-lock', $config['no_check_lock']);
     $arguments->addOptionalArgument('--no-check-publish', $config['no_check_publish']);
     $arguments->addOptionalArgument('--with-dependencies', $config['with_dependencies']);
     $arguments->addOptionalArgument('--strict', $config['strict']);
     $arguments->addOptionalArgument('%s', $config['file']);
     $process = $this->processBuilder->buildProcess($arguments);
     $process->run();
     if (!$process->isSuccessful()) {
         return TaskResult::createFailed($this, $context, $this->formatter->format($process));
     }
     if ($config['no_local_repository'] && $this->hasLocalRepository($files->first())) {
         return TaskResult::createFailed($this, $context, 'You have at least one local repository declared.');
     }
     return TaskResult::createPassed($this, $context);
 }
开发者ID:phpro,项目名称:grumphp,代码行数:28,代码来源:Composer.php


示例4: run

 /**
  * {@inheritdoc}
  */
 public function run(ContextInterface $context)
 {
     $files = $context->getFiles()->name('*.php');
     if (0 === count($files)) {
         return;
     }
     $config = $this->getConfiguration();
     $this->processBuilder->setArguments(array($this->getCommandLocation(), '--standard=' . $config['standard']));
     if (!$config['show_warnings']) {
         $this->processBuilder->add('--warning-severity=0');
     }
     if ($config['tab_width']) {
         $this->processBuilder->add('--tab-width=' . $config['tab_width']);
     }
     if (count($config['sniffs'])) {
         $this->processBuilder->add('--sniffs=' . implode(',', $config['sniffs']));
     }
     if (count($config['ignore_patterns'])) {
         $this->processBuilder->add('--ignore=' . implode(',', $config['ignore_patterns']));
     }
     foreach ($files as $file) {
         $this->processBuilder->add($file);
     }
     $process = $this->processBuilder->getProcess();
     $process->run();
     if (!$process->isSuccessful()) {
         throw new RuntimeException($process->getOutput());
     }
 }
开发者ID:adam-paterson,项目名称:grumphp,代码行数:32,代码来源:Phpcs.php


示例5: LintErrorsCollection

 function it_throws_exception_if_the_process_fails(JsonLinter $linter, ContextInterface $context)
 {
     $linter->isInstalled()->willReturn(true);
     $linter->setDetectKeyConflicts(false)->shouldBeCalled();
     $linter->lint(Argument::type('SplFileInfo'))->willReturn(new LintErrorsCollection(array(new JsonLintError(LintError::TYPE_ERROR, 0, 'error', 'file.json', 1, 1))));
     $context->getFiles()->willReturn(new FilesCollection(array(new SplFileInfo('file.json', '.', 'file.json'))));
     $this->shouldThrow('GrumPHP\\Exception\\RuntimeException')->duringRun($context);
 }
开发者ID:brunocoelhor,项目名称:grumphp,代码行数:8,代码来源:JsonLintSpec.php


示例6:

 function it_has_failed_if_it_contains_failed_task_result(TaskInterface $task, ContextInterface $context)
 {
     $aTask = $task->getWrappedObject();
     $aContext = $context->getWrappedObject();
     $this->add(TaskResult::createPassed($aTask, $aContext));
     $this->add(TaskResult::createNonBlockingFailed($aTask, $aContext, 'non blocking'));
     $this->isFailed()->shouldReturn(false);
     $this->add(TaskResult::createFailed($aTask, $aContext, 'failed message'));
     $this->isFailed()->shouldReturn(true);
 }
开发者ID:phpro,项目名称:grumphp,代码行数:10,代码来源:TaskResultCollectionSpec.php


示例7: LintErrorsCollection

 function it_throws_exception_if_the_process_fails(JsonLinter $linter, ContextInterface $context)
 {
     $linter->isInstalled()->willReturn(true);
     $linter->setDetectKeyConflicts(false)->shouldBeCalled();
     $linter->lint(Argument::type('SplFileInfo'))->willReturn(new LintErrorsCollection([new JsonLintError(LintError::TYPE_ERROR, 0, 'error', 'file.json', 1, 1)]));
     $context->getFiles()->willReturn(new FilesCollection([new SplFileInfo('file.json', '.', 'file.json')]));
     $result = $this->run($context);
     $result->shouldBeAnInstanceOf(TaskResultInterface::class);
     $result->isPassed()->shouldBe(false);
 }
开发者ID:phpro,项目名称:grumphp,代码行数:10,代码来源:JsonLintSpec.php


示例8: FilesCollection

 function it_throws_exception_if_the_process_fails(ProcessBuilder $processBuilder, Process $process, ContextInterface $context)
 {
     $processBuilder->setArguments(Argument::type('array'))->shouldBeCalled();
     $processBuilder->getProcess()->willReturn($process);
     $process->run()->shouldBeCalled();
     $process->isSuccessful()->willReturn(false);
     $process->getOutput()->shouldBeCalled();
     $context->getFiles()->willReturn(new FilesCollection(array(new SplFileInfo('test.php'))));
     $this->shouldThrow('GrumPHP\\Exception\\RuntimeException')->duringRun($context);
 }
开发者ID:xiris,项目名称:grumphp,代码行数:10,代码来源:PhpunitSpec.php


示例9: ProcessArgumentsCollection

 function it_lists_files_with_merge_conflicts(ProcessBuilder $processBuilder, ContextInterface $context, Process $process)
 {
     $arguments = new ProcessArgumentsCollection();
     $processBuilder->createArgumentsForCommand('git')->willReturn($arguments);
     $processBuilder->buildProcess($arguments)->willReturn($process);
     $context->getFiles()->willReturn(new FilesCollection([new SplFileInfo('file1.php', '.', 'file1.php')]));
     $result = $this->run($context);
     $result->shouldBeAnInstanceOf(TaskResultInterface::class);
     $result->isPassed()->shouldBe(true);
 }
开发者ID:phpro,项目名称:grumphp,代码行数:10,代码来源:ConflictSpec.php


示例10: array

 function it_throws_exception_if_the_process_is_successfull(GrumPHP $grumPHP, LocatorInterface $externalCommandLocator, ProcessBuilder $processBuilder, Process $process, ContextInterface $context)
 {
     $this->beConstructedWith($grumPHP, array('keywords' => array('var_dump(')), $externalCommandLocator, $processBuilder);
     $processBuilder->setArguments(Argument::type('array'))->shouldBeCalled();
     $processBuilder->getProcess()->willReturn($process);
     $process->run()->shouldBeCalled();
     $process->isSuccessful()->willReturn(true);
     $process->getOutput()->shouldBeCalled();
     $context->getFiles()->willReturn(new FilesCollection(array(new SplFileInfo('file1.php'))));
     $this->shouldThrow('GrumPHP\\Exception\\RuntimeException')->duringRun($context);
 }
开发者ID:Bilge,项目名称:grumphp,代码行数:11,代码来源:BlacklistSpec.php


示例11: LintErrorsCollection

 function it_throws_exception_if_the_process_fails(YamlLinter $linter, ContextInterface $context)
 {
     $linter->isInstalled()->willReturn(true);
     $linter->setObjectSupport(false)->shouldBeCalled();
     $linter->setExceptionOnInvalidType(false)->shouldBeCalled();
     $linter->lint(Argument::type('SplFileInfo'))->willReturn(new LintErrorsCollection(array(new YamlLintError(LintError::TYPE_ERROR, 0, 'error', 'file.yaml', 1, 1))));
     $context->getFiles()->willReturn(new FilesCollection(array(new SplFileInfo('file.yaml', '.', 'file.yaml'))));
     $result = $this->run($context);
     $result->shouldBeAnInstanceOf('GrumPHP\\Runner\\TaskResultInterface');
     $result->isPassed()->shouldBe(false);
 }
开发者ID:Big-Shark,项目名称:grumphp,代码行数:11,代码来源:YamlLintSpec.php


示例12: LintErrorsCollection

 function it_throws_exception_if_the_process_fails(XmlLinter $linter, ContextInterface $context)
 {
     $linter->isInstalled()->willReturn(true);
     $linter->setLoadFromNet(false)->shouldBeCalled();
     $linter->setXInclude(false)->shouldBeCalled();
     $linter->setDtdValidation(false)->shouldBeCalled();
     $linter->setSchemeValidation(false)->shouldBeCalled();
     $linter->lint(Argument::type('SplFileInfo'))->willReturn(new LintErrorsCollection(array(new XmlLintError(LintError::TYPE_ERROR, 0, 'error', 'file.xml', 1, 1))));
     $context->getFiles()->willReturn(new FilesCollection(array(new SplFileInfo('file.xml', '.', 'file.xml'))));
     $this->shouldThrow('GrumPHP\\Exception\\RuntimeException')->duringRun($context);
 }
开发者ID:brunocoelhor,项目名称:grumphp,代码行数:11,代码来源:XmlLintSpec.php


示例13: ProcessArgumentsCollection

 function it_throws_exception_if_the_process_fails(ProcessBuilder $processBuilder, Process $process, ContextInterface $context)
 {
     $arguments = new ProcessArgumentsCollection();
     $processBuilder->createArgumentsForCommand('behat')->willReturn($arguments);
     $processBuilder->buildProcess($arguments)->willReturn($process);
     $process->run()->shouldBeCalled();
     $process->isSuccessful()->willReturn(false);
     $process->getOutput()->shouldBeCalled();
     $context->getFiles()->willReturn(new FilesCollection(array(new SplFileInfo('test.php', '.', 'test.php'))));
     $this->shouldThrow('GrumPHP\\Exception\\RuntimeException')->duringRun($context);
 }
开发者ID:aaa2000,项目名称:grumphp,代码行数:11,代码来源:BehatSpec.php


示例14: ProcessArgumentsCollection

 function it_throws_exception_if_the_process_fails(ProcessBuilder $processBuilder, Process $process, ContextInterface $context)
 {
     $arguments = new ProcessArgumentsCollection();
     $processBuilder->createArgumentsForCommand('composer')->willReturn($arguments);
     $processBuilder->buildProcess($arguments)->willReturn($process);
     $process->run()->shouldBeCalled();
     $process->isSuccessful()->willReturn(false);
     $context->getFiles()->willReturn(new FilesCollection(array(new SplFileInfo('composer.json', '.', 'composer.json'))));
     $result = $this->run($context);
     $result->shouldBeAnInstanceOf('GrumPHP\\Runner\\TaskResultInterface');
     $result->isPassed()->shouldBe(false);
 }
开发者ID:Big-Shark,项目名称:grumphp,代码行数:12,代码来源:ComposerSpec.php


示例15: array

 function it_throws_exception_if_the_process_is_successfull(GrumPHP $grumPHP, ProcessBuilder $processBuilder, Process $process, ContextInterface $context)
 {
     $grumPHP->getTaskConfiguration('git_blacklist')->willReturn(array('keywords' => array('var_dump(')));
     $arguments = new ProcessArgumentsCollection();
     $processBuilder->createArgumentsForCommand('git')->willReturn($arguments);
     $processBuilder->buildProcess($arguments)->willReturn($process);
     $process->run()->shouldBeCalled();
     $process->isSuccessful()->willReturn(true);
     $process->getOutput()->shouldBeCalled();
     $context->getFiles()->willReturn(new FilesCollection(array(new SplFileInfo('file1.php', '.', 'file1.php'))));
     $this->shouldThrow('GrumPHP\\Exception\\RuntimeException')->duringRun($context);
 }
开发者ID:alexlondon07,项目名称:grumphp,代码行数:12,代码来源:BlacklistSpec.php


示例16: ProcessArgumentsCollection

 function it_throws_exception_if_the_process_fails(ProcessBuilder $processBuilder, Process $process, ContextInterface $context)
 {
     $arguments = new ProcessArgumentsCollection();
     $processBuilder->createArgumentsForCommand('phing')->willReturn($arguments);
     $processBuilder->buildProcess($arguments)->willReturn($process);
     $process->run()->shouldBeCalled();
     $process->isSuccessful()->willReturn(false);
     $context->getFiles()->willReturn(new FilesCollection([new SplFileInfo('test.php', '.', 'test.php')]));
     $result = $this->run($context);
     $result->shouldBeAnInstanceOf(TaskResultInterface::class);
     $result->isPassed()->shouldBe(false);
 }
开发者ID:phpro,项目名称:grumphp,代码行数:12,代码来源:PhingSpec.php


示例17: LintErrorsCollection

 function it_throws_exception_if_the_process_fails(XmlLinter $linter, ContextInterface $context)
 {
     $linter->isInstalled()->willReturn(true);
     $linter->setLoadFromNet(false)->shouldBeCalled();
     $linter->setXInclude(false)->shouldBeCalled();
     $linter->setDtdValidation(false)->shouldBeCalled();
     $linter->setSchemeValidation(false)->shouldBeCalled();
     $linter->lint(Argument::type('SplFileInfo'))->willReturn(new LintErrorsCollection([new XmlLintError(LintError::TYPE_ERROR, 0, 'error', 'file.xml', 1, 1)]));
     $context->getFiles()->willReturn(new FilesCollection([new SplFileInfo('file.xml', '.', 'file.xml')]));
     $result = $this->run($context);
     $result->shouldBeAnInstanceOf(TaskResultInterface::class);
     $result->isPassed()->shouldBe(false);
 }
开发者ID:phpro,项目名称:grumphp,代码行数:13,代码来源:XmlLintSpec.php


示例18: run

 /**
  * {@inheritdoc}
  */
 public function run(ContextInterface $context)
 {
     $files = $context->getFiles()->name('*.json');
     if (0 === count($files)) {
         return;
     }
     $config = $this->getConfiguration();
     $this->linter->setDetectKeyConflicts($config['detect_key_conflicts']);
     $lintErrors = $this->lint($files);
     if ($lintErrors->count()) {
         throw new RuntimeException($lintErrors->__toString());
     }
 }
开发者ID:brunocoelhor,项目名称:grumphp,代码行数:16,代码来源:JsonLint.php


示例19: run

 /**
  * {@inheritdoc}
  */
 public function run(ContextInterface $context)
 {
     $files = $context->getFiles()->name('*.php');
     if (0 === count($files)) {
         return;
     }
     $config = $this->getConfiguration();
     $this->processBuilder->setArguments(array($this->getCommandLocation(), '--format=json', '--dry-run'));
     if ($config['level']) {
         $this->processBuilder->add('--level=' . $config['level']);
     }
     if ($config['config']) {
         $this->processBuilder->add('--config=' . $config['config']);
     }
     if ($config['config_file']) {
         $this->processBuilder->add('--config-file' . $config['config-file']);
     }
     if ($config['verbose']) {
         $this->processBuilder->add('--verbose');
     }
     if (count($config['fixers'])) {
         $this->processBuilder->add('--fixers=' . implode(',', $config['fixers']));
     }
     $this->processBuilder->add('fix');
     $messages = array();
     $suggest = array('You can fix all errors by running following commands:');
     $errorCount = 0;
     foreach ($files as $file) {
         $processBuilder = clone $this->processBuilder;
         $processBuilder->add($file);
         $process = $processBuilder->getProcess();
         $process->run();
         if (!$process->isSuccessful()) {
             $output = $process->getOutput();
             $json = json_decode($output, true);
             if ($json) {
                 if (isset($json['files'][0]['name']) && isset($json['files'][0]['appliedFixers'])) {
                     $messages[] = sprintf('%s) %s (%s)', ++$errorCount, $json['files'][0]['name'], implode(',', $json['files'][0]['appliedFixers']));
                 } elseif (isset($json['files'][0]['name'])) {
                     $messages[] = sprintf('%s) %s', ++$errorCount, $json['files'][0]['name']);
                 }
                 $suggest[] = str_replace(array("'--dry-run' ", "'--format=json' "), '', $process->getCommandLine());
             } else {
                 $messages[] = $output;
             }
         }
     }
     if (count($messages)) {
         throw new RuntimeException(implode("\n", $messages) . "\n" . "\n" . implode("\n", $suggest));
     }
 }
开发者ID:xiris,项目名称:grumphp,代码行数:54,代码来源:Phpcsfixer.php


示例20: TaskResultCollection

 function it_should_display_warning_of_non_blocking_failed_tasks(OutputInterface $output, TaskRunner $taskRunner, TaskInterface $task, ContextInterface $context)
 {
     $aTask = $task->getWrappedObject();
     $aContext = $context->getWrappedObject();
     $nonBlockingFailedTaskResult = TaskResult::createNonBlockingFailed($aTask, $aContext, 'non blocking task message');
     $taskResults = new TaskResultCollection();
     $taskResults->add($nonBlockingFailedTaskResult);
     $taskRunner->run($context)->willReturn($taskResults);
     $output->isDecorated()->willReturn(false);
     $output->getVerbosity()->willReturn(OutputInterface::VERBOSITY_NORMAL);
     $output->writeln(Argument::containingString('non blocking task message'))->shouldBeCalled();
     $output->writeln(Argument::any())->shouldBeCalled();
     $this->run($output, $context);
 }
开发者ID:Big-Shark,项目名称:grumphp,代码行数:14,代码来源:TaskRunnerHelperSpec.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Common\Collection类代码示例发布时间:2022-05-23
下一篇:
PHP Configuration\GrumPHP类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap