Skip to content

Commit

Permalink
Merge branch 'main' of github.com:spatie/diff
Browse files Browse the repository at this point in the history
  • Loading branch information
freekmurze committed Feb 22, 2024
2 parents 8943f52 + c088e33 commit a3aa486
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/Differ.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function diff(mixed $first, mixed $second): DiffResult

protected function determineTypeDiffer(mixed $first, mixed $second): ?TypeDiffer
{
foreach($this->differs as $differClass) {
foreach ($this->differs as $differClass) {
$differClass = new $differClass;

if ($differClass->candiff($first, $second)) {
Expand Down
4 changes: 2 additions & 2 deletions src/Exceptions/CannotDiff.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ class CannotDiff extends Exception
{
public static function noDifferFound(mixed $first, mixed $second): self
{
return new self("We could not find a differ for the given type of the passed arguments");
return new self('We could not find a differ for the given type of the passed arguments');
}

public static function differentTypes(mixed $first, mixed $second): self
{
return new self("The given arguments are of different types");
return new self('The given arguments are of different types');
}
}
1 change: 0 additions & 1 deletion src/Normalisers/ObjectNormaliser.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@

class ObjectNormaliser
{

}
14 changes: 6 additions & 8 deletions src/TypeDiffers/ArrayDiffer.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,19 @@ public function canDiff(mixed $first, mixed $second): bool
}

/**
* @param array $first
* @param array $second
*
* @return \Spatie\Diff\DiffResult
* @param array $first
* @param array $second
*/
public function diff($first, $second): DiffResult
{
$diffResult = new DiffResult($first, $second);

foreach(array_diff_key($second, $first) as $key => $value) {
$diffResult->add(DiffResultLineType::Added, $key, $value);
foreach (array_diff_key($second, $first) as $key => $value) {
$diffResult->add(DiffResultLineType::Added, $key, $value);
}

foreach(array_diff_key($first, $second) as $key => $value) {
$diffResult->add(DiffResultLineType::Removed, $key, $value);
foreach (array_diff_key($first, $second) as $key => $value) {
$diffResult->add(DiffResultLineType::Removed, $key, $value);
}

foreach ($first as $key => $value) {
Expand Down
1 change: 0 additions & 1 deletion src/TypeDiffers/ScalarDiffer.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

class ScalarDiffer implements TypeDiffer
{

public function canDiff(mixed $first, mixed $second): bool
{
return is_scalar($first) && is_scalar($second);
Expand Down

0 comments on commit a3aa486

Please sign in to comment.