From 4ad1e4087cb3b762e3d0402d507e5ba786d7b413 Mon Sep 17 00:00:00 2001 From: Andrew Coulton Date: Sun, 30 Nov 2025 10:39:07 +0000 Subject: [PATCH 1/4] refactor! Rename operation classes to `xxxHandler` Adds a `Handler` suffix to all current final operation handler class names, and moves them to a `handlers` namespace. This is not expected to affect end-users as the in-built handler classes are not generally expected to be used outside the package. This will avoid naming conflicts and confusion when we subsequently introduce support for representing a patch as a set of operation DTOs. --- src/FastJsonPatch.php | 28 ++++++++++--------- src/operations/PatchOperation.php | 9 ++++-- .../{Add.php => handlers/AddHandler.php} | 5 ++-- .../{Copy.php => handlers/CopyHandler.php} | 5 ++-- .../{Move.php => handlers/MoveHandler.php} | 6 ++-- .../RemoveHandler.php} | 6 ++-- .../ReplaceHandler.php} | 6 ++-- .../{Test.php => handlers/TestHandler.php} | 7 +++-- tests/FastJsonPatchTest.php | 24 ++++++++-------- .../exceptions/ArrayBoundaryExceptionTest.php | 4 +-- tests/exceptions/FailedTestExceptionTest.php | 4 +-- .../InvalidPatchFromExceptionTest.php | 12 ++++---- .../InvalidPatchValueExceptionTest.php | 4 +-- tests/exceptions/UnknownPathExceptionTest.php | 24 ++++++++-------- tests/operations/{ => handlers}/AddTest.php | 10 +++---- tests/operations/{ => handlers}/CopyTest.php | 10 +++---- tests/operations/{ => handlers}/MoveTest.php | 10 +++---- .../operations/{ => handlers}/RemoveTest.php | 10 +++---- .../operations/{ => handlers}/ReplaceTest.php | 10 +++---- tests/operations/{ => handlers}/TestTest.php | 10 +++---- 20 files changed, 110 insertions(+), 94 deletions(-) rename src/operations/{Add.php => handlers/AddHandler.php} (93%) rename src/operations/{Copy.php => handlers/CopyHandler.php} (93%) rename src/operations/{Move.php => handlers/MoveHandler.php} (89%) rename src/operations/{Remove.php => handlers/RemoveHandler.php} (88%) rename src/operations/{Replace.php => handlers/ReplaceHandler.php} (89%) rename src/operations/{Test.php => handlers/TestHandler.php} (92%) rename tests/operations/{ => handlers}/AddTest.php (96%) rename tests/operations/{ => handlers}/CopyTest.php (97%) rename tests/operations/{ => handlers}/MoveTest.php (95%) rename tests/operations/{ => handlers}/RemoveTest.php (94%) rename tests/operations/{ => handlers}/ReplaceTest.php (95%) rename tests/operations/{ => handlers}/TestTest.php (96%) diff --git a/src/FastJsonPatch.php b/src/FastJsonPatch.php index bf327e4..90a92a7 100644 --- a/src/FastJsonPatch.php +++ b/src/FastJsonPatch.php @@ -23,13 +23,15 @@ }; use blancks\JsonPatch\operations\{ PatchOperationInterface, - PatchValidationTrait, - Add, - Copy, - Move, - Remove, - Replace, - Test + PatchValidationTrait +}; +use blancks\JsonPatch\operations\handlers\{ + AddHandler, + CopyHandler, + MoveHandler, + RemoveHandler, + ReplaceHandler, + TestHandler }; /** @@ -91,12 +93,12 @@ public function __construct( $this->setJsonPointerHandler($JsonPointerHandler); $this->setJsonHandler($JsonHandler); - $this->registerOperation(new Add); - $this->registerOperation(new Copy); - $this->registerOperation(new Move); - $this->registerOperation(new Remove); - $this->registerOperation(new Replace); - $this->registerOperation(new Test); + $this->registerOperation(new AddHandler); + $this->registerOperation(new CopyHandler); + $this->registerOperation(new MoveHandler); + $this->registerOperation(new RemoveHandler); + $this->registerOperation(new ReplaceHandler); + $this->registerOperation(new TestHandler); } /** diff --git a/src/operations/PatchOperation.php b/src/operations/PatchOperation.php index 1fe4cd6..c6c91ec 100644 --- a/src/operations/PatchOperation.php +++ b/src/operations/PatchOperation.php @@ -18,12 +18,17 @@ abstract class PatchOperation implements /** * Returns the operation name that the class will handle. - * Please note that this method will assume the class short name as the name of the operation, + * Please note the default implementation takes this from the lowercased class short name, removing any "Handler" + * suffix. * feel free to override if this is not the behaviour you want for your operation handler class. * @return string */ public function getOperation(): string { - return strtolower((new \ReflectionClass($this))->getShortName()); + $name = strtolower((new \ReflectionClass($this))->getShortName()); + if (str_ends_with($name, 'handler')) { + $name = substr($name, 0, -7); + } + return $name; } } diff --git a/src/operations/Add.php b/src/operations/handlers/AddHandler.php similarity index 93% rename from src/operations/Add.php rename to src/operations/handlers/AddHandler.php index 5e61bc1..0d494d5 100644 --- a/src/operations/Add.php +++ b/src/operations/handlers/AddHandler.php @@ -1,10 +1,11 @@ isJsonEquals($item, $patch->value)) { throw new FailedTestException( sprintf( - 'Test operation failed asserting that "%s" equals "%s"', + 'TestHandler operation failed asserting that "%s" equals "%s"', $this->JsonHandler->encode($item), $this->JsonHandler->encode($patch->value) ), diff --git a/tests/FastJsonPatchTest.php b/tests/FastJsonPatchTest.php index 44d393d..e348ff6 100644 --- a/tests/FastJsonPatchTest.php +++ b/tests/FastJsonPatchTest.php @@ -22,12 +22,12 @@ }; use blancks\JsonPatch\operations\{ PatchOperation, - Add, - Copy, - Move, - Remove, - Replace, - Test + handlers\AddHandler, + handlers\CopyHandler, + handlers\MoveHandler, + handlers\RemoveHandler, + handlers\ReplaceHandler, + handlers\TestHandler }; use blancks\JsonPatch\FastJsonPatch; use PHPUnit\Framework\Attributes\{ @@ -52,12 +52,12 @@ #[UsesClass(BasicJsonHandler::class)] #[UsesClass(JsonPointer6901::class)] #[UsesClass(PatchOperation::class)] -#[UsesClass(Add::class)] -#[UsesClass(Copy::class)] -#[UsesClass(Move::class)] -#[UsesClass(Remove::class)] -#[UsesClass(Replace::class)] -#[UsesClass(Test::class)] +#[UsesClass(AddHandler::class)] +#[UsesClass(CopyHandler::class)] +#[UsesClass(MoveHandler::class)] +#[UsesClass(RemoveHandler::class)] +#[UsesClass(ReplaceHandler::class)] +#[UsesClass(TestHandler::class)] final class FastJsonPatchTest extends JsonPatchCompliance { public function testValidPatch(): void diff --git a/tests/exceptions/ArrayBoundaryExceptionTest.php b/tests/exceptions/ArrayBoundaryExceptionTest.php index 964e73a..63e62b8 100644 --- a/tests/exceptions/ArrayBoundaryExceptionTest.php +++ b/tests/exceptions/ArrayBoundaryExceptionTest.php @@ -12,7 +12,7 @@ use blancks\JsonPatch\json\crud\CrudTrait; use blancks\JsonPatch\json\handlers\BasicJsonHandler; use blancks\JsonPatch\json\pointer\JsonPointer6901; -use blancks\JsonPatch\operations\Add; +use blancks\JsonPatch\operations\handlers\AddHandler; use blancks\JsonPatch\operations\PatchOperation; use blancks\JsonPatch\FastJsonPatch; use PHPUnit\Framework\Attributes\CoversClass; @@ -32,7 +32,7 @@ #[UsesClass(BasicJsonHandler::class)] #[UsesClass(JsonPointer6901::class)] #[UsesClass(PatchOperation::class)] -#[UsesClass(Add::class)] +#[UsesClass(AddHandler::class)] final class ArrayBoundaryExceptionTest extends TestCase { /** diff --git a/tests/exceptions/FailedTestExceptionTest.php b/tests/exceptions/FailedTestExceptionTest.php index a6d9ff5..42e2084 100644 --- a/tests/exceptions/FailedTestExceptionTest.php +++ b/tests/exceptions/FailedTestExceptionTest.php @@ -12,8 +12,8 @@ use blancks\JsonPatch\json\crud\CrudTrait; use blancks\JsonPatch\json\handlers\BasicJsonHandler; use blancks\JsonPatch\json\pointer\JsonPointer6901; +use blancks\JsonPatch\operations\handlers\TestHandler; use blancks\JsonPatch\operations\PatchOperation; -use blancks\JsonPatch\operations\Test; use blancks\JsonPatch\FastJsonPatch; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\DataProvider; @@ -32,7 +32,7 @@ #[UsesClass(BasicJsonHandler::class)] #[UsesClass(JsonPointer6901::class)] #[UsesClass(PatchOperation::class)] -#[UsesClass(Test::class)] +#[UsesClass(TestHandler::class)] final class FailedTestExceptionTest extends TestCase { /** diff --git a/tests/exceptions/InvalidPatchFromExceptionTest.php b/tests/exceptions/InvalidPatchFromExceptionTest.php index 27aba02..0ebfe5f 100644 --- a/tests/exceptions/InvalidPatchFromExceptionTest.php +++ b/tests/exceptions/InvalidPatchFromExceptionTest.php @@ -13,10 +13,10 @@ use blancks\JsonPatch\json\crud\CrudTrait; use blancks\JsonPatch\json\handlers\BasicJsonHandler; use blancks\JsonPatch\json\pointer\JsonPointer6901; -use blancks\JsonPatch\operations\Add; -use blancks\JsonPatch\operations\Copy; +use blancks\JsonPatch\operations\handlers\AddHandler; +use blancks\JsonPatch\operations\handlers\CopyHandler; +use blancks\JsonPatch\operations\handlers\RemoveHandler; use blancks\JsonPatch\operations\PatchOperation; -use blancks\JsonPatch\operations\Remove; use blancks\JsonPatch\FastJsonPatch; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\UsesClass; @@ -35,9 +35,9 @@ #[UsesClass(BasicJsonHandler::class)] #[UsesClass(JsonPointer6901::class)] #[UsesClass(PatchOperation::class)] -#[UsesClass(Add::class)] -#[UsesClass(Copy::class)] -#[UsesClass(Remove::class)] +#[UsesClass(AddHandler::class)] +#[UsesClass(CopyHandler::class)] +#[UsesClass(RemoveHandler::class)] final class InvalidPatchFromExceptionTest extends TestCase { /** diff --git a/tests/exceptions/InvalidPatchValueExceptionTest.php b/tests/exceptions/InvalidPatchValueExceptionTest.php index 955b00c..96be382 100644 --- a/tests/exceptions/InvalidPatchValueExceptionTest.php +++ b/tests/exceptions/InvalidPatchValueExceptionTest.php @@ -11,7 +11,7 @@ use blancks\JsonPatch\json\accessors\ValueAccessorAwareTrait; use blancks\JsonPatch\json\handlers\BasicJsonHandler; use blancks\JsonPatch\json\pointer\JsonPointer6901; -use blancks\JsonPatch\operations\Add; +use blancks\JsonPatch\operations\handlers\AddHandler; use blancks\JsonPatch\operations\PatchOperation; use blancks\JsonPatch\FastJsonPatch; use PHPUnit\Framework\Attributes\CoversClass; @@ -29,7 +29,7 @@ #[UsesClass(BasicJsonHandler::class)] #[UsesClass(JsonPointer6901::class)] #[UsesClass(PatchOperation::class)] -#[UsesClass(Add::class)] +#[UsesClass(AddHandler::class)] final class InvalidPatchValueExceptionTest extends TestCase { /** diff --git a/tests/exceptions/UnknownPathExceptionTest.php b/tests/exceptions/UnknownPathExceptionTest.php index b6c61c4..cc8c8d0 100644 --- a/tests/exceptions/UnknownPathExceptionTest.php +++ b/tests/exceptions/UnknownPathExceptionTest.php @@ -13,13 +13,13 @@ use blancks\JsonPatch\json\crud\CrudTrait; use blancks\JsonPatch\json\handlers\BasicJsonHandler; use blancks\JsonPatch\json\pointer\JsonPointer6901; -use blancks\JsonPatch\operations\Add; -use blancks\JsonPatch\operations\Copy; -use blancks\JsonPatch\operations\Move; +use blancks\JsonPatch\operations\handlers\AddHandler; +use blancks\JsonPatch\operations\handlers\CopyHandler; +use blancks\JsonPatch\operations\handlers\MoveHandler; +use blancks\JsonPatch\operations\handlers\RemoveHandler; +use blancks\JsonPatch\operations\handlers\ReplaceHandler; +use blancks\JsonPatch\operations\handlers\TestHandler; use blancks\JsonPatch\operations\PatchOperation; -use blancks\JsonPatch\operations\Remove; -use blancks\JsonPatch\operations\Replace; -use blancks\JsonPatch\operations\Test; use blancks\JsonPatch\FastJsonPatch; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\DataProvider; @@ -39,12 +39,12 @@ #[UsesClass(BasicJsonHandler::class)] #[UsesClass(JsonPointer6901::class)] #[UsesClass(PatchOperation::class)] -#[UsesClass(Add::class)] -#[UsesClass(Copy::class)] -#[UsesClass(Move::class)] -#[UsesClass(Remove::class)] -#[UsesClass(Replace::class)] -#[UsesClass(Test::class)] +#[UsesClass(AddHandler::class)] +#[UsesClass(CopyHandler::class)] +#[UsesClass(MoveHandler::class)] +#[UsesClass(RemoveHandler::class)] +#[UsesClass(ReplaceHandler::class)] +#[UsesClass(TestHandler::class)] final class UnknownPathExceptionTest extends TestCase { /** diff --git a/tests/operations/AddTest.php b/tests/operations/handlers/AddTest.php similarity index 96% rename from tests/operations/AddTest.php rename to tests/operations/handlers/AddTest.php index 4f51c62..7d364ea 100644 --- a/tests/operations/AddTest.php +++ b/tests/operations/handlers/AddTest.php @@ -1,6 +1,6 @@ setJsonPointerHandler($JsonPointerHandler); - $this->Operation = new Add(); + $this->Operation = new AddHandler(); $this->Operation->setJsonHandler($JsonHandler); $this->Operation->setJsonPointerHandler($JsonPointerHandler); } diff --git a/tests/operations/CopyTest.php b/tests/operations/handlers/CopyTest.php similarity index 97% rename from tests/operations/CopyTest.php rename to tests/operations/handlers/CopyTest.php index cefe710..9dbbc73 100644 --- a/tests/operations/CopyTest.php +++ b/tests/operations/handlers/CopyTest.php @@ -1,6 +1,6 @@ setJsonPointerHandler($JsonPointerHandler); - $this->Operation = new Copy(); + $this->Operation = new CopyHandler(); $this->Operation->setJsonHandler($JsonHandler); $this->Operation->setJsonPointerHandler($JsonPointerHandler); } diff --git a/tests/operations/MoveTest.php b/tests/operations/handlers/MoveTest.php similarity index 95% rename from tests/operations/MoveTest.php rename to tests/operations/handlers/MoveTest.php index 0a189a6..61cfa06 100644 --- a/tests/operations/MoveTest.php +++ b/tests/operations/handlers/MoveTest.php @@ -1,6 +1,6 @@ setJsonPointerHandler($JsonPointerHandler); - $this->Operation = new Move(); + $this->Operation = new MoveHandler(); $this->Operation->setJsonHandler($JsonHandler); $this->Operation->setJsonPointerHandler($JsonPointerHandler); } diff --git a/tests/operations/RemoveTest.php b/tests/operations/handlers/RemoveTest.php similarity index 94% rename from tests/operations/RemoveTest.php rename to tests/operations/handlers/RemoveTest.php index 130b960..a894475 100644 --- a/tests/operations/RemoveTest.php +++ b/tests/operations/handlers/RemoveTest.php @@ -1,6 +1,6 @@ setJsonPointerHandler($JsonPointerHandler); - $this->Operation = new Remove(); + $this->Operation = new RemoveHandler(); $this->Operation->setJsonHandler($JsonHandler); $this->Operation->setJsonPointerHandler($JsonPointerHandler); } diff --git a/tests/operations/ReplaceTest.php b/tests/operations/handlers/ReplaceTest.php similarity index 95% rename from tests/operations/ReplaceTest.php rename to tests/operations/handlers/ReplaceTest.php index 2b757e9..19118ea 100644 --- a/tests/operations/ReplaceTest.php +++ b/tests/operations/handlers/ReplaceTest.php @@ -1,6 +1,6 @@ setJsonPointerHandler($JsonPointerHandler); - $this->Operation = new Replace(); + $this->Operation = new ReplaceHandler(); $this->Operation->setJsonHandler($JsonHandler); $this->Operation->setJsonPointerHandler($JsonPointerHandler); } diff --git a/tests/operations/TestTest.php b/tests/operations/handlers/TestTest.php similarity index 96% rename from tests/operations/TestTest.php rename to tests/operations/handlers/TestTest.php index 85d154f..1845d49 100644 --- a/tests/operations/TestTest.php +++ b/tests/operations/handlers/TestTest.php @@ -1,6 +1,6 @@ setJsonPointerHandler($JsonPointerHandler); - $this->Operation = new Test(); + $this->Operation = new TestHandler(); $this->Operation->setJsonHandler($JsonHandler); $this->Operation->setJsonPointerHandler($JsonPointerHandler); } From 6cf32f6a8719d6af08c27f70140c78fd94d949de Mon Sep 17 00:00:00 2001 From: Andrew Coulton Date: Sun, 30 Nov 2025 10:42:44 +0000 Subject: [PATCH 2/4] refactor! Formally mark that `xxxHandler` classes are `@internal` End-users are not expected to reference these classes directly. If users want to customise handling for a particular operation, they should implement the interface and/or extend from the abstract base class. --- src/operations/handlers/AddHandler.php | 3 +++ src/operations/handlers/CopyHandler.php | 3 +++ src/operations/handlers/MoveHandler.php | 3 +++ src/operations/handlers/RemoveHandler.php | 3 +++ src/operations/handlers/ReplaceHandler.php | 3 +++ src/operations/handlers/TestHandler.php | 3 +++ 6 files changed, 18 insertions(+) diff --git a/src/operations/handlers/AddHandler.php b/src/operations/handlers/AddHandler.php index 0d494d5..62e7ad7 100644 --- a/src/operations/handlers/AddHandler.php +++ b/src/operations/handlers/AddHandler.php @@ -5,6 +5,9 @@ use blancks\JsonPatch\json\accessors\UndefinedValue; use blancks\JsonPatch\operations\PatchOperation; +/** + * @internal + */ final class AddHandler extends PatchOperation { private mixed $previous; diff --git a/src/operations/handlers/CopyHandler.php b/src/operations/handlers/CopyHandler.php index fd506b7..747434c 100644 --- a/src/operations/handlers/CopyHandler.php +++ b/src/operations/handlers/CopyHandler.php @@ -5,6 +5,9 @@ use blancks\JsonPatch\json\accessors\UndefinedValue; use blancks\JsonPatch\operations\PatchOperation; +/** + * @internal + */ final class CopyHandler extends PatchOperation { private mixed $previous; diff --git a/src/operations/handlers/MoveHandler.php b/src/operations/handlers/MoveHandler.php index a7ae091..3659434 100644 --- a/src/operations/handlers/MoveHandler.php +++ b/src/operations/handlers/MoveHandler.php @@ -4,6 +4,9 @@ use blancks\JsonPatch\operations\PatchOperation; +/** + * @internal + */ final class MoveHandler extends PatchOperation { /** diff --git a/src/operations/handlers/RemoveHandler.php b/src/operations/handlers/RemoveHandler.php index 88e6ca3..909f23f 100644 --- a/src/operations/handlers/RemoveHandler.php +++ b/src/operations/handlers/RemoveHandler.php @@ -4,6 +4,9 @@ use blancks\JsonPatch\operations\PatchOperation; +/** + * @internal + */ final class RemoveHandler extends PatchOperation { private mixed $previous; diff --git a/src/operations/handlers/ReplaceHandler.php b/src/operations/handlers/ReplaceHandler.php index f66719e..e58ac8f 100644 --- a/src/operations/handlers/ReplaceHandler.php +++ b/src/operations/handlers/ReplaceHandler.php @@ -4,6 +4,9 @@ use blancks\JsonPatch\operations\PatchOperation; +/** + * @internal + */ final class ReplaceHandler extends PatchOperation { private mixed $previous; diff --git a/src/operations/handlers/TestHandler.php b/src/operations/handlers/TestHandler.php index c8f9088..a2f40ca 100644 --- a/src/operations/handlers/TestHandler.php +++ b/src/operations/handlers/TestHandler.php @@ -5,6 +5,9 @@ use blancks\JsonPatch\exceptions\FailedTestException; use blancks\JsonPatch\operations\PatchOperation; +/** + * @internal + */ final class TestHandler extends PatchOperation { /** From e8b5a9f6d8d17728916009e60f9a94bd0ddacc8c Mon Sep 17 00:00:00 2001 From: Andrew Coulton Date: Sun, 30 Nov 2025 10:55:45 +0000 Subject: [PATCH 3/4] refactor! Fully rename operation classes & methods to `xxxHandler` Renames all remaining classes, interfaces & methods related to patch operation handlers to include the `Handler` suffix. This reinstates consistency between the naming of these concerns, and will provide the cleanest base for implementing patch operation DTOs without naming conflicts or confusion. It will, however, impact any end-users who have implemented & registered custom patch handlers as they will need to update them for the new naming as part of the 3.x upgrade. --- README.md | 6 ++-- src/FastJsonPatch.php | 34 +++++++++---------- src/operations/handlers/AddHandler.php | 3 +- src/operations/handlers/CopyHandler.php | 3 +- src/operations/handlers/MoveHandler.php | 4 +-- .../PatchOperationHandler.php} | 8 +++-- .../PatchOperationHandlerInterface.php} | 4 +-- src/operations/handlers/RemoveHandler.php | 4 +-- src/operations/handlers/ReplaceHandler.php | 4 +-- src/operations/handlers/TestHandler.php | 3 +- tests/FastJsonPatchTest.php | 6 ++-- .../exceptions/ArrayBoundaryExceptionTest.php | 4 +-- tests/exceptions/FailedTestExceptionTest.php | 4 +-- .../exceptions/InvalidPatchExceptionTest.php | 4 +-- .../InvalidPatchFromExceptionTest.php | 4 +-- .../InvalidPatchOperationExceptionTest.php | 4 +-- .../InvalidPatchPathExceptionTest.php | 4 +-- .../InvalidPatchValueExceptionTest.php | 4 +-- .../exceptions/MalformedPathExceptionTest.php | 4 +-- tests/exceptions/UnknownPathExceptionTest.php | 4 +-- tests/operations/handlers/AddTest.php | 4 +-- tests/operations/handlers/CopyTest.php | 4 +-- tests/operations/handlers/MoveTest.php | 4 +-- tests/operations/handlers/RemoveTest.php | 4 +-- tests/operations/handlers/ReplaceTest.php | 4 +-- tests/operations/handlers/TestTest.php | 4 +-- 26 files changed, 66 insertions(+), 73 deletions(-) rename src/operations/{PatchOperation.php => handlers/PatchOperationHandler.php} (79%) rename src/operations/{PatchOperationInterface.php => handlers/PatchOperationHandlerInterface.php} (93%) diff --git a/README.md b/README.md index a31fcd0..2046e55 100644 --- a/README.md +++ b/README.md @@ -185,14 +185,14 @@ Patch application is designed to be atomic. If any operation of a given patch fa ``` -#### `function registerOperation(PatchOperationInterface $PatchOperation): void` +#### `function registerOperationHandler(PatchOperationHandlerInterface $PatchOperation): void` - **Description**: Allows to register new patch operation handlers or to override existing ones. - **Parameters**: - - `PatchOperationInterface $PatchOperation`: The handler class for handling the operation. + - `PatchOperationHandlerInterface $PatchOperation`: The handler class for handling the operation. - **Example**: ```php - $FastJsonPatch->registerOperation(new Add); + $FastJsonPatch->registerOperationHandler(new Add); ``` diff --git a/src/FastJsonPatch.php b/src/FastJsonPatch.php index 90a92a7..eae4c2d 100644 --- a/src/FastJsonPatch.php +++ b/src/FastJsonPatch.php @@ -22,13 +22,13 @@ JsonPointerHandlerInterface }; use blancks\JsonPatch\operations\{ - PatchOperationInterface, PatchValidationTrait }; use blancks\JsonPatch\operations\handlers\{ AddHandler, CopyHandler, MoveHandler, + PatchOperationHandlerInterface, RemoveHandler, ReplaceHandler, TestHandler @@ -50,9 +50,9 @@ final class FastJsonPatch implements JsonHandlerAwareInterface, JsonPointerHandl private mixed $document; /** - * @var array registered classes for handling patch operations + * @var array registered classes for handling patch operations */ - private array $operations = []; + private array $operationHandlers = []; /** * Creates a FastJsonPatch instance from a json string document @@ -93,21 +93,21 @@ public function __construct( $this->setJsonPointerHandler($JsonPointerHandler); $this->setJsonHandler($JsonHandler); - $this->registerOperation(new AddHandler); - $this->registerOperation(new CopyHandler); - $this->registerOperation(new MoveHandler); - $this->registerOperation(new RemoveHandler); - $this->registerOperation(new ReplaceHandler); - $this->registerOperation(new TestHandler); + $this->registerOperationHandler(new AddHandler); + $this->registerOperationHandler(new CopyHandler); + $this->registerOperationHandler(new MoveHandler); + $this->registerOperationHandler(new RemoveHandler); + $this->registerOperationHandler(new ReplaceHandler); + $this->registerOperationHandler(new TestHandler); } /** * Allows to register a class that will be responsible to handle a specific patch operation. * You can replace a handler class for a given operation or register handlers for custom patch operations - * @param PatchOperationInterface $PatchOperation + * @param PatchOperationHandlerInterface $PatchOperation * @return void */ - public function registerOperation(PatchOperationInterface $PatchOperation): void + public function registerOperationHandler(PatchOperationHandlerInterface $PatchOperation): void { if ($PatchOperation instanceof JsonHandlerAwareInterface) { $PatchOperation->setJsonHandler($this->JsonHandler); @@ -117,7 +117,7 @@ public function registerOperation(PatchOperationInterface $PatchOperation): void $PatchOperation->setJsonPointerHandler($this->JsonPointerHandler); } - $this->operations[$PatchOperation->getOperation()] = $PatchOperation; + $this->operationHandlers[$PatchOperation->getOperation()] = $PatchOperation; } /** @@ -134,10 +134,10 @@ public function apply(string $patch): void $document = &$this->document; foreach ($this->patchIterator($patch) as $op => $p) { - if (!isset($this->operations[$op])) { + if (!isset($this->operationHandlers[$op])) { throw new InvalidPatchOperationException(sprintf('Unknown operation "%s"', $op)); } - $Operation = $this->operations[$op]; + $Operation = $this->operationHandlers[$op]; $Operation->validate($p); $Operation->apply($document, $p); $revertPatch[] = $Operation->getRevertPatch($p); @@ -146,7 +146,7 @@ public function apply(string $patch): void foreach (array_reverse($revertPatch) as $p) { if (!is_null($p)) { $p = (object) $p; - $this->operations[$p->op]->apply($this->document, $p); + $this->operationHandlers[$p->op]->apply($this->document, $p); } } @@ -172,10 +172,10 @@ public function isValidPatch(string $patch): bool { try { foreach ($this->patchIterator($patch) as $op => $p) { - if (!isset($this->operations[$op])) { + if (!isset($this->operationHandlers[$op])) { return false; } - $this->operations[$op]->validate($p); + $this->operationHandlers[$op]->validate($p); } return true; } catch (FastJsonPatchException) { diff --git a/src/operations/handlers/AddHandler.php b/src/operations/handlers/AddHandler.php index 62e7ad7..daf3d2a 100644 --- a/src/operations/handlers/AddHandler.php +++ b/src/operations/handlers/AddHandler.php @@ -3,12 +3,11 @@ namespace blancks\JsonPatch\operations\handlers; use blancks\JsonPatch\json\accessors\UndefinedValue; -use blancks\JsonPatch\operations\PatchOperation; /** * @internal */ -final class AddHandler extends PatchOperation +final class AddHandler extends PatchOperationHandler { private mixed $previous; diff --git a/src/operations/handlers/CopyHandler.php b/src/operations/handlers/CopyHandler.php index 747434c..f595f7b 100644 --- a/src/operations/handlers/CopyHandler.php +++ b/src/operations/handlers/CopyHandler.php @@ -3,12 +3,11 @@ namespace blancks\JsonPatch\operations\handlers; use blancks\JsonPatch\json\accessors\UndefinedValue; -use blancks\JsonPatch\operations\PatchOperation; /** * @internal */ -final class CopyHandler extends PatchOperation +final class CopyHandler extends PatchOperationHandler { private mixed $previous; diff --git a/src/operations/handlers/MoveHandler.php b/src/operations/handlers/MoveHandler.php index 3659434..d690b7c 100644 --- a/src/operations/handlers/MoveHandler.php +++ b/src/operations/handlers/MoveHandler.php @@ -2,12 +2,10 @@ namespace blancks\JsonPatch\operations\handlers; -use blancks\JsonPatch\operations\PatchOperation; - /** * @internal */ -final class MoveHandler extends PatchOperation +final class MoveHandler extends PatchOperationHandler { /** * @param object{ diff --git a/src/operations/PatchOperation.php b/src/operations/handlers/PatchOperationHandler.php similarity index 79% rename from src/operations/PatchOperation.php rename to src/operations/handlers/PatchOperationHandler.php index c6c91ec..1503859 100644 --- a/src/operations/PatchOperation.php +++ b/src/operations/handlers/PatchOperationHandler.php @@ -1,14 +1,16 @@ registerOperation(new class() extends PatchOperation { + $FastJsonPatch->registerOperationHandler(new class() extends PatchOperationHandler { public function getOperation(): string { return 'addexclamation'; diff --git a/tests/exceptions/ArrayBoundaryExceptionTest.php b/tests/exceptions/ArrayBoundaryExceptionTest.php index 63e62b8..619b9a8 100644 --- a/tests/exceptions/ArrayBoundaryExceptionTest.php +++ b/tests/exceptions/ArrayBoundaryExceptionTest.php @@ -13,7 +13,7 @@ use blancks\JsonPatch\json\handlers\BasicJsonHandler; use blancks\JsonPatch\json\pointer\JsonPointer6901; use blancks\JsonPatch\operations\handlers\AddHandler; -use blancks\JsonPatch\operations\PatchOperation; +use blancks\JsonPatch\operations\handlers\PatchOperationHandler; use blancks\JsonPatch\FastJsonPatch; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\DataProvider; @@ -31,7 +31,7 @@ #[UsesClass(CrudTrait::class)] #[UsesClass(BasicJsonHandler::class)] #[UsesClass(JsonPointer6901::class)] -#[UsesClass(PatchOperation::class)] +#[UsesClass(PatchOperationHandler::class)] #[UsesClass(AddHandler::class)] final class ArrayBoundaryExceptionTest extends TestCase { diff --git a/tests/exceptions/FailedTestExceptionTest.php b/tests/exceptions/FailedTestExceptionTest.php index 42e2084..8d97391 100644 --- a/tests/exceptions/FailedTestExceptionTest.php +++ b/tests/exceptions/FailedTestExceptionTest.php @@ -12,8 +12,8 @@ use blancks\JsonPatch\json\crud\CrudTrait; use blancks\JsonPatch\json\handlers\BasicJsonHandler; use blancks\JsonPatch\json\pointer\JsonPointer6901; +use blancks\JsonPatch\operations\handlers\PatchOperationHandler; use blancks\JsonPatch\operations\handlers\TestHandler; -use blancks\JsonPatch\operations\PatchOperation; use blancks\JsonPatch\FastJsonPatch; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\DataProvider; @@ -31,7 +31,7 @@ #[UsesClass(CrudTrait::class)] #[UsesClass(BasicJsonHandler::class)] #[UsesClass(JsonPointer6901::class)] -#[UsesClass(PatchOperation::class)] +#[UsesClass(PatchOperationHandler::class)] #[UsesClass(TestHandler::class)] final class FailedTestExceptionTest extends TestCase { diff --git a/tests/exceptions/InvalidPatchExceptionTest.php b/tests/exceptions/InvalidPatchExceptionTest.php index 7d2d82c..7c8738d 100644 --- a/tests/exceptions/InvalidPatchExceptionTest.php +++ b/tests/exceptions/InvalidPatchExceptionTest.php @@ -10,7 +10,7 @@ use blancks\JsonPatch\json\accessors\ValueAccessorAwareTrait; use blancks\JsonPatch\json\handlers\BasicJsonHandler; use blancks\JsonPatch\json\pointer\JsonPointer6901; -use blancks\JsonPatch\operations\PatchOperation; +use blancks\JsonPatch\operations\handlers\PatchOperationHandler; use blancks\JsonPatch\FastJsonPatch; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\UsesClass; @@ -25,7 +25,7 @@ #[UsesClass(ValueAccessorAwareTrait::class)] #[UsesClass(BasicJsonHandler::class)] #[UsesClass(JsonPointer6901::class)] -#[UsesClass(PatchOperation::class)] +#[UsesClass(PatchOperationHandler::class)] final class InvalidPatchExceptionTest extends TestCase { /** diff --git a/tests/exceptions/InvalidPatchFromExceptionTest.php b/tests/exceptions/InvalidPatchFromExceptionTest.php index 0ebfe5f..ea23c1a 100644 --- a/tests/exceptions/InvalidPatchFromExceptionTest.php +++ b/tests/exceptions/InvalidPatchFromExceptionTest.php @@ -15,8 +15,8 @@ use blancks\JsonPatch\json\pointer\JsonPointer6901; use blancks\JsonPatch\operations\handlers\AddHandler; use blancks\JsonPatch\operations\handlers\CopyHandler; +use blancks\JsonPatch\operations\handlers\PatchOperationHandler; use blancks\JsonPatch\operations\handlers\RemoveHandler; -use blancks\JsonPatch\operations\PatchOperation; use blancks\JsonPatch\FastJsonPatch; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\UsesClass; @@ -34,7 +34,7 @@ #[UsesClass(CrudTrait::class)] #[UsesClass(BasicJsonHandler::class)] #[UsesClass(JsonPointer6901::class)] -#[UsesClass(PatchOperation::class)] +#[UsesClass(PatchOperationHandler::class)] #[UsesClass(AddHandler::class)] #[UsesClass(CopyHandler::class)] #[UsesClass(RemoveHandler::class)] diff --git a/tests/exceptions/InvalidPatchOperationExceptionTest.php b/tests/exceptions/InvalidPatchOperationExceptionTest.php index e0154ce..0841940 100644 --- a/tests/exceptions/InvalidPatchOperationExceptionTest.php +++ b/tests/exceptions/InvalidPatchOperationExceptionTest.php @@ -11,7 +11,7 @@ use blancks\JsonPatch\json\accessors\ValueAccessorAwareTrait; use blancks\JsonPatch\json\handlers\BasicJsonHandler; use blancks\JsonPatch\json\pointer\JsonPointer6901; -use blancks\JsonPatch\operations\PatchOperation; +use blancks\JsonPatch\operations\handlers\PatchOperationHandler; use blancks\JsonPatch\FastJsonPatch; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\UsesClass; @@ -27,7 +27,7 @@ #[UsesClass(ValueAccessorAwareTrait::class)] #[UsesClass(BasicJsonHandler::class)] #[UsesClass(JsonPointer6901::class)] -#[UsesClass(PatchOperation::class)] +#[UsesClass(PatchOperationHandler::class)] final class InvalidPatchOperationExceptionTest extends TestCase { /** diff --git a/tests/exceptions/InvalidPatchPathExceptionTest.php b/tests/exceptions/InvalidPatchPathExceptionTest.php index 542acda..f34af28 100644 --- a/tests/exceptions/InvalidPatchPathExceptionTest.php +++ b/tests/exceptions/InvalidPatchPathExceptionTest.php @@ -11,7 +11,7 @@ use blancks\JsonPatch\json\accessors\ValueAccessorAwareTrait; use blancks\JsonPatch\json\handlers\BasicJsonHandler; use blancks\JsonPatch\json\pointer\JsonPointer6901; -use blancks\JsonPatch\operations\PatchOperation; +use blancks\JsonPatch\operations\handlers\PatchOperationHandler; use blancks\JsonPatch\FastJsonPatch; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\UsesClass; @@ -27,7 +27,7 @@ #[UsesClass(ValueAccessorAwareTrait::class)] #[UsesClass(BasicJsonHandler::class)] #[UsesClass(JsonPointer6901::class)] -#[UsesClass(PatchOperation::class)] +#[UsesClass(PatchOperationHandler::class)] final class InvalidPatchPathExceptionTest extends TestCase { /** diff --git a/tests/exceptions/InvalidPatchValueExceptionTest.php b/tests/exceptions/InvalidPatchValueExceptionTest.php index 96be382..994b796 100644 --- a/tests/exceptions/InvalidPatchValueExceptionTest.php +++ b/tests/exceptions/InvalidPatchValueExceptionTest.php @@ -12,7 +12,7 @@ use blancks\JsonPatch\json\handlers\BasicJsonHandler; use blancks\JsonPatch\json\pointer\JsonPointer6901; use blancks\JsonPatch\operations\handlers\AddHandler; -use blancks\JsonPatch\operations\PatchOperation; +use blancks\JsonPatch\operations\handlers\PatchOperationHandler; use blancks\JsonPatch\FastJsonPatch; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\UsesClass; @@ -28,7 +28,7 @@ #[UsesClass(ValueAccessorAwareTrait::class)] #[UsesClass(BasicJsonHandler::class)] #[UsesClass(JsonPointer6901::class)] -#[UsesClass(PatchOperation::class)] +#[UsesClass(PatchOperationHandler::class)] #[UsesClass(AddHandler::class)] final class InvalidPatchValueExceptionTest extends TestCase { diff --git a/tests/exceptions/MalformedPathExceptionTest.php b/tests/exceptions/MalformedPathExceptionTest.php index c6ce1e7..362972a 100644 --- a/tests/exceptions/MalformedPathExceptionTest.php +++ b/tests/exceptions/MalformedPathExceptionTest.php @@ -11,7 +11,7 @@ use blancks\JsonPatch\json\accessors\ValueAccessorAwareTrait; use blancks\JsonPatch\json\handlers\BasicJsonHandler; use blancks\JsonPatch\json\pointer\JsonPointer6901; -use blancks\JsonPatch\operations\PatchOperation; +use blancks\JsonPatch\operations\handlers\PatchOperationHandler; use blancks\JsonPatch\FastJsonPatch; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\UsesClass; @@ -27,7 +27,7 @@ #[UsesClass(ValueAccessorAwareTrait::class)] #[UsesClass(BasicJsonHandler::class)] #[UsesClass(JsonPointer6901::class)] -#[UsesClass(PatchOperation::class)] +#[UsesClass(PatchOperationHandler::class)] final class MalformedPathExceptionTest extends TestCase { /** diff --git a/tests/exceptions/UnknownPathExceptionTest.php b/tests/exceptions/UnknownPathExceptionTest.php index cc8c8d0..e6a0d3a 100644 --- a/tests/exceptions/UnknownPathExceptionTest.php +++ b/tests/exceptions/UnknownPathExceptionTest.php @@ -16,10 +16,10 @@ use blancks\JsonPatch\operations\handlers\AddHandler; use blancks\JsonPatch\operations\handlers\CopyHandler; use blancks\JsonPatch\operations\handlers\MoveHandler; +use blancks\JsonPatch\operations\handlers\PatchOperationHandler; use blancks\JsonPatch\operations\handlers\RemoveHandler; use blancks\JsonPatch\operations\handlers\ReplaceHandler; use blancks\JsonPatch\operations\handlers\TestHandler; -use blancks\JsonPatch\operations\PatchOperation; use blancks\JsonPatch\FastJsonPatch; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\DataProvider; @@ -38,7 +38,7 @@ #[UsesClass(CrudTrait::class)] #[UsesClass(BasicJsonHandler::class)] #[UsesClass(JsonPointer6901::class)] -#[UsesClass(PatchOperation::class)] +#[UsesClass(PatchOperationHandler::class)] #[UsesClass(AddHandler::class)] #[UsesClass(CopyHandler::class)] #[UsesClass(MoveHandler::class)] diff --git a/tests/operations/handlers/AddTest.php b/tests/operations/handlers/AddTest.php index 7d364ea..58206c0 100644 --- a/tests/operations/handlers/AddTest.php +++ b/tests/operations/handlers/AddTest.php @@ -15,14 +15,14 @@ use blancks\JsonPatch\json\handlers\JsonHandlerAwareTrait; use blancks\JsonPatch\json\pointer\JsonPointer6901; use blancks\JsonPatch\operations\handlers\AddHandler; -use blancks\JsonPatch\operations\PatchOperation; +use blancks\JsonPatch\operations\handlers\PatchOperationHandler; use blancks\JsonPatch\operations\PatchValidationTrait; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\UsesClass; use PHPUnit\Framework\TestCase; #[CoversClass(AddHandler::class)] -#[CoversClass(PatchOperation::class)] +#[CoversClass(PatchOperationHandler::class)] #[UsesClass(PatchValidationTrait::class)] #[UsesClass(CrudTrait::class)] #[UsesClass(BasicJsonHandler::class)] diff --git a/tests/operations/handlers/CopyTest.php b/tests/operations/handlers/CopyTest.php index 9dbbc73..87044e3 100644 --- a/tests/operations/handlers/CopyTest.php +++ b/tests/operations/handlers/CopyTest.php @@ -17,14 +17,14 @@ use blancks\JsonPatch\json\handlers\JsonHandlerAwareTrait; use blancks\JsonPatch\json\pointer\JsonPointer6901; use blancks\JsonPatch\operations\handlers\CopyHandler; -use blancks\JsonPatch\operations\PatchOperation; +use blancks\JsonPatch\operations\handlers\PatchOperationHandler; use blancks\JsonPatch\operations\PatchValidationTrait; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\UsesClass; use PHPUnit\Framework\TestCase; #[CoversClass(CopyHandler::class)] -#[CoversClass(PatchOperation::class)] +#[CoversClass(PatchOperationHandler::class)] #[UsesClass(PatchValidationTrait::class)] #[UsesClass(CrudTrait::class)] #[UsesClass(BasicJsonHandler::class)] diff --git a/tests/operations/handlers/MoveTest.php b/tests/operations/handlers/MoveTest.php index 61cfa06..d94a659 100644 --- a/tests/operations/handlers/MoveTest.php +++ b/tests/operations/handlers/MoveTest.php @@ -17,14 +17,14 @@ use blancks\JsonPatch\json\handlers\JsonHandlerAwareTrait; use blancks\JsonPatch\json\pointer\JsonPointer6901; use blancks\JsonPatch\operations\handlers\MoveHandler; -use blancks\JsonPatch\operations\PatchOperation; +use blancks\JsonPatch\operations\handlers\PatchOperationHandler; use blancks\JsonPatch\operations\PatchValidationTrait; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\UsesClass; use PHPUnit\Framework\TestCase; #[CoversClass(MoveHandler::class)] -#[CoversClass(PatchOperation::class)] +#[CoversClass(PatchOperationHandler::class)] #[UsesClass(PatchValidationTrait::class)] #[UsesClass(CrudTrait::class)] #[UsesClass(BasicJsonHandler::class)] diff --git a/tests/operations/handlers/RemoveTest.php b/tests/operations/handlers/RemoveTest.php index a894475..dbc93fe 100644 --- a/tests/operations/handlers/RemoveTest.php +++ b/tests/operations/handlers/RemoveTest.php @@ -16,15 +16,15 @@ use blancks\JsonPatch\json\handlers\BasicJsonHandler; use blancks\JsonPatch\json\handlers\JsonHandlerAwareTrait; use blancks\JsonPatch\json\pointer\JsonPointer6901; +use blancks\JsonPatch\operations\handlers\PatchOperationHandler; use blancks\JsonPatch\operations\handlers\RemoveHandler; -use blancks\JsonPatch\operations\PatchOperation; use blancks\JsonPatch\operations\PatchValidationTrait; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\UsesClass; use PHPUnit\Framework\TestCase; #[CoversClass(RemoveHandler::class)] -#[CoversClass(PatchOperation::class)] +#[CoversClass(PatchOperationHandler::class)] #[UsesClass(PatchValidationTrait::class)] #[UsesClass(CrudTrait::class)] #[UsesClass(BasicJsonHandler::class)] diff --git a/tests/operations/handlers/ReplaceTest.php b/tests/operations/handlers/ReplaceTest.php index 19118ea..6b42747 100644 --- a/tests/operations/handlers/ReplaceTest.php +++ b/tests/operations/handlers/ReplaceTest.php @@ -17,15 +17,15 @@ use blancks\JsonPatch\json\handlers\BasicJsonHandler; use blancks\JsonPatch\json\handlers\JsonHandlerAwareTrait; use blancks\JsonPatch\json\pointer\JsonPointer6901; +use blancks\JsonPatch\operations\handlers\PatchOperationHandler; use blancks\JsonPatch\operations\handlers\ReplaceHandler; -use blancks\JsonPatch\operations\PatchOperation; use blancks\JsonPatch\operations\PatchValidationTrait; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\UsesClass; use PHPUnit\Framework\TestCase; #[CoversClass(ReplaceHandler::class)] -#[CoversClass(PatchOperation::class)] +#[CoversClass(PatchOperationHandler::class)] #[UsesClass(PatchValidationTrait::class)] #[UsesClass(CrudTrait::class)] #[UsesClass(BasicJsonHandler::class)] diff --git a/tests/operations/handlers/TestTest.php b/tests/operations/handlers/TestTest.php index 1845d49..122a1a6 100644 --- a/tests/operations/handlers/TestTest.php +++ b/tests/operations/handlers/TestTest.php @@ -17,15 +17,15 @@ use blancks\JsonPatch\json\handlers\BasicJsonHandler; use blancks\JsonPatch\json\handlers\JsonHandlerAwareTrait; use blancks\JsonPatch\json\pointer\JsonPointer6901; +use blancks\JsonPatch\operations\handlers\PatchOperationHandler; use blancks\JsonPatch\operations\handlers\TestHandler; -use blancks\JsonPatch\operations\PatchOperation; use blancks\JsonPatch\operations\PatchValidationTrait; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\UsesClass; use PHPUnit\Framework\TestCase; #[CoversClass(TestHandler::class)] -#[CoversClass(PatchOperation::class)] +#[CoversClass(PatchOperationHandler::class)] #[UsesClass(PatchValidationTrait::class)] #[UsesClass(CrudTrait::class)] #[UsesClass(BasicJsonHandler::class)] From e19ecc1b7c87d2200cbf13e4f7414e1a2a63f41f Mon Sep 17 00:00:00 2001 From: Andrew Coulton Date: Sat, 6 Dec 2025 08:47:12 +0000 Subject: [PATCH 4/4] nits: Apply CR fixes --- src/operations/handlers/PatchOperationHandler.php | 1 - src/operations/handlers/TestHandler.php | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/operations/handlers/PatchOperationHandler.php b/src/operations/handlers/PatchOperationHandler.php index 1503859..034fd3d 100644 --- a/src/operations/handlers/PatchOperationHandler.php +++ b/src/operations/handlers/PatchOperationHandler.php @@ -6,7 +6,6 @@ use blancks\JsonPatch\json\handlers\JsonHandlerAwareTrait; use blancks\JsonPatch\json\pointer\JsonPointerHandlerAwareInterface; use blancks\JsonPatch\json\pointer\JsonPointerHandlerAwareTrait; -use blancks\JsonPatch\operations\handlers\PatchOperationHandlerInterface; use blancks\JsonPatch\operations\PatchValidationTrait; abstract class PatchOperationHandler implements diff --git a/src/operations/handlers/TestHandler.php b/src/operations/handlers/TestHandler.php index f39c5b9..69f2e02 100644 --- a/src/operations/handlers/TestHandler.php +++ b/src/operations/handlers/TestHandler.php @@ -40,7 +40,7 @@ public function apply(mixed &$document, object $patch): void if (!$this->isJsonEquals($item, $patch->value)) { throw new FailedTestException( sprintf( - 'TestHandler operation failed asserting that "%s" equals "%s"', + 'Test operation failed asserting that "%s" equals "%s"', $this->JsonHandler->encode($item), $this->JsonHandler->encode($patch->value) ),