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


PHP Differ::diff方法代码示例

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


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

示例1: diff

 /**
  * {@inheritdoc}
  */
 public function diff($old, $new)
 {
     return implode(PHP_EOL, array_map(function ($string) {
         $string = preg_replace('/^(\\+){3}/', '<info>+++</info>', $string);
         $string = preg_replace('/^(\\+){1}/', '<info>+</info>', $string);
         $string = preg_replace('/^(\\-){3}/', '<error>---</error>', $string);
         $string = preg_replace('/^(\\-){1}/', '<error>-</error>', $string);
         return $string;
     }, explode(PHP_EOL, $this->differ->diff($old, $new))));
 }
开发者ID:thekabal,项目名称:tki,代码行数:13,代码来源:SebastianBergmannDiffer.php

示例2: difObj

 public function difObj($obj1, $obj2)
 {
     $differ = new Differ();
     $arr = [];
     foreach ($obj1 as $a => $v) {
         if ($v != $obj2[$a]) {
             if (is_numeric($v) && is_numeric($obj2[$a])) {
                 $arr[$a] = $v;
             } else {
                 /*
                 if (substr_count( $v, "\n" ) > 1 && substr_count( $obj2[$a], "\n" ) > 1)
                 {
                 	$arr[$a] = $differ->diff($v,$obj2[$a]);	
                 }
                 else
                 {	
                 	$arr[$a] = $differ->diff(self::strLine($v),self::strLine($obj2[$a]));
                 }
                 */
                 $arr[$a] = $differ->diff($v, $obj2[$a]);
             }
         }
     }
     return $arr;
 }
开发者ID:evgenmil,项目名称:versioning,代码行数:25,代码来源:Libs.php

示例3: diffTemplate

 /**
  * @inheritdoc
  */
 public function diffTemplate(Stack $stack)
 {
     $actual_template = $stack->provisioned ? $this->cfn($stack)->getTemplate(['StackName' => $stack->get('name')])->get('TemplateBody') : '{}';
     $new_template = $this->createTemplate($stack);
     $arr_diff = new Differ();
     $diff = $arr_diff->diff(json_encode(json_decode($actual_template, true), JSON_PRETTY_PRINT), json_encode(json_decode($new_template, true), JSON_PRETTY_PRINT));
     return $diff;
 }
开发者ID:sourcestream,项目名称:highcore-api,代码行数:11,代码来源:CloudFormer.php

示例4: getDiff

 /**
  * @param string $expected
  * @param string $actual
  * @return string
  */
 private function getDiff($expected = '', $actual = '')
 {
     if (!$actual && !$expected) {
         return '';
     }
     $differ = new Differ('');
     return $differ->diff($expected, $actual);
 }
开发者ID:solutionDrive,项目名称:Codeception,代码行数:13,代码来源:DiffFactory.php

示例5: execute

 protected function execute(array $arguments)
 {
     if (isset($arguments[0]) && isset($arguments[1])) {
         $differ = new Differ();
         return $differ->diff($arguments[0], $arguments[1]);
     }
     throw new InvalidArgumentException('strings invalid');
 }
开发者ID:sysatom,项目名称:workflow,代码行数:8,代码来源:DiffText.php

示例6: getDiff

 /**
  * Get difference of two variables.
  *
  * @param mixed $actual
  *
  * @return string
  */
 protected function getDiff($actual)
 {
     if (is_array($actual) or is_array($this->expected)) {
         $diff = new Diff\Differ('--- Expected' . PHP_EOL . '+++ Actual' . PHP_EOL);
         return $diff->diff(var_export($this->expected, true), var_export($actual, true));
     } else {
         return 'expected ' . $this->formatter($this->expected) . ', but given ' . $this->formatter($actual);
     }
 }
开发者ID:komex,项目名称:unteist,代码行数:16,代码来源:EqualTo.php

示例7: diffFiles

 private function diffFiles($path, $from, $to)
 {
     if (!$this->compareFiles($from, $to)) {
         $differ = new Differ();
         $this->filesystem->put($path, $differ->diff($from, $to));
         $this->diffedFiles[] = $path;
     } else {
         $this->filesystem->put($path, $to);
     }
 }
开发者ID:joecianflone,项目名称:heisenberg-toolkit-installer,代码行数:10,代码来源:Mover.php

示例8: stringDiff

 protected function stringDiff($old, $new)
 {
     $diff = $this->diff->diff($old, $new);
     $diff = implode(PHP_EOL, array_map(function ($string) {
         $string = preg_replace('/^(\\+){3}/', '<info>+++</info>', $string);
         $string = preg_replace('/^(\\+){1}/', '<info>+</info>', $string);
         $string = preg_replace('/^(\\-){3}/', '<error>---</error>', $string);
         $string = preg_replace('/^(\\-){1}/', '<error>-</error>', $string);
         $string = str_repeat(' ', 6) . $string;
         return $string;
     }, explode(PHP_EOL, $diff)));
     return $diff;
 }
开发者ID:nazimodi,项目名称:PHP-CS-Fixer,代码行数:13,代码来源:Fixer.php

