(PHPStan) Add a deprecation warning for constructing a HttpFetcherResult without the file_system parameter

Created on 13 July 2024, 4 months ago

Problem/Motivation

The parameter $file_system in \Drupal\feeds\Result\HttpFetcherResult::__construct() is optional. To fix dependency injection in the future, we should make it required in the future. Deprecate that the parameter is optional.

\Drupal\Tests\feeds\Unit\Result\HttpFetcherResultTest::testUnserialize() looks like to be the only code in the Feeds code base that doesn't pass a value for the $file_system parameter, so that one would need to be updated.

Proposed resolution

Add a deprecation warning in \Drupal\feeds\Result\HttpFetcherResult::__construct() for if the $file_system parameter is not set. Write a change record.

Code:

if (!isset($file_system)) {
  @trigger_error('Calling ' . __METHOD__ . '() without the $file_system argument is deprecated in feeds:3.0.0-rc1 and will be required in feeds:4.0.0. See https://www.drupal.org/node/xxx', E_USER_DEPRECATED);
  $entity_type_manager = \Drupal::service('entity_type.manager');
}

'xxx' should be the node ID of the change record.

Remaining tasks

  • Draft a change record.
  • Trigger an error with a deprecation message when the parameter $file_system in \Drupal\feeds\Result\HttpFetcherResult::__construct() is not set.
  • Update \Drupal\Tests\feeds\Unit\Result\HttpFetcherResultTest::testUnserialize().
  • Commit.
  • Publish the change record.

User interface changes

None.

API changes

\Drupal\feeds\Result\HttpFetcherResult::__construct() will trigger an error with a deprecation message when the parameter $file_system is not set.

Data model changes

None.

📌 Task
Status

Active

Version

3.0

Component

Code

Created by

🇳🇱Netherlands megachriz

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

Comments & Activities

Production build 0.71.5 2024