update v1.0.4

This commit is contained in:
sujitprasad
2016-01-04 18:05:45 +05:30
parent 372485336b
commit 4864e5a3f1
529 changed files with 20956 additions and 8178 deletions

66
vendor/sebastian/diff/.php_cs vendored Normal file
View File

@@ -0,0 +1,66 @@
<?php
$finder = Symfony\CS\Finder\DefaultFinder::create()
->files()
->in('src')
->in('tests')
->name('*.php');
return Symfony\CS\Config\Config::create()
->level(\Symfony\CS\FixerInterface::NONE_LEVEL)
->fixers(
array(
'align_double_arrow',
'align_equals',
'braces',
'concat_with_spaces',
'duplicate_semicolon',
'elseif',
'empty_return',
'encoding',
'eof_ending',
'extra_empty_lines',
'function_call_space',
'function_declaration',
'indentation',
'join_function',
'line_after_namespace',
'linefeed',
'list_commas',
'lowercase_constants',
'lowercase_keywords',
'method_argument_space',
'multiple_use',
'namespace_no_leading_whitespace',
'no_blank_lines_after_class_opening',
'no_empty_lines_after_phpdocs',
'parenthesis',
'php_closing_tag',
'phpdoc_indent',
'phpdoc_no_access',
'phpdoc_no_empty_return',
'phpdoc_no_package',
'phpdoc_params',
'phpdoc_scalar',
'phpdoc_separation',
'phpdoc_to_comment',
'phpdoc_trim',
'phpdoc_types',
'phpdoc_var_without_name',
'remove_lines_between_uses',
'return',
'self_accessor',
'short_tag',
'single_line_after_imports',
'single_quote',
'spaces_before_semicolon',
'spaces_cast',
'ternary_spaces',
'trailing_spaces',
'trim_array_spaces',
'unused_use',
'visibility',
'whitespacy_lines'
)
)
->finder($finder);

View File

@@ -2,7 +2,7 @@
"name": "sebastian/diff",
"description": "Diff implementation",
"keywords": ["diff"],
"homepage": "http://www.github.com/sebastianbergmann/diff",
"homepage": "https://github.com/sebastianbergmann/diff",
"license": "BSD-3-Clause",
"authors": [
{
@@ -18,7 +18,7 @@
"php": ">=5.3.3"
},
"require-dev": {
"phpunit/phpunit": "~4.2"
"phpunit/phpunit": "~4.8"
},
"autoload": {
"classmap": [
@@ -27,7 +27,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "1.3-dev"
"dev-master": "1.4-dev"
}
}
}

View File

