Skip to content

Commit 96f9d75

Browse files
committed
Contract: Add and adopt MethodNotImplementedException and others
1 parent b9a178a commit 96f9d75

18 files changed

+115
-37
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace Salient\Contract\Core;
4+
5+
use Throwable;
6+
7+
/**
8+
* @api
9+
*/
10+
interface MethodNotImplementedExceptionInterface extends Throwable
11+
{
12+
/**
13+
* Get the name of the class that has not implemented the method
14+
*
15+
* @return class-string
16+
*/
17+
public function getClass(): string;
18+
19+
/**
20+
* Get the name of the method that has not been implemented
21+
*/
22+
public function getMethod(): string;
23+
24+
/**
25+
* Get the name of the class or interface from which the unimplemented
26+
* method is inherited
27+
*
28+
* @return class-string
29+
*/
30+
public function getPrototypeClass(): string;
31+
}

src/Toolkit/Contract/Core/ProviderInterface.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
use Salient\Contract\Container\ContainerInterface;
66
use Salient\Contract\Container\HasContainer;
7-
use Salient\Core\Exception\MethodNotImplementedException;
87
use Stringable;
98

109
/**
@@ -77,8 +76,8 @@ public function getContext(?ContainerInterface $container = null): ProviderConte
7776
* must never be cached.
7877
*
7978
* @return $this
80-
* @throws MethodNotImplementedException if heartbeat monitoring isn't
81-
* supported.
79+
* @throws MethodNotImplementedExceptionInterface if heartbeat monitoring
80+
* isn't supported.
8281
*/
8382
public function checkHeartbeat(int $ttl = 300);
8483
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace Salient\Contract\Sync\Exception;
4+
5+
/** @api */
6+
interface FilterPolicyViolationExceptionInterface extends SyncExceptionInterface {}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace Salient\Contract\Sync\Exception;
4+
5+
/** @api */
6+
interface InvalidFilterExceptionInterface extends SyncExceptionInterface {}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace Salient\Contract\Sync\Exception;
4+
5+
/** @api */
6+
interface InvalidFilterSignatureExceptionInterface extends InvalidFilterExceptionInterface {}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace Salient\Contract\Sync\Exception;
4+
5+
/** @api */
6+
interface SyncEntityNotFoundExceptionInterface extends SyncExceptionInterface {}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace Salient\Contract\Sync\Exception;
4+
5+
/** @api */
6+
interface SyncEntityRecursionExceptionInterface extends SyncExceptionInterface {}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace Salient\Contract\Sync\Exception;
4+
5+
use Throwable;
6+
7+
/** @api */
8+
interface SyncExceptionInterface extends Throwable {}

src/Toolkit/Contract/Sync/FilterPolicy.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Salient\Contract\Sync;
44

5-
use Salient\Sync\Exception\SyncFilterPolicyViolationException;
5+
use Salient\Contract\Sync\Exception\FilterPolicyViolationExceptionInterface;
66

77
/**
88
* Policies for unclaimed sync operation filters
@@ -20,8 +20,8 @@ interface FilterPolicy
2020
/**
2121
* Throw an exception if there are unclaimed filters
2222
*
23-
* A {@see SyncFilterPolicyViolationException} is thrown and the request is
24-
* not passed to the provider.
23+
* A {@see FilterPolicyViolationExceptionInterface} is thrown and the
24+
* request is not passed to the provider.
2525
*
2626
* This is the default policy.
2727
*/

src/Toolkit/Contract/Sync/SyncContextInterface.php

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
namespace Salient\Contract\Sync;
44

55
use Salient\Contract\Core\ProviderContextInterface;
6-
use Salient\Sync\Exception\SyncEntityRecursionException;
7-
use Salient\Sync\Exception\SyncInvalidFilterException;
8-
use Salient\Sync\Exception\SyncInvalidFilterSignatureException;
6+
use Salient\Contract\Sync\Exception\InvalidFilterExceptionInterface;
7+
use Salient\Contract\Sync\Exception\InvalidFilterSignatureExceptionInterface;
8+
use Salient\Contract\Sync\Exception\SyncEntityRecursionExceptionInterface;
99
use DateTimeInterface;
1010

1111
/**
@@ -63,7 +63,7 @@ interface SyncContextInterface extends ProviderContextInterface
6363
* @param mixed ...$args Sync operation arguments, not including the
6464
* {@see SyncContextInterface} argument.
6565
* @return static
66-
* @throws SyncInvalidFilterSignatureException
66+
* @throws InvalidFilterSignatureExceptionInterface
6767
*/
6868
public function withFilter($operation, ...$args);
6969

@@ -143,7 +143,7 @@ public function pushWithRecursionCheck(SyncEntityInterface $entity);
143143
/**
144144
* Throw an exception if recursion is detected
145145
*
146-
* @throws SyncEntityRecursionException if
146+
* @throws SyncEntityRecursionExceptionInterface if
147147
* {@see SyncContextInterface::pushWithRecursionCheck()} detected recursion.
148148
*/
149149
public function maybeThrowRecursionException(): void;
@@ -211,7 +211,7 @@ public function getFilter(?string $key = null, bool $orValue = true);
211211
* Same as {@see SyncContextInterface::getFilter()}, but an exception is
212212
* thrown if the value is not an integer.
213213
*
214-
* @throws SyncInvalidFilterException
214+
* @throws InvalidFilterExceptionInterface
215215
*/
216216
public function getFilterInt(string $key, bool $orValue = true): ?int;
217217

