From 53502f22744a9bb1dbbbe7d9e25e5c9224cd0043 Mon Sep 17 00:00:00 2001 From: JBlond Date: Sat, 19 Jan 2019 11:39:07 +0100 Subject: [PATCH 1/7] return type match --- lib/jblond/Diff/SequenceMatcher.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/jblond/Diff/SequenceMatcher.php b/lib/jblond/Diff/SequenceMatcher.php index 2fe50d41..4a0b6295 100644 --- a/lib/jblond/Diff/SequenceMatcher.php +++ b/lib/jblond/Diff/SequenceMatcher.php @@ -237,7 +237,7 @@ private function chainB() * for the list of junk characters. * * @param string $b - * @return boolean $b True if the character is considered junk. False if not. + * @return bool $b True if the character is considered junk. False if not. */ private function isBJunk($b) : bool { @@ -349,7 +349,7 @@ public function findLongestMatch($alo, $ahi, $blo, $bhi) : array * * @param int $aIndex Line number to check against in a. * @param int $bIndex Line number to check against in b. - * @return boolean True if the lines are different and false if not. + * @return bool True if the lines are different and false if not. */ public function linesAreDifferent($aIndex, $bIndex) : bool { From 4113efe04db89982a57190446923a906fd3ad8ec Mon Sep 17 00:00:00 2001 From: JBlond Date: Sat, 19 Jan 2019 11:39:50 +0100 Subject: [PATCH 2/7] remove useless use import --- lib/jblond/Diff/SequenceMatcher.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/jblond/Diff/SequenceMatcher.php b/lib/jblond/Diff/SequenceMatcher.php index 4a0b6295..1791cfc3 100644 --- a/lib/jblond/Diff/SequenceMatcher.php +++ b/lib/jblond/Diff/SequenceMatcher.php @@ -2,8 +2,6 @@ declare(strict_types=1); namespace jblond\Diff; -use phpDocumentor\Reflection\Types\Boolean; - /** * Sequence matcher for Diff * From aea243727ff31b681db114169af731bd438275d2 Mon Sep 17 00:00:00 2001 From: JBlond Date: Sat, 19 Jan 2019 11:46:18 +0100 Subject: [PATCH 3/7] done. support for PSR4 is given --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index b70cecd4..33e9c038 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,6 @@ Todo * Ability to ignore blank line changes * 3 way diff support * Performance optimizations - * Add namespace / PSR4 Contributors --------------------- From 6fa3c766de7809301fc347589eef8454c8b8fb4c Mon Sep 17 00:00:00 2001 From: JBlond Date: Sat, 19 Jan 2019 12:06:01 +0100 Subject: [PATCH 4/7] add code sniffer PSR2 file --- phpcs.xml | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 phpcs.xml diff --git a/phpcs.xml b/phpcs.xml new file mode 100644 index 00000000..536e8906 --- /dev/null +++ b/phpcs.xml @@ -0,0 +1,8 @@ + + + php-diff + + + + + From fe21917b41189d79dd9a3d8ccd9bc64e7cb9948e Mon Sep 17 00:00:00 2001 From: JBlond Date: Sat, 19 Jan 2019 16:46:49 +0100 Subject: [PATCH 5/7] fix PSR1.Files.SideEffects.FoundWithSymbols --- lib/Autoloader.php | 2 +- tests/Diff/Renderer/ArrayTest.php | 7 ++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/lib/Autoloader.php b/lib/Autoloader.php index a9c3a002..284f5048 100644 --- a/lib/Autoloader.php +++ b/lib/Autoloader.php @@ -25,7 +25,7 @@ private function __autoload($class) $dir = str_replace('\\', '/', __DIR__); if (file_exists($dir . '/' . $class . '.php')) { /** @noinspection PhpIncludeInspection */ - require $dir . '/' . $class . '.php'; + require_once $dir . '/' . $class . '.php'; } } } diff --git a/tests/Diff/Renderer/ArrayTest.php b/tests/Diff/Renderer/ArrayTest.php index df017c81..424aaa6b 100644 --- a/tests/Diff/Renderer/ArrayTest.php +++ b/tests/Diff/Renderer/ArrayTest.php @@ -2,9 +2,6 @@ declare(strict_types=1); namespace Tests\Diff\Renderer\Html; -require "../../../lib/Autoloader.php"; - -use jblond\Autoloader; use jblond\Diff\Renderer\Html\HtmlArray; use PHPUnit\Framework\TestCase; @@ -23,9 +20,9 @@ class ArrayTest extends TestCase */ public function __construct($name = null, array $data = [], $dataName = '') { - + require "../../../lib/Autoloader.php"; + new \jblond\Autoloader(); parent::__construct($name, $data, $dataName); - new Autoloader(); } /** From 148e78748d521df0fb66b531cf331b39a603d626 Mon Sep 17 00:00:00 2001 From: JBlond Date: Sat, 19 Jan 2019 16:52:53 +0100 Subject: [PATCH 6/7] adding curly brackets --- lib/jblond/Diff/Renderer/Html/HtmlArray.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/jblond/Diff/Renderer/Html/HtmlArray.php b/lib/jblond/Diff/Renderer/Html/HtmlArray.php index 89ad37e0..95ae4168 100644 --- a/lib/jblond/Diff/Renderer/Html/HtmlArray.php +++ b/lib/jblond/Diff/Renderer/Html/HtmlArray.php @@ -86,8 +86,9 @@ public function mbSubstrReplace($string, $replacement, $start, $length = null) // $start if (is_array($start)) { $start = array_slice($start, 0, $num); - foreach ($start as $key => $value) + foreach ($start as $key => $value) { $start[$key] = is_int($value) ? $value : 0; + } } else { $start = array_pad(array($start), $num, $start); } @@ -96,8 +97,9 @@ public function mbSubstrReplace($string, $replacement, $start, $length = null) $length = array_fill(0, $num, 0); } elseif (is_array($length)) { $length = array_slice($length, 0, $num); - foreach ($length as $key => $value) + foreach ($length as $key => $value) { $length[$key] = isset($value) ? (is_int($value) ? $value : $num) : 0; + } } else { $length = array_pad(array($length), $num, $length); } From 354bf5c6b51e740539c64827634a9ba805c76a06 Mon Sep 17 00:00:00 2001 From: JBlond Date: Sat, 19 Jan 2019 16:55:43 +0100 Subject: [PATCH 7/7] fix tabs --- lib/jblond/Diff/Renderer/Html/HtmlArray.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/jblond/Diff/Renderer/Html/HtmlArray.php b/lib/jblond/Diff/Renderer/Html/HtmlArray.php index 95ae4168..b788c24e 100644 --- a/lib/jblond/Diff/Renderer/Html/HtmlArray.php +++ b/lib/jblond/Diff/Renderer/Html/HtmlArray.php @@ -88,7 +88,7 @@ public function mbSubstrReplace($string, $replacement, $start, $length = null) $start = array_slice($start, 0, $num); foreach ($start as $key => $value) { $start[$key] = is_int($value) ? $value : 0; - } + } } else { $start = array_pad(array($start), $num, $start); } @@ -99,7 +99,7 @@ public function mbSubstrReplace($string, $replacement, $start, $length = null) $length = array_slice($length, 0, $num); foreach ($length as $key => $value) { $length[$key] = isset($value) ? (is_int($value) ? $value : $num) : 0; - } + } } else { $length = array_pad(array($length), $num, $length); }