Skip to content

Commit ab6e491

Browse files
authored
Merge pull request #8 from JBlond/development
PSR
2 parents 7795e70 + 354bf5c commit ab6e491

File tree

6 files changed

+17
-13
lines changed

6 files changed

+17
-13
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ Todo
4343
* Ability to ignore blank line changes
4444
* 3 way diff support
4545
* Performance optimizations
46-
* Add namespace / PSR4
4746

4847
Contributors
4948
---------------------

lib/Autoloader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ private function __autoload($class)
2525
$dir = str_replace('\\', '/', __DIR__);
2626
if (file_exists($dir . '/' . $class . '.php')) {
2727
/** @noinspection PhpIncludeInspection */
28-
require $dir . '/' . $class . '.php';
28+
require_once $dir . '/' . $class . '.php';
2929
}
3030
}
3131
}

lib/jblond/Diff/Renderer/Html/HtmlArray.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,9 @@ public function mbSubstrReplace($string, $replacement, $start, $length = null)
8686
// $start
8787
if (is_array($start)) {
8888
$start = array_slice($start, 0, $num);
89-
foreach ($start as $key => $value)
89+
foreach ($start as $key => $value) {
9090
$start[$key] = is_int($value) ? $value : 0;
91+
}
9192
} else {
9293
$start = array_pad(array($start), $num, $start);
9394
}
@@ -96,8 +97,9 @@ public function mbSubstrReplace($string, $replacement, $start, $length = null)
9697
$length = array_fill(0, $num, 0);
9798
} elseif (is_array($length)) {
9899
$length = array_slice($length, 0, $num);
99-
foreach ($length as $key => $value)
100+
foreach ($length as $key => $value) {
100101
$length[$key] = isset($value) ? (is_int($value) ? $value : $num) : 0;
102+
}
101103
} else {
102104
$length = array_pad(array($length), $num, $length);
103105
}

lib/jblond/Diff/SequenceMatcher.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
declare(strict_types=1);
33
namespace jblond\Diff;
44

5-
use phpDocumentor\Reflection\Types\Boolean;
6-
75
/**
86
* Sequence matcher for Diff
97
*
@@ -237,7 +235,7 @@ private function chainB()
237235
* for the list of junk characters.
238236
*
239237
* @param string $b
240-
* @return boolean $b True if the character is considered junk. False if not.
238+
* @return bool $b True if the character is considered junk. False if not.
241239
*/
242240
private function isBJunk($b) : bool
243241
{
@@ -349,7 +347,7 @@ public function findLongestMatch($alo, $ahi, $blo, $bhi) : array
349347
*
350348
* @param int $aIndex Line number to check against in a.
351349
* @param int $bIndex Line number to check against in b.
352-
* @return boolean True if the lines are different and false if not.
350+
* @return bool True if the lines are different and false if not.
353351
*/
354352
public function linesAreDifferent($aIndex, $bIndex) : bool
355353
{

phpcs.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ruleset name="php-diff">
3+
<description>php-diff</description>
4+
<rule ref="PSR2">
5+
<exclude name="Generic.WhiteSpace.DisallowTabIndent.NonIndentTabsUsed" />
6+
<exclude name="Generic.WhiteSpace.DisallowTabIndent.TabsUsed" />
7+
</rule>
8+
</ruleset>

tests/Diff/Renderer/ArrayTest.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
declare(strict_types=1);
33
namespace Tests\Diff\Renderer\Html;
44

5-
require "../../../lib/Autoloader.php";
6-
7-
use jblond\Autoloader;
85
use jblond\Diff\Renderer\Html\HtmlArray;
96
use PHPUnit\Framework\TestCase;
107

@@ -23,9 +20,9 @@ class ArrayTest extends TestCase
2320
*/
2421
public function __construct($name = null, array $data = [], $dataName = '')
2522
{
26-
23+
require "../../../lib/Autoloader.php";
24+
new \jblond\Autoloader();
2725
parent::__construct($name, $data, $dataName);
28-
new Autoloader();
2926
}
3027

3128
/**

0 commit comments

Comments
 (0)