@@ -11,12 +11,6 @@
namespace SebastianBergmann\Diff;
/**
* @package Diff
* @author Sebastian Bergmann <sebastian@phpunit.de>
* @author Kore Nordmann <mail@kore-nordmann.de>
* @copyright Sebastian Bergmann <sebastian@phpunit.de>
* @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License
* @link http://www.github.com/sebastianbergmann/diff
*/
class Chunk
{

View File

@@ -11,12 +11,6 @@
namespace SebastianBergmann\Diff;
/**
* @package Diff
* @author Sebastian Bergmann <sebastian@phpunit.de>
* @author Kore Nordmann <mail@kore-nordmann.de>
* @copyright Sebastian Bergmann <sebastian@phpunit.de>
* @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License
* @link http://www.github.com/sebastianbergmann/diff
*/
class Diff
{

View File

@@ -16,13 +16,6 @@ use SebastianBergmann\Diff\LCS\MemoryEfficientImplementation;
/**
* Diff implementation.
*
* @package Diff
* @author Sebastian Bergmann <sebastian@phpunit.de>
* @author Kore Nordmann <mail@kore-nordmann.de>
* @copyright Sebastian Bergmann <sebastian@phpunit.de>
* @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License
* @link http://www.github.com/sebastianbergmann/diff
*/
class Differ
{
@@ -31,20 +24,27 @@ class Differ
*/
private $header;
/**
* @var bool
*/
private $showNonDiffLines;
/**
* @param string $header
*/
public function __construct($header = "--- Original\n+++ New\n")
public function __construct($header = "--- Original\n+++ New\n", $showNonDiffLines = true)
{
$this->header = $header;
$this->header = $header;
$this->showNonDiffLines = $showNonDiffLines;
}
/**
* Returns the diff between two arrays or strings as string.
*
* @param array|string $from
* @param array|string $to
* @param LongestCommonSubsequence $lcs
* @param array|string $from
* @param array|string $to
* @param LongestCommonSubsequence $lcs
*
* @return string
*/
public function diff($from, $to, LongestCommonSubsequence $lcs = null)
@@ -97,7 +97,9 @@ class Differ
}
if ($newChunk) {
$buffer .= "@@ @@\n";
if ($this->showNonDiffLines === true) {
$buffer .= "@@ @@\n";
}
$newChunk = false;
}
@@ -105,7 +107,7 @@ class Differ
$buffer .= '+' . $diff[$i][0] . "\n";
} elseif ($diff[$i][1] === 2 /* REMOVED */) {
$buffer .= '-' . $diff[$i][0] . "\n";
} else {
} elseif ($this->showNonDiffLines === true) {
$buffer .= ' ' . $diff[$i][0] . "\n";
}
}
@@ -124,9 +126,10 @@ class Differ
* - 1: ADDED: $token was added to $from
* - 0: OLD: $token is not changed in $to
*
* @param array|string $from
* @param array|string $to
* @param LongestCommonSubsequence $lcs
* @param array|string $from
* @param array|string $to
* @param LongestCommonSubsequence $lcs
*
* @return array
*/
public function diffToArray($from, $to, LongestCommonSubsequence $lcs = null)
@@ -221,8 +224,9 @@ class Differ
}
/**
* @param array $from
* @param array $to
* @param array $from
* @param array $to
*
* @return LongestCommonSubsequence
*/
private function selectLcsImplementation(array $from, array $to)
@@ -243,9 +247,10 @@ class Differ
/**
* Calculates the estimated memory footprint for the DP-based method.
*
* @param array $from
* @param array $to
* @return integer
* @param array $from
* @param array $to
*
* @return int
*/
private function calculateEstimatedFootprint(array $from, array $to)
{

View File

@@ -12,21 +12,15 @@ namespace SebastianBergmann\Diff\LCS;
/**
* Interface for implementations of longest common subsequence calculation.
*
* @package Diff
* @author Sebastian Bergmann <sebastian@phpunit.de>
* @author Kore Nordmann <mail@kore-nordmann.de>
* @copyright Sebastian Bergmann <sebastian@phpunit.de>
* @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License
* @link http://www.github.com/sebastianbergmann/diff
*/
interface LongestCommonSubsequence
{
/**
* Calculates the longest common subsequence of two arrays.
*
* @param array $from
* @param array $to
* @param array $from
* @param array $to
*
* @return array
*/
public function calculate(array $from, array $to);

View File

@@ -12,21 +12,15 @@ namespace SebastianBergmann\Diff\LCS;
/**
* Memory-efficient implementation of longest common subsequence calculation.
*
* @package Diff
* @author Sebastian Bergmann <sebastian@phpunit.de>
* @author Denes Lados <lados.denes@gmail.com>
* @copyright Sebastian Bergmann <sebastian@phpunit.de>
* @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License
* @link http://www.github.com/sebastianbergmann/diff
*/
class MemoryEfficientImplementation implements LongestCommonSubsequence
{
/**
* Calculates the longest common subsequence of two arrays.
*
* @param array $from
* @param array $to
* @param array $from
* @param array $to
*
* @return array
*/
public function calculate(array $from, array $to)
@@ -73,6 +67,7 @@ class MemoryEfficientImplementation implements LongestCommonSubsequence
/**
* @param array $from
* @param array $to
*
* @return array
*/
private function length(array $from, array $to)

View File

@@ -12,21 +12,15 @@ namespace SebastianBergmann\Diff\LCS;
/**
* Time-efficient implementation of longest common subsequence calculation.
*
* @package Diff
* @author Sebastian Bergmann <sebastian@phpunit.de>
* @author Kore Nordmann <mail@kore-nordmann.de>
* @copyright Sebastian Bergmann <sebastian@phpunit.de>
* @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License
* @link http://www.github.com/sebastianbergmann/diff
*/
class TimeEfficientImplementation implements LongestCommonSubsequence
{
/**
* Calculates the longest common subsequence of two arrays.
*
* @param array $from
* @param array $to
* @param array $from
* @param array $to
*
* @return array
*/
public function calculate(array $from, array $to)
@@ -47,7 +41,7 @@ class TimeEfficientImplementation implements LongestCommonSubsequence
for ($i = 1; $i <= $fromLength; ++$i) {
for ($j = 1; $j <= $toLength; ++$j) {
$o = ($j * $width) + $i;
$o = ($j * $width) + $i;
$matrix[$o] = max(
$matrix[$o - 1],
$matrix[$o - $width],

View File

@@ -11,17 +11,11 @@
namespace SebastianBergmann\Diff;
/**
* @package Diff
* @author Sebastian Bergmann <sebastian@phpunit.de>
* @author Kore Nordmann <mail@kore-nordmann.de>
* @copyright Sebastian Bergmann <sebastian@phpunit.de>
* @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License
* @link http://www.github.com/sebastianbergmann/diff
*/
class Line
{
const ADDED = 1;
const REMOVED = 2;
const ADDED = 1;
const REMOVED = 2;
const UNCHANGED = 3;
/**

View File

@@ -12,18 +12,12 @@ namespace SebastianBergmann\Diff;
/**
* Unified diff parser.
*
* @package Diff
* @author Sebastian Bergmann <sebastian@phpunit.de>
* @author Kore Nordmann <mail@kore-nordmann.de>
* @copyright Sebastian Bergmann <sebastian@phpunit.de>
* @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License
* @link http://www.github.com/sebastianbergmann/diff
*/
class Parser
{
/**
* @param string $string
* @param string $string
*
* @return Diff[]
*/
public function parse($string)
@@ -78,7 +72,7 @@ class Parser
isset($match['endrange']) ? max(1, $match['endrange']) : 1
);
$chunks[] = $chunk;
$chunks[] = $chunk;
$diffLines = array();
continue;
}

Binary file not shown.

View File

@@ -49,7 +49,7 @@ class TimeEfficientImplementationTest extends PHPUnit_Framework_TestCase
false, 0, 0.0, '', null, array(),
true, 1, 1.0, 'foo', array('foo', 'bar'), array('foo' => 'bar')
);
$to = $from;
$to = $from;
$common = $this->implementation->calculate($from, $to);
$this->assertEquals($from, $common);
@@ -81,19 +81,19 @@ class TimeEfficientImplementationTest extends PHPUnit_Framework_TestCase
public function testDistinctSequences()
{
$from = array('A');
$to = array('B');
$from = array('A');
$to = array('B');
$common = $this->implementation->calculate($from, $to);
$this->assertEquals(array(), $common);
$from = array('A', 'B', 'C');
$to = array('D', 'E', 'F');
$from = array('A', 'B', 'C');
$to = array('D', 'E', 'F');
$common = $this->implementation->calculate($from, $to);
$this->assertEquals(array(), $common);
foreach ($this->stress_sizes as $size) {
$from = range(1, $size);
$to = range($size + 1, $size * 2);
$from = range(1, $size);
$to = range($size + 1, $size * 2);
$common = $this->implementation->calculate($from, $to);
$this->assertEquals(array(), $common);
}
@@ -101,15 +101,15 @@ class TimeEfficientImplementationTest extends PHPUnit_Framework_TestCase
public function testCommonSubsequence()
{
$from = array('A', 'C', 'E', 'F', 'G' );
$from = array('A', 'C', 'E', 'F', 'G');
$to = array('A', 'B', 'D', 'E', 'H');
$expected = array('A', 'E' );
$expected = array('A', 'E');
$common = $this->implementation->calculate($from, $to);
$this->assertEquals($expected, $common);
$from = array('A', 'C', 'E', 'F', 'G' );
$to = array( 'B', 'C', 'D', 'E', 'F', 'H');
$expected = array('C', 'E', 'F' );
$from = array('A', 'C', 'E', 'F', 'G');
$to = array('B', 'C', 'D', 'E', 'F', 'H');
$expected = array('C', 'E', 'F');
$common = $this->implementation->calculate($from, $to);
$this->assertEquals($expected, $common);

View File

@@ -29,7 +29,7 @@ class Console
public function hasColorSupport()
{
if (DIRECTORY_SEPARATOR == '\\') {
return false !== getenv('ANSICON') || 'ON' === getenv('ConEmuANSI');
return false !== getenv('ANSICON') || 'ON' === getenv('ConEmuANSI') || 'xterm' === getenv('TERM');
}
if (!defined('STDOUT')) {

View File

@@ -121,7 +121,7 @@ final class Context
private function containsArray(array &$array)
{
$keys = array_keys($this->arrays, $array, true);
$hash = '_Key_' . hash('sha512', microtime(true));
$hash = '_Key_' . microtime(true);
foreach ($keys as $key) {
$this->arrays[$key][$hash] = $hash;