/**
   * Detects the credit card type based on the number.
   *
   * @param string $number
   *   The credit card number.
   *
   * @return \Drupal\commerce_payment\CreditCardType|null
   *   The credit card type, or NULL if unknown.
   */
  public static function detectType($number) {
    if (!is_numeric($number)) {
      return FALSE;
    }
    $types = self::getTypes();
    foreach ($types as $type) {
      foreach ($type->getNumberPrefixes() as $prefix) {
        if (self::matchPrefix($number, $prefix)) {
          return $type;
        }
      }
    }

    return FALSE;
  }

We document NULL, but return FALSE.
PHP saves us, but this is still unclean. The general D8 pattern is NULL, not FALSE, so the docs are correct, not the code.

Comments

bojanz created an issue. See original summary.

  • bojanz committed e83802a on 8.x-2.x
    Issue #2931920 by bojanz: CreditCard::detectType() mismatch between...
bojanz’s picture

Status: Active » Fixed

Fixed.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.