@@ -222,7 +222,7 @@ public function getFilterInt(string $key, bool $orValue = true): ?int;
222222
* Same as {@see SyncContextInterface::getFilter()}, but an exception is
223223
* thrown if the value is not a string.
224224
*
225-
* @throws SyncInvalidFilterException
225+
* @throws InvalidFilterExceptionInterface
226226
*/
227227
public function getFilterString(string $key, bool $orValue = true): ?string;
228228

@@ -234,7 +234,7 @@ public function getFilterString(string $key, bool $orValue = true): ?string;
234234
* thrown if the value is not an integer or string.
235235
*
236236
* @return int|string|null
237-
* @throws SyncInvalidFilterException
237+
* @throws InvalidFilterExceptionInterface
238238
*/
239239
public function getFilterArrayKey(string $key, bool $orValue = true);
240240

@@ -246,7 +246,7 @@ public function getFilterArrayKey(string $key, bool $orValue = true);
246246
* thrown if the value is not a list of integers.
247247
*
248248
* @return int[]|null
249-
* @throws SyncInvalidFilterException
249+
* @throws InvalidFilterExceptionInterface
250250
*/
251251
public function getFilterIntList(string $key, bool $orValue = true): ?array;
252252

@@ -258,7 +258,7 @@ public function getFilterIntList(string $key, bool $orValue = true): ?array;
258258
* thrown if the value is not a list of strings.
259259
*
260260
* @return string[]|null
261-
* @throws SyncInvalidFilterException
261+
* @throws InvalidFilterExceptionInterface
262262
*/
263263
public function getFilterStringList(string $key, bool $orValue = true): ?array;
264264

@@ -270,7 +270,7 @@ public function getFilterStringList(string $key, bool $orValue = true): ?array;
270270
* thrown if the value is not a list of integers and strings.
271271
*
272272
* @return (int|string)[]|null
273-
* @throws SyncInvalidFilterException
273+
* @throws InvalidFilterExceptionInterface
274274
*/
275275
public function getFilterArrayKeyList(string $key, bool $orValue = true): ?array;
276276

@@ -303,7 +303,7 @@ public function claimFilter(string $key, bool $orValue = true);
303303
* Same as {@see SyncContextInterface::claimFilter()}, but an exception is
304304
* thrown if the value is not an integer.
305305
*
306-
* @throws SyncInvalidFilterException
306+
* @throws InvalidFilterExceptionInterface
307307
*/
308308
public function claimFilterInt(string $key, bool $orValue = true): ?int;
309309

@@ -314,7 +314,7 @@ public function claimFilterInt(string $key, bool $orValue = true): ?int;
314314
* Same as {@see SyncContextInterface::claimFilter()}, but an exception is
315315
* thrown if the value is not a string.
316316
*
317-
* @throws SyncInvalidFilterException
317+
* @throws InvalidFilterExceptionInterface
318318
*/
319319
public function claimFilterString(string $key, bool $orValue = true): ?string;
320320

@@ -326,7 +326,7 @@ public function claimFilterString(string $key, bool $orValue = true): ?string;
326326
* thrown if the value is not an integer or string.
327327
*
328328
* @return int|string|null
329-
* @throws SyncInvalidFilterException
329+
* @throws InvalidFilterExceptionInterface
330330
*/
331331
public function claimFilterArrayKey(string $key, bool $orValue = true);
332332

@@ -338,7 +338,7 @@ public function claimFilterArrayKey(string $key, bool $orValue = true);
338338
* thrown if the value is not a list of integers.
339339
*
340340
* @return int[]|null
341-
* @throws SyncInvalidFilterException
341+
* @throws InvalidFilterExceptionInterface
342342
*/
343343
public function claimFilterIntList(string $key, bool $orValue = true): ?array;
344344

@@ -350,7 +350,7 @@ public function claimFilterIntList(string $key, bool $orValue = true): ?array;
350350
* thrown if the value is not a list of strings.
351351
*
352352
* @return string[]|null
353-
* @throws SyncInvalidFilterException
353+
* @throws InvalidFilterExceptionInterface
354354
*/
355355
public function claimFilterStringList(string $key, bool $orValue = true): ?array;
356356

@@ -362,7 +362,7 @@ public function claimFilterStringList(string $key, bool $orValue = true): ?array
362362
* thrown if the value is not a list of integers and strings.
363363
*
364364
* @return (int|string)[]|null
365-
* @throws SyncInvalidFilterException
365+
* @throws InvalidFilterExceptionInterface
366366
*/
367367
public function claimFilterArrayKeyList(string $key, bool $orValue = true): ?array;
368368

0 commit comments

Comments
 (0)