示例9: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $finder = (new Finder())->in($input->getArgument('input'))->exclude($input->getOption('exclude'))->name('*.php')->files();
     $files = [];
     foreach ($finder as $file) {
         $files[] = $file->getRealpath();
     }
     $project = ProjectFactory::createInstance()->create('current', $files);
     $converter = new Converter();
     $output->writeln('<comment>Running the PHPDoc to Type Hint converter. Brought to you by Kévin Dunglas and Les-Tilleuls.coop.</comment>');
     $output->writeln('');
     $progress = new ProgressBar($output, count($files));
     $changed = [];
     foreach ($project->getFiles() as $file) {
         $old = $file->getSource();
         $new = $converter->convert($project, $file);
         if ($new !== $old) {
             if ($input->getOption('dry-run')) {
                 $changed[] = ['path' => $file->getPath(), 'diff' => $this->differ->diff($old, $new)];
             } else {
                 file_put_contents($file->getPath(), $new);
             }
         }
         $progress->advance();
     }
     $progress->finish();
     $output->writeln('');
     $output->writeln('');
     foreach ($changed as $i => $file) {
         $output->writeln(sprintf('<fg=blue>%d) %s</>', $i + 1, $file['path']));
         $output->writeln('');
         $output->writeln($file['diff']);
         $output->writeln('');
     }
     $output->writeln('<info>Conversion done.</info>');
 }
开发者ID:dunglas,项目名称:phpdoc-to-typehint,代码行数:39,代码来源:ConvertCommand.php

示例10: additionalFailureDescription

 protected function additionalFailureDescription($other)
 {
     $from = preg_split('(\\r\\n|\\r|\\n)', $this->string);
     $to = preg_split('(\\r\\n|\\r|\\n)', $other);
     foreach ($from as $index => $line) {
         if (isset($to[$index]) && $line !== $to[$index]) {
             $line = $this->createPatternFromFormat($line);
             if (preg_match($line, $to[$index]) > 0) {
                 $from[$index] = $to[$index];
             }
         }
     }
     $this->string = implode("\n", $from);
     $other = implode("\n", $to);
     $differ = new Differ("--- Expected\n+++ Actual\n");
     return $differ->diff($this->string, $other);
 }
开发者ID:noikiy,项目名称:phpunit,代码行数:17,代码来源:StringMatches.php

示例11: execute

 /**
  * @see Command
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $files = $this->getResource($input);
     if (count($files) != 2) {
         throw new \InvalidArgumentException('You have to define 2 files.');
     }
     $results = array();
     foreach ($files as $file) {
         if ($file->isCrypted()) {
             $file = $this->getBackend($input->getOption('configuration-file'))->setIO($this->getIO())->decrypt($file);
         }
     }
     $it = $files->getIterator();
     $output->writeln(sprintf('<info>Diff between <comment>%s</comment> and <comment>%s</comment></info>', $it[0]->getSourceFile(), $it[1]->getSourceFile()));
     $from = $this->clean($it[0]->isCrypted() ? $it[0]->getTargetContent() : $it[0]->getSourceContent());
     $to = $this->clean($it[1]->isCrypted() ? $it[1]->getTargetContent() : $it[1]->getSourceContent());
     if ($from == $to) {
         $output->writeln('no diff.');
     } else {
         $differ = new Differ();
         echo $differ->diff($from, $to);
     }
 }
开发者ID:rezzza,项目名称:vaultage,代码行数:26,代码来源:DiffCommand.php

示例12: compareGlobalStateSnapshotPart

 /**
  * @param  array  $before
  * @param  array  $after
  * @param  string $header
  * @throws PHPUnit_Framework_RiskyTestError
  */
 private function compareGlobalStateSnapshotPart(array $before, array $after, $header)
 {
     if ($before != $after) {
         $differ = new Differ($header);
         $exporter = new Exporter();
         $diff = $differ->diff($exporter->export($before), $exporter->export($after));
         throw new PHPUnit_Framework_RiskyTestError($diff);
     }
 }
开发者ID:emsdog,项目名称:lumen-todo,代码行数:15,代码来源:TestCase.php

示例13: testTypesOtherThanArrayAndStringCanBePassed

 public function testTypesOtherThanArrayAndStringCanBePassed()
 {
     $this->assertEquals("--- Original\n+++ New\n@@ @@\n-1\n+2\n", $this->differ->diff(1, 2));
 }
开发者ID:EnmanuelCode,项目名称:backend-laravel,代码行数:4,代码来源:DifferTest.php

示例14: __construct

 /**
  * @param $text
  */
 public function __construct($old, $new)
 {
     $differ = new Differ('');
     $this->diff = $differ->diff($old, $new);
 }
开发者ID:sledgehammer,项目名称:wordpress,代码行数:8,代码来源:ColorDiff.php

示例15: getDiff

 /**
  *
  * @return string
  */
 public function getDiff()
 {
     if (!$this->actualAsString && !$this->expectedAsString) {
         return '';
     }
     $differ = new Differ("\n--- Expected\n+++ Actual\n");
     return $differ->diff($this->expectedAsString, $this->actualAsString);
 }
开发者ID:ngitimfoyo,项目名称:Nyari-AppPHP,代码行数:12,代码来源:ComparisonFailure.php


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