Problem/Motivation

PHP 8.4 has deprecated implicit nullable types.

Steps to reproduce

Use in a PHP 8.4 environment

Deprecated: Drupal\oembed_providers\OEmbed\ProviderRepositoryDecorator::__construct(): Implicitly marking parameter $key_value_factory as nullable is deprecated, the explicit nullable type must be used instead in /var/www/html/web/modules/contrib/oembed_providers/src/OEmbed/ProviderRepositoryDecorator.php on line 116

Deprecated: Drupal\oembed_providers\OEmbed\ProviderRepositoryDecorator::__construct(): Implicitly marking parameter $logger_factory as nullable is deprecated, the explicit nullable type must be used instead in /var/www/html/web/modules/contrib/oembed_providers/src/OEmbed/ProviderRepositoryDecorator.php on line 116

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

pcambra created an issue. See original summary.

pcambra’s picture

Issue summary: View changes
pcambra’s picture

Status: Active » Needs review
steinmb’s picture

Status: Needs review » Reviewed & tested by the community

Lets try a keep PHP 8.4 happy, RTBC

chris burge’s picture

Title: Nullable types must be explicit » Make $key_value_factory and $logger_factory parameters required in ProviderRepositoryDecorator::__contstruct()
Version: 2.2.2 » 2.x-dev
Status: Reviewed & tested by the community » Needs work

A number of tests are failing with the following output:

Test code or tested code printed unexpected output:
Deprecated: Optional parameter $key_value_factory declared before required parameter $module_handler is implicitly treated as a required parameter in /builds/issue/oembed_providers-3528538/src/OEmbed/ProviderRepositoryDecorator.php on line 116
Deprecated: Optional parameter $logger_factory declared before required parameter $module_handler is implicitly treated as a required parameter in /builds/issue/oembed_providers-3528538/src/OEmbed/ProviderRepositoryDecorator.php on line 116

The ProviderRepository constructor change in D10, and the $key_value_factory and $logger_factory parameters are no longer optional: __construct() in D10 vs __construct() in D9.

D9 is no longer supported by this module, so all we need to do is make the parameters required:

  public function __construct(ProviderRepositoryInterface $decorated, EntityTypeManagerInterface $entity_type_manager, ClientInterface $http_client, ConfigFactoryInterface $config_factory, TimeInterface $time, $key_value_factory, LoggerChannelFactoryInterface $logger_factory, ModuleHandlerInterface $module_handler, $max_age = 604800) {

liuyuanchao made their first commit to this issue’s fork.

liuyuanchao’s picture

Status: Needs work » Needs review

> D9 is no longer supported by this module, so all we need to do is make the parameters required:

You are right, I change the parameters not nullable, the phpunit passed.
And by the way, fix phpcs and phpstan warnings.
Please review.

chris burge’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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

pcambra’s picture

Could we please get a release for this? thanks!

chris burge’s picture

Released in 2.2.3.

pcambra’s picture

Thank you!!