File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -45,6 +45,11 @@ class JsonDiff
4545 */
4646 const COLLECT_MODIFIED_DIFF = 64 ;
4747
48+ /**
49+ * SKIP_TEST_OPS is an option to skip the generation of test operations for JsonPatch.
50+ */
51+ const SKIP_TEST_OPS = 128 ;
52+
4853
4954 private $ options = 0 ;
5055
@@ -258,6 +263,8 @@ public function getMergePatch()
258263 private function process ($ original , $ new )
259264 {
260265 $ merge = !($ this ->options & self ::SKIP_JSON_MERGE_PATCH );
266+
267+ $ addTestOps = !($ this ->options & self ::SKIP_TEST_OPS );
261268
262269 if ($ this ->options & self ::TOLERATE_ASSOCIATIVE_ARRAYS ) {
263270 if (is_array ($ original ) && !empty ($ original ) && !array_key_exists (0 , $ original )) {
@@ -281,7 +288,9 @@ private function process($original, $new)
281288 $ this ->modifiedPaths [] = $ this ->path ;
282289
283290 if ($ this ->jsonPatch !== null ) {
284- $ this ->jsonPatch ->op (new Test ($ this ->path , $ original ));
291+ if ($ addTestOps ) {
292+ $ this ->jsonPatch ->op (new Test ($ this ->path , $ original ));
293+ }
285294 $ this ->jsonPatch ->op (new Replace ($ this ->path , $ new ));
286295 }
287296
@@ -557,4 +566,4 @@ private function rearrangeEqualItems(array $original, array $new)
557566
558567 return $ newRearranged ;
559568 }
560- }
569+ }
You can’t perform that action at this time.
0 commit comments