Skip to content
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

refactor: Rename phar occurrences into pharInfo #1037

Merged
merged 1 commit into from
Oct 8, 2023
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
32 changes: 16 additions & 16 deletions src/Phar/PharDiff.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,49 +29,49 @@
final class PharDiff
{
private readonly ParagoniePharDiff $diff;
private readonly PharInfo $pharA;
private readonly PharInfo $pharB;
private readonly PharInfo $pharInfoA;
private readonly PharInfo $pharInfoB;

public function __construct(string $pathA, string $pathB)
{
$phars = array_map(
[$pharInfoA, $pharInfoB] = array_map(
static fn (string $path) => new PharInfo($path),
[$pathA, $pathB],
);

$this->pharA = $phars[0];
$this->pharB = $phars[1];
$this->pharInfoA = $pharInfoA;
$this->pharInfoB = $pharInfoB;

$diff = new ParagoniePharDiff(...$phars);
$diff = new ParagoniePharDiff($pharInfoA, $pharInfoB);
$diff->setVerbose(true);

$this->diff = $diff;
}

public function getPharA(): PharInfo
public function getPharInfoA(): PharInfo
{
return $this->pharA;
return $this->pharInfoA;
}

public function getPharB(): PharInfo
public function getPharInfoB(): PharInfo
{
return $this->pharB;
return $this->pharInfoB;
}

public function gitDiff(): ?string
{
return self::getDiff(
$this->pharA,
$this->pharB,
$this->pharInfoA,
$this->pharInfoB,
'git diff --no-index',
);
}

public function gnuDiff(): ?string
{
return self::getDiff(
$this->pharA,
$this->pharB,
$this->pharInfoA,
$this->pharInfoB,
'diff',
);
}
Expand All @@ -91,8 +91,8 @@ public function listChecksums(string $algo = 'sha384'): int
*/
public function listDiff(): array
{
$pharAFiles = self::collectFiles($this->pharA);
$pharBFiles = self::collectFiles($this->pharB);
$pharAFiles = self::collectFiles($this->pharInfoA);
$pharBFiles = self::collectFiles($this->pharInfoB);

return [
array_diff($pharAFiles, $pharBFiles),
Expand Down
15 changes: 8 additions & 7 deletions src/Pharaoh/PharDiff.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@

namespace KevinGH\Box\Pharaoh;

use KevinGH\Box\Phar\PharInfo;
use KevinGH\Box\PharInfo\IncompariblePhars;
use ParagonIE\ConstantTime\Hex;
use ParagonIE_Sodium_File;
Expand Down Expand Up @@ -77,18 +78,18 @@ class PharDiff
'yellow' => "\033[0;93m",
];

/** @var array<int, SafePhar> */
private array $phars = [];
/** @var array<int, PharInfo> */
private array $pharInfos = [];

private bool $verbose = false;

public function __construct(SafePhar $pharA, SafePhar $pharB)
public function __construct(PharInfo $pharInfoA, PharInfo $pharInfoB)
{
if ($pharA->hasPubKey() || $pharB->hasPubKey()) {
if ($pharInfoA->hasPubKey() || $pharInfoB->hasPubKey()) {
throw IncompariblePhars::signedPhars();
}

$this->phars = [$pharA, $pharB];
$this->pharInfos = [$pharInfoA, $pharInfoB];
}

/**
Expand Down Expand Up @@ -208,8 +209,8 @@ public function listChecksums(string $algo = 'sha384'): int
{
[$pharA, $pharB] = $this->hashChildren(
$algo,
$this->phars[0]->getTmp(),
$this->phars[1]->getTmp(),
$this->pharInfos[0]->getTmp(),
$this->pharInfos[1]->getTmp(),
);

$diffs = 0;
Expand Down
1 change: 0 additions & 1 deletion tests/Console/Command/DiffTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
use function ob_get_clean;
use function ob_start;
use function realpath;
use const PHP_VERSION_ID;

/**
* @covers \KevinGH\Box\Console\Command\Diff
Expand Down
Loading