Problem/Motivation

Recent pipelines have been failing due to new deprecations on dev-main, and phpstan is set to hard fail.

------ --------------------------------------------------------------
Line src/Batch/UpdateNarfProcessor.php
------ --------------------------------------------------------------
270 Call to deprecated function update_calculate_project_data():
in drupal:11.5.0 and is removed from drupal:13.0.0. Use
\Drupal::service(UpdateManagerInterface::class)
->calculateProjectData($available) instead.
🪪 function.deprecated
------ --------------------------------------------------------------
[ERROR] Found 1 error

Method "Drupal\Core\Form\FormInterface::getFormId()" might add "string" as a native return type declaration in the future. Do the same in implementation "Drupal\update_narf\Form\UpdateNarfSettingsForm" now to avoid errors or add an explicit @return annotation to suppress this message.

Method "Drupal\Core\Form\FormInterface::buildForm()" might add "array" as a native return type declaration in the future. Do the same in implementation "Drupal\update_narf\Form\UpdateNarfSettingsForm" now to avoid errors or add an explicit @return annotation to suppress this message.

Method "Drupal\Core\Form\ConfigFormBase::getEditableConfigNames()" might add "array" as a native return type declaration in the future. Do the same in child class "Drupal\update_narf\Form\UpdateNarfSettingsForm" now to avoid errors or add an explicit @return annotation to suppress this message.

Method "Drupal\Core\Form\FormInterface::getFormId()" might add "string" as a native return type declaration in the future. Do the same in implementation "Drupal\update_narf\Form\AdvancedExpungeForm" now to avoid errors or add an explicit @return annotation to suppress this message.

Method "Drupal\Core\Form\FormInterface::buildForm()" might add "array" as a native return type declaration in the future. Do the same in implementation "Drupal\update_narf\Form\AdvancedExpungeForm" now to avoid errors or add an explicit @return annotation to suppress this message.

Steps to reproduce

  1. https://git.drupalcode.org/project/update_narf/-/pipelines/1032303

Proposed resolution

  • Use deprecation helper for BC call < 11.5
  • Add return type hints to methods specified
  • perhaps special handling needed for ConfigFormBase::getEditableConfigNames() if this is included via trait

Remaining tasks

User interface changes

n/a

API changes

n/a

Data model changes

n/a

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

elc created an issue. See original summary.

  • elc committed 5eea119b on 1.0.x
    task: #3635524 Fix deprecation warnings causing pipeline failures.
    
    By:...
elc’s picture

Assigned: elc » Unassigned
Status: Active » Fixed

PHPStan is unable to find functions included my ModuleHandlerInterface::loadInclude while inside a closure.

    DeprecationHelper::backwardsCompatibleCall(
      currentVersion: \Drupal::VERSION,
      deprecatedVersion: '11.5.0',
      currentCallable: fn() => $this->updateManager
        ->calculateProjectData($available),
      deprecatedCallable: function () use ($available) {

        $this->moduleHandler->loadInclude('update', 'inc', 'update.compare');
        // PHPStan gets lost here inside the closure and does not correctly
        // process the loadInclude and thus fails to locate the function.
        // @phpstan-ignore function.notFound
        update_calculate_project_data($available);
      },
    );

With that, and the return type hints, pipelines are now passing again.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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