Skip to content

Commit ff9fc3f

Browse files
committed
Psalm declarations
1 parent 2339d73 commit ff9fc3f

2 files changed

Lines changed: 11 additions & 5 deletions

File tree

src/Services/CallbackService.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,19 @@
1212

1313
final readonly class CallbackService implements PesoServiceInterface
1414
{
15+
/** @psalm-var Closure(object):(ExchangeRateResponse|ConversionResponse|ErrorResponse) */
1516
private Closure $send;
17+
/** @psalm-var Closure(object):bool */
1618
private Closure $supports;
1719

20+
/**
21+
* @psalm-param callable(object):(ExchangeRateResponse|ConversionResponse|ErrorResponse) $send
22+
* @psalm-param callable(object):bool|null $supports
23+
*/
1824
public function __construct(callable $send, callable|null $supports = null)
1925
{
20-
$this->send = Closure::fromCallable($send);
21-
$this->supports = $supports !== null ? Closure::fromCallable($supports) : static fn (object $_) => true;
26+
$this->send = $send(...);
27+
$this->supports = $supports !== null ? $supports(...) : static fn (object $_): true => true;
2228
}
2329

2430
#[Override]

src/Services/PesoServiceInterface.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
interface PesoServiceInterface
1717
{
1818
/**
19-
* @template T of object
20-
* @param T $request
21-
* @return (
19+
* @psalm-template T of object
20+
* @psalm-param T $request
21+
* @psalm-return (
2222
* T is CurrentExchangeRateRequest ? ExchangeRateResponse|ErrorResponse : (
2323
* T is HistoricalExchangeRateRequest ? ExchangeRateResponse|ErrorResponse : (
2424
* T is CurrentConversionRequest ? ConversionResponse|ErrorResponse : (

0 commit comments

Comments
 (0)