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


PHP Diff::render方法代码示例

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


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

示例1: diff

 /**
  * Get the difference between two files
  *
  * @static
  * @access private
  * @param string $a The path to the existing file
  * @param string $b The path to the new (replacement) file
  * @return string The unified diff between the two
  */
 private static function diff($a, $b)
 {
     $a_code = explode("\n", file_get_contents($a));
     $b_code = explode("\n", file_get_contents($b));
     $diff = new \Diff($b_code, $a_code, array('ignoreWhitespace' => TRUE, 'ignoreNewLines' => TRUE));
     return $diff->render(new \Diff_Renderer_Text_Unified());
 }
开发者ID:imarc,项目名称:opus,代码行数:16,代码来源:Processor.php

示例2: buildPatch

 public function buildPatch($originalFile, $modfiedFileName, PatchBuffer $buffer)
 {
     if (!$buffer->isModified()) {
         return '';
     }
     $diff = new \Diff($buffer->getOriginalContents(), $buffer->getModifiedContents());
     $renderer = new \Diff_Renderer_Text_Unified();
     return "--- {$originalFile}\n" . "+++ {$modfiedFileName}\n" . $diff->render($renderer);
 }
开发者ID:yashb,项目名称:generator,代码行数:9,代码来源:PhpDiffBuilder.php

示例3: testReplace

 public function testReplace()
 {
     $old = ['first', 'equal'];
     $new = ['second', 'equal'];
     $diff = new \Diff($old, $new);
     $renderer = new \VisualAppeal\Connect\Extensions\DiffRenderer();
     $render = @$diff->render($renderer);
     $this->assertContains('diff-change-replace', $render);
 }
开发者ID:rafaelvieiras,项目名称:connect,代码行数:9,代码来源:DiffRendererTest.php

示例4: compareVersions

 /**
  * Show difference between two versions.
  *
  * @param  \App\Version
  * @param  \App\Version
  * @return void
  */
 protected function compareVersions(Version $before, Version $after)
 {
     // Parse source
     $beforeArray = explode("\n", $before->source);
     $afterArray = explode("\n", $after->source);
     // Compare versions
     $diff = new \Diff($beforeArray, $afterArray, $options = []);
     // Load view
     return view('version.compare', ['title' => _('Versions'), 'subtitle' => _('Compare'), 'before' => $before, 'after' => $after, 'sideBySideDiff' => $diff->Render(new \Diff_Renderer_Html_SideBySide()), 'inlineDiff' => $diff->render(new \Diff_Renderer_Html_Inline())]);
 }
开发者ID:superdol,项目名称:Wiki,代码行数:17,代码来源:VersionController.php

示例5: compare

 public function compare(IResource $resourceA, IResource $resourceB)
 {
     $data_a = $resourceA->getCleanFields();
     $data_b = $resourceB->getCleanFields();
     $a = explode("\n", $data_a['snippet']);
     $b = explode("\n", $data_b['snippet']);
     $d = new \Diff($a, $b, []);
     $renderer = new \Diff_Renderer_Html_SideBySide();
     $diffc = $d->render($renderer);
     return !empty($diffc);
 }
开发者ID:JasperGrimm,项目名称:modvert2,代码行数:11,代码来源:BaseComparator.php

示例6: getDiffHtml

 public function getDiffHtml()
 {
     $old = explode("\n", $this->old_value);
     $new = explode("\n", $this->new_value);
     foreach ($old as $i => $line) {
         $old[$i] = rtrim($line, "\r\n");
     }
     foreach ($new as $i => $line) {
         $new[$i] = rtrim($line, "\r\n");
     }
     $diff = new \Diff($old, $new);
     return $diff->render(new \Diff_Renderer_Html_Inline());
 }
开发者ID:cornernote,项目名称:yii2-audit,代码行数:13,代码来源:AuditTrail.php

