Skip to content

Commit

Permalink
style: $ composer fix
Browse files Browse the repository at this point in the history
Signed-off-by: Jack Cherng <[email protected]>
  • Loading branch information
jfcherng committed Oct 29, 2023
1 parent 5b70504 commit e0da986
Show file tree
Hide file tree
Showing 29 changed files with 49 additions and 118 deletions.
10 changes: 4 additions & 6 deletions src/DiffHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ final class DiffHelper
/**
* The constructor.
*/
private function __construct()
{
}
private function __construct() {}

/**
* Get the absolute path of the project root directory.
Expand All @@ -38,7 +36,7 @@ public static function getRenderersInfo(): array
}

$glob = implode(\DIRECTORY_SEPARATOR, [
static::getProjectDirectory(),
self::getProjectDirectory(),
'src',
'Renderer',
'{' . implode(',', RendererConstant::RENDERER_TYPES) . '}',
Expand Down Expand Up @@ -94,7 +92,7 @@ public static function getStyleSheet(): string
return $fileContent;
}

$filePath = static::getProjectDirectory() . '/example/diff-table.css';
$filePath = self::getProjectDirectory() . '/example/diff-table.css';

$file = new \SplFileObject($filePath, 'r');

Expand Down Expand Up @@ -170,7 +168,7 @@ public static function calculateFiles(
$oldFile = new \SplFileObject($old, 'r');
$newFile = new \SplFileObject($new, 'r');

return static::calculate(
return self::calculate(
// fread() requires the length > 0 hence we plus 1 for empty files
$oldFile->fread($oldFile->getSize() + 1),
$newFile->fread($newFile->getSize() + 1),
Expand Down
10 changes: 5 additions & 5 deletions src/Differ.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public function setNew(array $new): self
*/
public function setOptions(array $options): self
{
$mergedOptions = $options + static::$defaultOptions;
$mergedOptions = $options + self::$defaultOptions;

if ($this->options !== $mergedOptions) {
$this->options = $mergedOptions;
Expand All @@ -196,7 +196,7 @@ public function setOptions(array $options): self
*
* @return string[] array of all of the lines between the specified range
*/
public function getOld(int $start = 0, ?int $end = null): array
public function getOld(int $start = 0, int $end = null): array
{
return Arr::getPartialByIndex($this->old, $start, $end);
}
Expand All @@ -210,7 +210,7 @@ public function getOld(int $start = 0, ?int $end = null): array
*
* @return string[] array of all of the lines between the specified range
*/
public function getNew(int $start = 0, ?int $end = null): array
public function getNew(int $start = 0, int $end = null): array
{
return Arr::getPartialByIndex($this->new, $start, $end);
}
Expand Down Expand Up @@ -260,7 +260,7 @@ public static function getInstance(): self
{
static $singleton;

return $singleton ??= new static([], []);
return $singleton ??= new self([], []);
}

/**
Expand Down Expand Up @@ -491,7 +491,7 @@ private function finalize(): self
*/
private function resetCachedResults(): self
{
foreach (static::CACHED_PROPERTIES as $property => $value) {
foreach (self::CACHED_PROPERTIES as $property => $value) {
$this->{$property} = $value;
}

Expand Down
4 changes: 1 addition & 3 deletions src/Factory/LineRendererFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ final class LineRendererFactory
/**
* The constructor.
*/
private function __construct()
{
}
private function __construct() {}

/**
* Get the singleton of a line renderer.
Expand Down
4 changes: 1 addition & 3 deletions src/Factory/RendererFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ final class RendererFactory
/**
* The constructor.
*/
private function __construct()
{
}
private function __construct() {}

/**
* Get the singleton of a renderer.
Expand Down
9 changes: 1 addition & 8 deletions src/Renderer/AbstractRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,6 @@ public function getOptions(): array
}

/**
* {@inheritdoc}
*
* @final
*
* @todo mark this method with "final" in the next major release
Expand All @@ -178,21 +176,16 @@ public function getResultForIdenticals(): string
*/
abstract public function getResultForIdenticalsDefault(): string;

/**
* {@inheritdoc}
*/
final public function render(Differ $differ): string
{
$this->changesAreRaw = true;

// the "no difference" situation may happen frequently
return $differ->getOldNewComparison() === 0
? $this->getResultForIdenticals()
: $this->renderWorker($differ);
}

/**
* {@inheritdoc}
*/
final public function renderArray(array $differArray): string
{
$this->changesAreRaw = false;
Expand Down
9 changes: 0 additions & 9 deletions src/Renderer/Html/AbstractHtml.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ abstract class AbstractHtml extends AbstractRenderer
*/
public const AUTO_FORMAT_CHANGES = true;

/**
* {@inheritdoc}
*/
public function getResultForIdenticalsDefault(): string
{
return '';
Expand Down Expand Up @@ -105,19 +102,13 @@ public function getChanges(Differ $differ): array
return $changes;
}

/**
* {@inheritdoc}
*/
protected function renderWorker(Differ $differ): string
{
$rendered = $this->redererChanges($this->getChanges($differ));

return $this->cleanUpDummyHtmlClosures($rendered);
}

/**
* {@inheritdoc}
*/
protected function renderArrayWorker(array $differArray): string
{
$this->ensureChangesUseIntTag($differArray);
Expand Down
3 changes: 0 additions & 3 deletions src/Renderer/Html/Combined.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ final class Combined extends AbstractHtml
*/
public const AUTO_FORMAT_CHANGES = false;

/**
* {@inheritdoc}
*/
protected function redererChanges(array $changes): string
{
if (empty($changes)) {
Expand Down
3 changes: 0 additions & 3 deletions src/Renderer/Html/Inline.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ final class Inline extends AbstractHtml
'type' => 'Html',
];

/**
* {@inheritdoc}
*/
protected function redererChanges(array $changes): string
{
if (empty($changes)) {
Expand Down
4 changes: 1 addition & 3 deletions src/Renderer/Html/Json.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,4 @@
*
* @deprecated 6.8.0 Use the "JsonHtml" renderer instead.
*/
final class Json extends JsonHtml
{
}
final class Json extends JsonHtml {}
9 changes: 0 additions & 9 deletions src/Renderer/Html/JsonHtml.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,11 @@ class JsonHtml extends AbstractHtml
*/
public const IS_TEXT_RENDERER = true;

/**
* {@inheritdoc}
*/
public function getResultForIdenticalsDefault(): string
{
return '[]';
}

/**
* {@inheritdoc}
*/
protected function redererChanges(array $changes): string
{
if ($this->options['outputTagAsString']) {
Expand All @@ -58,9 +52,6 @@ protected function convertTagToString(array &$changes): void
}
}

/**
* {@inheritdoc}
*/
protected function formatStringFromLines(string $string): string
{
return $this->htmlSafe($string);
Expand Down
2 changes: 0 additions & 2 deletions src/Renderer/Html/LineRenderer/Char.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
final class Char extends AbstractLineRenderer
{
/**
* {@inheritdoc}
*
* @return static
*/
public function render(MbString $mbOld, MbString $mbNew): LineRendererInterface
Expand Down
2 changes: 0 additions & 2 deletions src/Renderer/Html/LineRenderer/Line.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
final class Line extends AbstractLineRenderer
{
/**
* {@inheritdoc}
*
* @return static
*/
public function render(MbString $mbOld, MbString $mbNew): LineRendererInterface
Expand Down
2 changes: 0 additions & 2 deletions src/Renderer/Html/LineRenderer/None.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
final class None extends AbstractLineRenderer
{
/**
* {@inheritdoc}
*
* @return static
*/
public function render(MbString $mbOld, MbString $mbNew): LineRendererInterface
Expand Down
2 changes: 0 additions & 2 deletions src/Renderer/Html/LineRenderer/Word.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
final class Word extends AbstractLineRenderer
{
/**
* {@inheritdoc}
*
* @return static
*/
public function render(MbString $mbOld, MbString $mbNew): LineRendererInterface
Expand Down
3 changes: 0 additions & 3 deletions src/Renderer/Html/SideBySide.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ final class SideBySide extends AbstractHtml
'type' => 'Html',
];

/**
* {@inheritdoc}
*/
protected function redererChanges(array $changes): string
{
if (empty($changes)) {
Expand Down
10 changes: 1 addition & 9 deletions src/Renderer/Text/AbstractText.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ abstract class AbstractText extends AbstractRenderer
*/
protected $isCliColorEnabled = false;

/**
* {@inheritdoc}
*/
public function setOptions(array $options): AbstractRenderer
{
parent::setOptions($options);
Expand All @@ -48,17 +45,11 @@ public function setOptions(array $options): AbstractRenderer
return $this;
}

/**
* {@inheritdoc}
*/
public function getResultForIdenticalsDefault(): string
{
return '';
}

/**
* {@inheritdoc}
*/
protected function renderArrayWorker(array $differArray): string
{
throw new UnsupportedFunctionException(__METHOD__);
Expand Down Expand Up @@ -139,6 +130,7 @@ protected function hasColorSupport($stream): bool
}

$stat = @fstat($stream);

// Check if formatted mode is S_IFCHR
return $stat ? 0020000 === ($stat['mode'] & 0170000) : false;
}
Expand Down
3 changes: 0 additions & 3 deletions src/Renderer/Text/Context.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ final class Context extends AbstractText
SequenceMatcher::OP_INS |
SequenceMatcher::OP_REP;

/**
* {@inheritdoc}
*/
protected function renderWorker(Differ $differ): string
{
$ret = '';
Expand Down
3 changes: 0 additions & 3 deletions src/Renderer/Text/JsonText.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ final class JsonText extends AbstractText
'type' => 'Text',
];

/**
* {@inheritdoc}
*/
protected function renderWorker(Differ $differ): string
{
$ret = [];
Expand Down
3 changes: 0 additions & 3 deletions src/Renderer/Text/Unified.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ final class Unified extends AbstractText
'type' => 'Text',
];

/**
* {@inheritdoc}
*/
protected function renderWorker(Differ $differ): string
{
$ret = '';
Expand Down
2 changes: 1 addition & 1 deletion src/Utility/Arr.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ final class Arr
*
* @return array array of all of the lines between the specified range
*/
public static function getPartialByIndex(array $array, int $start = 0, ?int $end = null): array
public static function getPartialByIndex(array $array, int $start = 0, int $end = null): array
{
$count = \count($array);

Expand Down
4 changes: 1 addition & 3 deletions src/Utility/ReverseIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ final class ReverseIterator
/**
* The constructor.
*/
private function __construct()
{
}
private function __construct() {}

/**
* Iterate the array reversely.
Expand Down
10 changes: 5 additions & 5 deletions tests/DiffHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ final class DiffHelperTest extends TestCase
* @covers \Jfcherng\Diff\Renderer\Text\Context
* @covers \Jfcherng\Diff\Renderer\Text\Unified
*
* @dataProvider rendererOutputDataProvider
* @dataProvider provideRendererOutputCases
*
* @param string $rendererName The renderer name
* @param int $idx The index
Expand All @@ -33,7 +33,7 @@ final class DiffHelperTest extends TestCase
public function testRendererOutput(string $rendererName, int $idx, array $testFiles): void
{
if (!isset($testFiles['old'], $testFiles['new'], $testFiles['result'])) {
static::markTestSkipped("Renderer output test '{$rendererName}' #{$idx} is imcomplete.");
self::markTestSkipped("Renderer output test '{$rendererName}' #{$idx} is imcomplete.");
}

$result = DiffHelper::calculate(
Expand All @@ -44,7 +44,7 @@ public function testRendererOutput(string $rendererName, int $idx, array $testFi
['cliColorization' => RendererConstant::CLI_COLOR_DISABLE],
);

static::assertSame(
self::assertSame(
$testFiles['result']->getContents(),
$result,
"Renderer output test '{$rendererName}' #{$idx} failed...",
Expand All @@ -58,13 +58,13 @@ public function testRendererOutput(string $rendererName, int $idx, array $testFi
*/
public function testGetStyleSheet(): void
{
static::assertIsString(DiffHelper::getStyleSheet());
self::assertIsString(DiffHelper::getStyleSheet());
}

/**
* Data provider for self::testRendererOutput.
*/
public function rendererOutputDataProvider(): array
public function provideRendererOutputCases(): iterable
{
$rendererNames = DiffHelper::getAvailableRenderers();

Expand Down
Loading

0 comments on commit e0da986

Please sign in to comment.