Should define LoggerChannelInstance type for $logger, not LoggerChannel

Created on 1 September 2025, about 1 month ago

Problem/Motivation

Using D11 with commerce_stripe 2.1.0 and Monolog 3.0.5, when i want to create a payment gateway from interface, i have the error :

TypeError: Cannot assign Drupal\monolog\Logger\LoggerInterfacesAdapter to property Drupal\commerce_stripe\Plugin\Commerce\PaymentGateway\StripePaymentElement::$logger of type Drupal\Core\Logger\LoggerChannel in Drupal\commerce_stripe\Plugin\Commerce\PaymentGateway\StripePaymentElement::create() (line 178 of modules/contrib/commerce_stripe/src/Plugin/Commerce/PaymentGateway/StripePaymentElement.php). 

In StripePaymentElement.php, $logger type should be LoggerChannelInterface, not LoggerChannel, so other modules like Monolog can handle logs.

Steps to reproduce

Install monolog, install commerce_stripe and go to /admin/commerce/config/payment-gateways/add to add a stripe payment.

Proposed resolution

Replace

  /**
   * The logging channel.
   *
   * @var \Drupal\Core\Logger\LoggerChannel
   */
  protected LoggerChannel $logger;

by


  /**
   * The logging channel.
   *
   * @var \Drupal\Core\Logger\LoggerChannelInterface
   */
  protected LoggerChannelInterface $logger;
🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

🇫🇷France goz

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024