Repository: symfony/symfony
File: src/Symfony/Component/Intl/Currencies.php (PHP)

Code before:
            if (!$activeOnly) {
                $currencies[$currency] = $currencyMetadata;

                continue;
            }

            if (!self::isActive($country, $currency, $currencyMetadata, $date)) {
                continue;
            }

            $currencies[$currency] = $currencyMetadata;
        }

        return $currencies;
    }

    /**
     * @param non-empty-string $country e.g. 'FR'
     * @param non-empty-string $currency e.g. 'USD'
     * @param string $date The date that will be checked when $activeOnly is set to true
     */
    public static function existsInCountry(
        string $country,
        string $currency,
        bool $activeOnly = true,
        string $date = 'today',
    ): bool {
        try {
            $currencyMetadata = self::readEntry(['Map', $country, $currency], 'meta');
        } catch (MissingResourceException) {
            return false;
        }

        if (!$activeOnly) {
            return true;
        }

        return self::isActive($country, $currency, $currencyMetadata, $date);
    }

    /**
     * @param array{tender?: bool} $currencyMetadata
     */
    private static function isLegalTender(array $currencyMetadata): bool
    {
        return !\array_key_exists('tender', $currencyMetadata) || false !== $currencyMetadata['tender'];
    }

    /**
     * @param non-empty-string $country  e.g. 'FR'
     * @param non-empty-string $currency  e.g. 'USD'

Review comment (suggestion):
`?\DateTimeImmutable $date = null`?

providing `new \DateTimeImmutable('today')` is little effort, while providing more flexibility

Code after:
            if (self::isDateActive($country, $currency, $currencyMetadata, $date) !== $active) {
                continue;
            }

            $currencies[] = $currency;
        }

        return $currencies;
    }

    /**
     * @param string             $country     e.g. 'FR'
     * @param string             $currency    e.g. 'USD'
     * @param ?bool              $legalTender If the currency must be a legal tender; null to not filter anything
     * @param ?bool              $active      Indicates whether the currency should always be active for the given $date; null to not filter anything
     * @param \DateTimeInterface $date        The date that will be checked when $active is set to true
     */
    public static function isValidInCountry(string $country, string $currency, ?bool $legalTender = true, ?bool $active = true, \DateTimeInterface $date = new \DateTimeImmutable('today', new \DateTimeZone('Etc/UTC'))): bool
    {
        if (!self::exists($currency)) {
            throw new \InvalidArgumentException("The currency $currency does not exist.");
        }

        try {
            $currencyMetadata = self::readEntry(['Map', $country, $currency], 'meta');
        } catch (MissingResourceException) {
            return false;
        }

        if (null !== $legalTender && $legalTender !== self::isLegalTender($currencyMetadata)) {
            return false;
        }

        if (null === $active) {
            return true;
        }

        return self::isDateActive($country, $currency, $currencyMetadata, $date) === $active;
    }

    /**
     * @param array{tender?: bool} $currencyMetadata When the `tender` property does not exist, it means it is a legal tender
     */
    private static function isLegalTender(array $currencyMetadata): bool
    {
        return !\array_key_exists('tender', $currencyMetadata) || false !== $currencyMetadata['tender'];
    }

    /**
     * @param string                            $country          e.g. 'FR'
     * @param string                            $currency         e.g. 'USD'