1 | <?php |
||
9 | final class CurrencyConverter implements CurrencyConverterInterface |
||
10 | { |
||
11 | /** |
||
12 | * @var ExchangeRateInterface[] |
||
13 | */ |
||
14 | private $exchangeRates = []; |
||
15 | |||
16 | /** |
||
17 | * CurrencyConverter constructor. |
||
18 | * @param ExchangeRateInterface[] ...$exchangeRates |
||
19 | */ |
||
20 | public function __construct(ExchangeRateInterface ...$exchangeRates) |
||
26 | |||
27 | /** |
||
28 | * @param ExchangeRateInterface $exchangeRate |
||
29 | */ |
||
30 | private function registerExchangeRate(ExchangeRateInterface $exchangeRate): void |
||
42 | |||
43 | /** |
||
44 | * @param string $sourceCurrencyCode |
||
45 | * @param string $targetCurrencyCode |
||
46 | * @return float|null |
||
47 | */ |
||
48 | private function getExchangeRate(string $sourceCurrencyCode, string $targetCurrencyCode): ?float |
||
52 | |||
53 | /** |
||
54 | * @param string $sourceCurrencyCode |
||
55 | * @param string $targetCurrencyCode |
||
56 | * @return bool |
||
57 | */ |
||
58 | private function hasExchangeRate(string $sourceCurrencyCode, string $targetCurrencyCode): bool |
||
62 | |||
63 | /** |
||
64 | * @inheritDoc |
||
65 | */ |
||
66 | public function convert(float $amount, CurrencyInterface $sourceCurrency, CurrencyInterface $targetCurrency): float |
||
76 | } |
||
77 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: