diff --git a/src/Utils/ArrayDiff.php b/src/Utils/ArrayDiff.php index 31d5a16b..ca137654 100644 --- a/src/Utils/ArrayDiff.php +++ b/src/Utils/ArrayDiff.php @@ -55,13 +55,13 @@ public function diff($oldData, $newData) * Compare the type and the property values of two objects. * Return true if they are the same, false otherwise. * If the type is the same and all properties are the same, this will return true, even if they are not the same instance. + * + * @see https://www.php.net/manual/en/language.oop5.object-comparison.php. */ - public function compareObjects(object $object1, object $object2): bool + private function compareObjects(object $object1, object $object2): bool { // Check if the objects are of the same type. - $obj1Class = $object1::class; - $obj2Class = $object2::class; - if ($obj1Class !== $obj2Class) { + if ($object1::class !== $object2::class) { return false; } @@ -76,6 +76,7 @@ public function compareObjects(object $object1, object $object2): bool if (!$this->compareObjects($value, $obj2Properties[$key])) { return false; } + continue; } if ($value !== $obj2Properties[$key]) { diff --git a/tests/Utils/ArrayDiffTest.php b/tests/Utils/ArrayDiffTest.php index 5d8e000f..e3c5b960 100644 --- a/tests/Utils/ArrayDiffTest.php +++ b/tests/Utils/ArrayDiffTest.php @@ -16,7 +16,7 @@ use PHPUnit\Framework\TestCase; use SimpleThings\EntityAudit\Utils\ArrayDiff; -class ArrayDiffTest extends TestCase +final class ArrayDiffTest extends TestCase { public function testDiff(): void {