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
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:
- 3383414-add-group-deprecated
changes, plain diff MR !6382
- 3383414-pp-1-add-group
changes, plain diff MR !4661
Comments
Comment #2
spokjeComment #3
spokjeComment #4
spokjeComment #5
spokjeComment #6
spokjeComment #8
spokjeComment #9
spokjeComment #10
spokjeComment #11
smustgrave commentedLooking at the changes and think this is good.
Comment #12
mondrakeMmmm...
@group legacyas 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?Comment #13
mglamancore/modules/system/tests/modules/deprecation_test/src/DeprecatedController.php
Does this class or its methods have the deprecated tag in them?
Comment #14
kim.pepperCame 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-lineto get around it.Comment #15
smustgrave commentedPer @mglaman in slack
Moving to NW for that.
Comment #20
spokjeRight, so adding "just"
@deprecateddoesn'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) inDeprecatedController,ExternalCommandRequirementTestwill be gone in 11.0.0 anyway.Comment #21
quietone commentedClosing as outdated. See #3425660: [11.x] Remove deprecated ExternalCommandRequirementsTrait