Fatal error due to typed properties in GraphApiTransportFactory

Created on 25 April 2025, 2 months ago

Problem/Motivation

When using symfony_mailer_lite_microsoft with Symfony Mailer 6.3+, PHP throws a fatal error:

PHP Fatal error:  Type of Drupal\symfony_mailer_lite_microsoft\Transport\GraphApiTransportFactory::$dispatcher must not be defined (as in class Symfony\Component\Mailer\Transport\AbstractTransportFactory)

This happens because the $dispatcher property is declared with a type in the child class but not in the parent class (AbstractTransportFactory) — which causes an inheritance conflict depending on the PHP and Symfony version.

This happens because the $dispatcher, $client and $property properties are declared with a type in the child class but not in the parent class (AbstractTransportFactory) — which causes an inheritance conflict depending on the PHP and Symfony version.

Steps to reproduce

  1. Install symfony_mailer_lite and symfony_mailer_lite_microsoft
  2. Use Symfony Mailer 6.3 or newer
  3. Load any page, or run drush cr
  4. See fatal error

Proposed resolution

Remove the typed property declaration (EventDispatcherInterface) from $dispatcher in GraphApiTransportFactory.

The constructor already type-hints the dispatcher and sets the property, so PHP's type inference is sufficient — and this change maintains compatibility with newer Symfony versions.

Remaining tasks

  • Confirm patch works on PHP 8.1+ and Symfony Mailer 6.3+
  • Confirm compatibility with previous module versions
  • Add test coverage if applicable (optional for contribs like this)

User interface changes

None.

API changes

None.

Data model changes

None.

🐛 Bug report
Status

Needs review

Version

1.0

Component

Code

Created by

🇨🇦Canada gwvoigt London, ON 🇨🇦

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