Skip to content

Commit 9aaf5b5

Browse files
committed
Changed RecoverableExceptionHandler::__invoke return type ?Promise -> void.
1 parent f24ba7f commit 9aaf5b5

File tree

7 files changed

+11
-48
lines changed

7 files changed

+11
-48
lines changed

src/Connector/AsyncDataSource.php

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,10 @@
33

44
namespace ScriptFUSION\Porter\Connector;
55

6-
use Amp\Promise;
7-
86
/**
97
* Specifies a data source and the necessary parameters required to fetch it asynchronously.
108
*/
11-
interface AsyncDataSource
9+
interface AsyncDataSource extends DataSource
1210
{
13-
/**
14-
* Computes the hash code for this object's state. The computed hash must be the same when the object state
15-
* is unchanged or is still considered equivalent for cache key purposes, otherwise the hash code must always
16-
* be different for different states.
17-
*
18-
* @return Promise<string> Hash code.
19-
*/
20-
public function computeHash(): Promise;
11+
// Intentionally empty. TODO: Remove in next version.
2112
}

src/Connector/Recoverable/ExponentialAsyncDelayRecoverableExceptionHandler.php

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

44
namespace ScriptFUSION\Porter\Connector\Recoverable;
55

6-
use Amp\Promise;
76
use ScriptFUSION\Retry\ExceptionHandler\AsyncExponentialBackoffExceptionHandler;
87

98
/**
@@ -34,8 +33,8 @@ public function initialize(): void
3433
$this->handler = new AsyncExponentialBackoffExceptionHandler($this->initialDelay);
3534
}
3635

37-
public function __invoke(RecoverableException $exception): ?Promise
36+
public function __invoke(RecoverableException $exception): void
3837
{
39-
return ($this->handler)();
38+
($this->handler)();
4039
}
4140
}

src/Connector/Recoverable/ExponentialSleepRecoverableExceptionHandler.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
namespace ScriptFUSION\Porter\Connector\Recoverable;
55

6-
use Amp\Promise;
76
use ScriptFUSION\Retry\ExceptionHandler\ExponentialBackoffExceptionHandler;
87

98
/**
@@ -34,10 +33,8 @@ public function initialize(): void
3433
$this->handler = new ExponentialBackoffExceptionHandler($this->initialDelay);
3534
}
3635

37-
public function __invoke(RecoverableException $exception): ?Promise
36+
public function __invoke(RecoverableException $exception): void
3837
{
3938
($this->handler)();
40-
41-
return null;
4239
}
4340
}

src/Connector/Recoverable/RecoverableExceptionHandler.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
namespace ScriptFUSION\Porter\Connector\Recoverable;
55

6-
use Amp\Promise;
7-
86
/**
97
* Provides methods for handling recoverable exceptions.
108
*
@@ -28,11 +26,10 @@ interface RecoverableExceptionHandler
2826
public function initialize(): void;
2927

3028
/**
31-
* Handles a recoverable exception. Return value is ignored unless it's a promise.
29+
* Handles a recoverable exception. The handler may either throw its own exception to abort the import, or ignore
30+
* the exception to continue retrying the import.
3231
*
3332
* @param RecoverableException $exception Recoverable exception.
34-
*
35-
* @return Promise|null Promise that responds with an asynchronous delay or null.
3633
*/
37-
public function __invoke(RecoverableException $exception): ?Promise;
34+
public function __invoke(RecoverableException $exception): void;
3835
}

src/Connector/Recoverable/StatelessRecoverableExceptionHandler.php

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

44
namespace ScriptFUSION\Porter\Connector\Recoverable;
55

6-
use Amp\Promise;
7-
86
/**
97
* Contains a fetch exception handler that does not have private state and therefore does not require initialization.
108
*/
@@ -25,8 +23,8 @@ final public function initialize(): void
2523
// Intentionally empty.
2624
}
2725

28-
final public function __invoke(RecoverableException $exception): ?Promise
26+
final public function __invoke(RecoverableException $exception): void
2927
{
30-
return ($this->handler)($exception);
28+
($this->handler)($exception);
3129
}
3230
}

test/Integration/Connector/ImportConnectorTest.php

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -102,22 +102,6 @@ public function testStatelessExceptionHandlerNotCloned(): void
102102
);
103103
}
104104

105-
/**
106-
* Tests that a recoverable exception handler cannot return false.
107-
*/
108-
public function testExceptionHandlerCannotCancelRetries(): void
109-
{
110-
$this->expectException(\TypeError::class);
111-
112-
FixtureFactory::buildImportConnector(
113-
\Mockery::mock(Connector::class)
114-
->shouldReceive('fetch')
115-
->andThrow(new TestRecoverableException)
116-
->getMock(),
117-
new StatelessRecoverableExceptionHandler(fn () => false)
118-
)->fetch($this->source);
119-
}
120-
121105
/**
122106
* Tests that when a user recoverable exception handler throws an exception, the handler's exception can be
123107
* captured.

test/Stubs/TestRecoverableExceptionHandler.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
namespace ScriptFUSIONTest\Stubs;
55

6-
use Amp\Promise;
76
use ScriptFUSION\Porter\Connector\Recoverable\RecoverableException;
87
use ScriptFUSION\Porter\Connector\Recoverable\RecoverableExceptionHandler;
98

@@ -21,11 +20,9 @@ public function initialize(): void
2120
})();
2221
}
2322

24-
public function __invoke(RecoverableException $exception): ?Promise
23+
public function __invoke(RecoverableException $exception): void
2524
{
2625
$this->series->next();
27-
28-
return null;
2926
}
3027

3128
public function getCurrent()

0 commit comments

Comments
 (0)