Skip to content

Commit

Permalink
vendor: Update php-diff with fixes
Browse files Browse the repository at this point in the history
Version is based on:
* chrisboulton/php-diff@3cb3f7c
* and chrisboulton/php-diff#50

Also see SOURCE
  • Loading branch information
pprkut authored and lazyfrosch committed Apr 16, 2018
1 parent 8e28f7f commit 525b316
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 20 deletions.
16 changes: 13 additions & 3 deletions library/vendor/php-diff/SOURCE
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
#!/bin/bash

set -ex

# version based on current master 3cb3f7ce6bb8b910f5a41ea1887b1faceba6a7d7
# plus https://github.com/chrisboulton/php-diff/pull/50
git clone https://github.com/chrisboulton/php-diff.git
# Last used commit:

cd php-diff
git checkout f4db229d7ae8dffa0a4f90e1adbec9bf22c93d99

git fetch origin pull/50/head:pr
git checkout a9f124f81a9436138879e56157c6cced52a6d95b
git show -s

rm -rf .git
rm -rf .gitignore
rm -rf composer.json
rm -rf example
rm -rf example tests phpunit.xml
cd ..
14 changes: 4 additions & 10 deletions library/vendor/php-diff/lib/Diff/Renderer/Html/Array.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,27 +176,21 @@ protected function formatLines($lines)
{
$lines = array_map(array($this, 'ExpandTabs'), $lines);
$lines = array_map(array($this, 'HtmlSafe'), $lines);
$callback = array($this, 'fixMatchedSpaces');
foreach($lines as &$line) {
// $line = preg_replace('# ( +)|^ #e', "\$this->fixSpaces('\\1')", $line);
$line = preg_replace_callback('# ( +)|^ #', $callback, $line);
$line = preg_replace_callback('# ( +)|^ #', array($this, 'fixSpaces'), $line);
}
return $lines;
}

protected function fixMatchedSpaces($m)
{
return $this->fixSpaces($m[1]);
}

/**
* Replace a string containing spaces with a HTML representation using  .
*
* @param string $spaces The string of spaces.
* @param string[] $matches Array with preg matches.
* @return string The HTML representation of the string.
*/
function fixSpaces($spaces='')
private function fixSpaces(array $matches)
{
$spaces = $matches[1];
$count = strlen($spaces);
if($count == 0) {
return '';
Expand Down
4 changes: 2 additions & 2 deletions library/vendor/php-diff/lib/Diff/Renderer/Html/Inline.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ public function render()
foreach($change['changed']['lines'] as $no => $line) {
$toLine = $change['changed']['offset'] + $no + 1;
$html .= '<tr>';
$html .= '<th>'.$toLine.'</th>';
$html .= '<th>&nbsp;</th>';
$html .= '<th>'.$toLine.'</th>';
$html .= '<td class="Right"><span>'.$line.'</span></td>';
$html .= '</tr>';
}
Expand All @@ -140,4 +140,4 @@ public function render()
$html .= '</table>';
return $html;
}
}
}
10 changes: 5 additions & 5 deletions library/vendor/php-diff/lib/Diff/SequenceMatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ class Diff_SequenceMatcher
/**
* @var array The first sequence to compare against.
*/
private $a = null;
private $a = array();

/**
* @var array The second sequence.
*/
private $b = null;
private $b = array();

/**
* @var array Array of characters that are considered junk from the second sequence. Characters are the array key.
Expand Down Expand Up @@ -86,8 +86,8 @@ class Diff_SequenceMatcher
*/
public function __construct($a, $b, $junkCallback=null, $options)
{
$this->a = null;
$this->b = null;
$this->a = array();
$this->b = array();
$this->junkCallback = $junkCallback;
$this->setOptions($options);
$this->setSequences($a, $b);
Expand Down Expand Up @@ -739,4 +739,4 @@ private function tupleSort($a, $b)
return 1;
}
}
}
}

0 comments on commit 525b316

Please sign in to comment.