Skip to content

Commit 32f3f48

Browse files
authored
Merge pull request #16 from swaggest/issue-14
Fix #14
2 parents 05e6127 + 06bf0ac commit 32f3f48

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/JsonDiff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ private function process($original, $new)
244244
$path = $this->path;
245245
$pathItems = $this->pathItems;
246246
$actualKey = $key;
247-
if ($isArray) {
247+
if ($isArray && is_int($actualKey)) {
248248
$actualKey -= $removedOffset;
249249
}
250250
$this->path .= '/' . JsonPointer::escapeSegment($actualKey, $this->options & self::JSON_URI_FRAGMENT_ID);

tests/src/Issues/Issue14Test.php

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
namespace Swaggest\JsonDiff\Tests\Issues;
4+
5+
use Swaggest\JsonDiff\JsonDiff;
6+
7+
class Issue14Test extends \PHPUnit_Framework_TestCase
8+
{
9+
public function testIssue()
10+
{
11+
new JsonDiff(
12+
["name" => "Test"],
13+
[],
14+
JsonDiff::REARRANGE_ARRAYS
15+
);
16+
}
17+
18+
}

0 commit comments

Comments
 (0)