Skip to content

PSR #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jan 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ Todo
* Ability to ignore blank line changes
* 3 way diff support
* Performance optimizations
* Add namespace / PSR4

Contributors
---------------------
Expand Down
2 changes: 1 addition & 1 deletion lib/Autoloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}
}
}
6 changes: 4 additions & 2 deletions lib/jblond/Diff/Renderer/Html/HtmlArray.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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);
}
Expand Down
6 changes: 2 additions & 4 deletions lib/jblond/Diff/SequenceMatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
declare(strict_types=1);
namespace jblond\Diff;

use phpDocumentor\Reflection\Types\Boolean;

/**
* Sequence matcher for Diff
*
Expand Down Expand Up @@ -237,7 +235,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
{
Expand Down Expand Up @@ -349,7 +347,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
{
Expand Down
8 changes: 8 additions & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="php-diff">
<description>php-diff</description>
<rule ref="PSR2">
<exclude name="Generic.WhiteSpace.DisallowTabIndent.NonIndentTabsUsed" />
<exclude name="Generic.WhiteSpace.DisallowTabIndent.TabsUsed" />
</rule>
</ruleset>
7 changes: 2 additions & 5 deletions tests/Diff/Renderer/ArrayTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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();
}

/**
Expand Down