Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [3.10.2] - 2022-11-08

### Added
- Exceptions improved, [#60](https://github.com/swaggest/json-diff/pull/59).

## [3.10.1] - 2022-10-24

### Added
Expand Down Expand Up @@ -85,6 +90,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- Compatibility option to `TOLERATE_ASSOCIATIVE_ARRAYS` that mimic JSON objects.

[3.10.2]: https://github.com/swaggest/json-diff/compare/v3.10.1...v3.10.2
[3.10.1]: https://github.com/swaggest/json-diff/compare/v3.10.0...v3.10.1
[3.10.0]: https://github.com/swaggest/json-diff/compare/v3.9.0...v3.10.0
[3.9.0]: https://github.com/swaggest/json-diff/compare/v3.8.3...v3.9.0
Expand Down
16 changes: 9 additions & 7 deletions src/JsonPatch.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,6 @@ public static function import(array $data)
throw new MissingFieldException('path', $operation);
}

if (!is_string($operation->op)) {
throw new InvalidFieldTypeException('op', 'string', $operation);
}
if (!is_string($operation->path)) {
throw new InvalidFieldTypeException('path', 'string', $operation);
}

$op = null;
switch ($operation->op) {
case Add::OP:
Expand All @@ -98,8 +91,17 @@ public static function import(array $data)
$op = new Test();
break;
default:
if (!is_string($operation->op)) {
throw new InvalidFieldTypeException('op', 'string', $operation);
}

throw new UnknownOperationException($operation);
}

if (!is_string($operation->path)) {
throw new InvalidFieldTypeException('path', 'string', $operation);
}

$op->path = $operation->path;
if ($op instanceof OpPathValue) {
if (property_exists($operation, 'value')) {
Expand Down