示例7: assertJsonResponseContent

 protected function assertJsonResponseContent($response, $filename)
 {
     $expectedResponse = file_get_contents(__DIR__ . sprintf('/../Tests/Responses/%s.json', $filename));
     $actualResponse = $response->getContent();
     $actualResponse = json_encode(json_decode($actualResponse), JSON_PRETTY_PRINT);
     $factory = new SimpleFactory();
     $matcher = $factory->createMatcher();
     $result = $matcher->match($actualResponse, $expectedResponse);
     if (!$result) {
         echo $matcher->getError();
         $expectedResponse = explode(PHP_EOL, (string) $expectedResponse);
         $actualResponse = explode(PHP_EOL, (string) $actualResponse);
         $diff = new \Diff($expectedResponse, $actualResponse, array());
         $renderer = new \Diff_Renderer_Text_Unified();
         echo $diff->render($renderer);
     }
     $this->assertTrue($result);
 }
开发者ID:Strontium-90,项目名称:Sylius,代码行数:18,代码来源:ApiTestCase.php

示例8: compare

 public function compare($expected, $actual)
 {
     $expected = explode(PHP_EOL, (string) $expected);
     $actual = explode(PHP_EOL, (string) $actual);
     $diff = new \Diff($expected, $actual, array());
     $renderer = new \Diff_Renderer_Text_Unified();
     $text = $diff->render($renderer);
     $lines = array();
     foreach (explode("\n", $text) as $line) {
         if (0 === strpos($line, '-')) {
             $lines[] = sprintf('<diff-del>%s</diff-del>', $line);
         } elseif (0 === strpos($line, '+')) {
             $lines[] = sprintf('<diff-add>%s</diff-add>', $line);
         } else {
             $lines[] = $line;
         }
     }
     return sprintf("<code>%s%s</code>", PHP_EOL, implode(PHP_EOL, $lines));
 }
开发者ID:EnmanuelCode,项目名称:backend-laravel,代码行数:19,代码来源:StringEngine.php

示例9: diffWithOnline

 public function diffWithOnline($file)
 {
     $localSourceDir = $this->config->getDeployFromDir();
     $remoteSourceDir = $this->config->getTargetWorkspace();
     $cmd[] = "cat {$remoteSourceDir}/{$file}";
     $command = implode(' && ', $cmd);
     $host = GlobalHelper::str2arr($this->config->hosts)[0];
     if ($this->runRemoteCommand($command, 0, $host)) {
         $contentOld = explode(PHP_EOL, substr($this->log, strlen($host . ' : ')));
         array_walk($contentOld, function (&$line) {
             $line = rtrim($line, "\r\n");
         });
     } else {
         $contentOld = [];
     }
     $contentNew = file("{$localSourceDir}/{$file}");
     array_walk($contentNew, function (&$line) {
         $line = rtrim($line, "\r\n");
     });
     $diff = new \Diff($contentOld, $contentNew);
     return $diff->render(new \Diff_Renderer_Html_Array());
 }
开发者ID:ashehui,项目名称:walle-web,代码行数:22,代码来源:CodeFile.php

示例10: diff

 public function diff()
 {
     $this->test();
     if ($this->wasSuccessfull()) {
         return;
     }
     global $HTML;
     $HTML->p('Diff', '.label');
     $a = explode("\n", $this->prediction);
     $b = explode("\n", $this->_result);
     $options = array();
     // Initialize the diff class
     $diff = new \Diff($a, $b, $options);
     $renderer = new \Diff_Renderer_Html_Inline();
     echo $diff->render($renderer);
 }
开发者ID:xiphe,项目名称:html,代码行数:16,代码来源:TestCase.php

示例11: theResponseJSONMatches

 /**
  * @Then /^the response JSON matches "([^"]*)"$/
  *
  * @param string $expectedJsonFilePath
  *
  * @throws \Exception
  */
 public function theResponseJSONMatches($expectedJsonFilePath)
 {
     $factory = new PHPMatcherFactory();
     $matcher = $factory->createMatcher();
     $responseJson = json_encode(json_decode($this->getResponseWithAssertion()->getContent()), JSON_PRETTY_PRINT);
     $expectedJson = file_get_contents($this->getFilePath($expectedJsonFilePath));
     if ($matcher->match($responseJson, $expectedJson) === false) {
         echo $matcher->getError();
         $difference = new \Diff(explode(PHP_EOL, $expectedJson), explode(PHP_EOL, $responseJson));
         echo $difference->render(new \Diff_Renderer_Text_Unified());
         throw new \Exception('Response JSON did not match.');
     }
 }
