diff --git a/src/JsonPointer.php b/src/JsonPointer.php index 08a1d3a..d9fc2e0 100644 --- a/src/JsonPointer.php +++ b/src/JsonPointer.php @@ -134,7 +134,7 @@ public static function add(&$holder, $pathItems, $value, $flags = self::RECURSIV } else { if ($flags & self::RECURSIVE_KEY_CREATION && $ref === null) $ref = array(); if ('-' === $key) { - $ref = &$ref[]; + $ref = &$ref[count($ref)]; } else { if (false === $intKey) { if (0 === ($flags & self::TOLERATE_ASSOCIATIVE_ARRAYS)) { @@ -282,7 +282,6 @@ public static function remove(&$holder, $pathItems, $flags = 0) unset($parent->$refKey); } else { $isAssociative = false; - $ff = $flags & self::TOLERATE_ASSOCIATIVE_ARRAYS; if ($flags & self::TOLERATE_ASSOCIATIVE_ARRAYS) { $i = 0; foreach ($parent as $index => $value) { diff --git a/tests/src/Issues/Issue31Test.php b/tests/src/Issues/Issue31Test.php new file mode 100644 index 0000000..a6e0982 --- /dev/null +++ b/tests/src/Issues/Issue31Test.php @@ -0,0 +1,18 @@ +apply($reportData); + + $this->assertSame('["a","b","c","e"]', json_encode($reportData)); + } + +} \ No newline at end of file