Problem/Motivation

As discovered by mglaman/phpstan-drupal 1.2.0 (see #3383279: Bump mglaman/phpstan-drupal to latest to make daily "updated deps" QA run pass again), we are using some deprecated functionality throughout Drupal core.

This issue is for dealing with code calling deprecated "things" in classes used for testing that don't extend \PHPUnit\Framework\TestCase.

Until now this code wasn't throwing any deprecation warnings, but after #3383279: Bump mglaman/phpstan-drupal to latest to make daily "updated deps" QA run pass again landed, they do.

So far, this issue has identified and tries to fix the following PHPStan failures:

 ------ -------------------------------------------------------------------------------------------------------------------------------------------------------------
  Line   ExternalCommandRequirementTest.php
 ------ -------------------------------------------------------------------------------------------------------------------------------------------------------------
  136    Usage of deprecated trait Drupal\BuildTests\Framework\ExternalCommandRequirementsTrait in class Drupal\BuildTests\Framework\Tests\UsesCommandRequirements:
         in drupal:10.2.0 and is removed from drupal:11.0.0. Use
         Drupal\\TestTools\\Extension\\RequiresComposerTrait instead.
  149    Usage of deprecated trait Drupal\BuildTests\Framework\ExternalCommandRequirementsTrait in class Drupal\BuildTests\Framework\Tests\ClassRequiresAvailable:
         in drupal:10.2.0 and is removed from drupal:11.0.0. Use
         Drupal\\TestTools\\Extension\\RequiresComposerTrait instead.
  162    Usage of deprecated trait Drupal\BuildTests\Framework\ExternalCommandRequirementsTrait in class Drupal\BuildTests\Framework\Tests\ClassRequiresUnavailable:
         in drupal:10.2.0 and is removed from drupal:11.0.0. Use
         Drupal\\TestTools\\Extension\\RequiresComposerTrait instead.
  168    Usage of deprecated trait Drupal\BuildTests\Framework\ExternalCommandRequirementsTrait in class Drupal\BuildTests\Framework\Tests\MethodRequires:
         in drupal:10.2.0 and is removed from drupal:11.0.0. Use
         Drupal\\TestTools\\Extension\\RequiresComposerTrait instead.
 ------ -------------------------------------------------------------------------------------------------------------------------------------------------------------
 ------ --------------------------------------------------------------------------------- 
  Line   core/modules/system/tests/modules/deprecation_test/src/DeprecatedController.php  
 ------ --------------------------------------------------------------------------------- 
  18     Call to deprecated function deprecation_test_function():                         
         in drupal:8.4.0 and is removed from drupal:9.0.0. This is                        
           the deprecation message for deprecated_test_function().                        
 ------ --------------------------------------------------------------------------------- 

Steps to reproduce

Proposed resolution

Add @group legacy to the code, which makes mglaman/phpstan-drupal aware this is using deprecated code and won't emit a deprecation warning.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Issue fork drupal-3383414

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

Spokje created an issue. See original summary.

spokje’s picture

Issue summary: View changes
spokje’s picture

Assigned: Unassigned » spokje
spokje’s picture

Issue summary: View changes
spokje’s picture

Title: [PP-1] Add @group legacy to non-TestCase-extending code calling deprecated things » Add @group legacy to non-TestCase-extending code calling deprecated things
Status: Postponed » Active
spokje’s picture

Issue summary: View changes

spokje’s picture

Title: Add @group legacy to non-TestCase-extending code calling deprecated things » Add @group legacy to non-TestCase-extending code for testing calling deprecated things
spokje’s picture

Issue summary: View changes
spokje’s picture

Assigned: spokje » Unassigned
Status: Active » Needs review
smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Looking at the changes and think this is good.

mondrake’s picture

Status: Reviewed & tested by the community » Needs review

Mmmm... @group legacy as an annotation should only be applied to test methods or to classes containing test methods IMHO. Here it seems it's misused. Possibly also a sign of a bug upstream, @mglaman?

mglaman’s picture

core/modules/system/tests/modules/deprecation_test/src/DeprecatedController.php

Does this class or its methods have the deprecated tag in them?

kim.pepper’s picture

Came across the same issue in #3375423: Deprecate file_managed_file_save_upload(), file_save_upload() and _file_save_upload_from_form() and replace with a service where a test module was used to test a deprecated function. I added @phpstan-ignore-next-line to get around it.

smustgrave’s picture

Status: Needs review » Needs work

Per @mglaman in slack

Use @deprecated

If code is intended to call deprecated code, that should itself be tagged as deprecated

Moving to NW for that.

spokje’s picture

Right, so adding "just" @deprecated doesn't play nice with our (rightfully) rather strict PHPCS rule on that.

TBH: This looks like far too much effort. I would go with just a @phpstan-ignore-next-line (like #14) in DeprecatedController, ExternalCommandRequirementTest will be gone in 11.0.0 anyway.

quietone’s picture

Status: Needs work » Closed (outdated)