开发者ID:PurpleYellow,项目名称:Saints,代码行数:20,代码来源:SymfonyClientContext.php

示例12: getDiff

 public function getDiff($field, $new, $old)
 {
     $config = ['ignoreNewLines' => true, 'ignoreWhitespace' => true, 'ignoreCase' => true];
     $diff = new \Diff((array) $old, (array) $new, $config);
     return $diff->render(new \Diff_Renderer_Html_SideBySide());
 }
开发者ID:jippi,项目名称:cakephp-audit-log,代码行数:6,代码来源:AuditLogHelper.php

示例13: diffAction

 /**
  * Shows a visual diff of what has changed
  */
 public function diffAction()
 {
     $id = (int) $this->dispatcher->getParam('id');
     $revision = (int) $this->dispatcher->getParam('revision');
     $diffVersion = Versions::findFirst(array('page_id = :id: AND version = :revision:', 'bind' => array('id' => $id, 'revision' => $revision)));
     if ($diffVersion === false) {
         return $this->dispatcher->forward(array('action' => 'error404'));
     }
     $currentVersion = Pages::findFirst($id);
     $diffEngine = new \Diff(explode("\n", $diffVersion->content), explode("\n", $currentVersion->content), []);
     $renderer = new \Diff_Renderer_Html_SideBySide();
     $this->view->diff = $diffEngine->render($renderer);
     $this->view->page = $currentVersion;
     $this->view->revision = $diffVersion->version;
     $this->view->title = "diff – " . $currentVersion->title;
 }
开发者ID:niden,项目名称:kolibri,代码行数:19,代码来源:KolibriController.php

示例14: htmlspecialchars

// Initialize the diff class
$diff = new Diff($a, $b, $options);
?>
		<h2>Side by Side Diff</h2>
		<?php 
// Generate a side by side diff
require_once __DIR__ . '/../lib/Diff/Renderer/Html/SideBySide.php';
$renderer = new Diff_Renderer_Html_SideBySide();
echo $diff->Render($renderer);
?>
		<h2>Inline Diff</h2>
		<?php 
// Generate an inline diff
require_once __DIR__ . '/../lib/Diff/Renderer/Html/Inline.php';
$renderer = new Diff_Renderer_Html_Inline();
echo $diff->render($renderer);
?>
		<h2>Unified Diff</h2>
		<pre><?php 
// Generate a unified diff
require_once __DIR__ . '/../lib/Diff/Renderer/Text/Unified.php';
$renderer = new Diff_Renderer_Text_Unified();
echo htmlspecialchars($diff->render($renderer));
?>
		</pre>
		<h2>Context Diff</h2>
		<pre><?php 
// Generate a context diff
require_once __DIR__ . '/../lib/Diff/Renderer/Text/Context.php';
$renderer = new Diff_Renderer_Text_Context();
echo htmlspecialchars($diff->render($renderer));
开发者ID:J5lx,项目名称:luminous,代码行数:31,代码来源:example.php

示例15: compareContent

 /**
  * Compare given content with the subject's one in the given language.
  *
  * @param mixed  $subject
  * @param array  $content
  * @param string $language
  * @param bool   $original
  *
  * @return array
  */
 protected function compareContent($subject, array $content, $language, $original = true)
 {
     $properties = array_keys($content);
     $values = $this->getProperties($subject, $properties, $language);
     $diffs = [];
     $renderer = new \Diff_Renderer_Html_SideBySide();
     foreach ($values as $property => $value) {
         $a = [$value];
         $b = [$content[$property]];
         if ($original) {
             $b = [$content[$property]['original_phrase']];
         }
         $diff = new \Diff($a, $b);
         $diffs[$property] = $diff->render($renderer);
     }
     return $diffs;
 }
开发者ID:worldia,项目名称:textmaster-api,代码行数:27,代码来源:AbstractAdapter.php


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