Adjust deprecated coding standard in tests

Created on 14 February 2022, about 3 years ago
Updated 4 March 2023, about 2 years ago

Problem/Motivation

Currently the standard for @deprecated code blocks โ†’ is the following:

@deprecated: Indicating deprecated functionality

The @deprecated tag is placed in a documentation block to indicate that a function, method, or class has been deprecated and should not be used, but has not yet been removed.

Syntax

@deprecated in %deprecation-version% and is removed from %removal-version%. %extra-info%.
@see %cr-link%

In โœจ Use PHPStan for deprecation checking Active we propose to use this tag to flag tests of deprecations. That way PHPStan does not flag those as using deprecated code. This would currently, however, violate the standards unless we always add the extra info to the tags, causing unnecessary overhead.

Proposed resolution

See #3263109-21: Use PHPStan for deprecation checking โ†’ : We propose to modify the standards by adding an exception for test classes/methods that would allow them to be tagged with a @deprecated tag without any further description/information, if the tag is merely present because the test tests deprecated code. (Actual deprecations, for instance in a test base class, would of course still need proper descriptions and change records.)

Remaining tasks

  1. Discuss
  2. Draft a phrasing for the proposed new text
  3. Decide
๐Ÿ“Œ Task
Status

Active

Component

Coding Standards

Created by

๐Ÿ‡ง๐Ÿ‡ชBelgium mallezie Loenhout

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • ๐Ÿ‡ฆ๐Ÿ‡นAustria drunken monkey Vienna, Austria

    Sorry, I have trouble understanding the IS. In essence, you just propose that @deprecated tags can be stand-alone (that is, with no further info/description) inside test code โ€“ correct? I tried to update the IS according to my understanding of it โ€“ please correct or further clarify as necessary.

    Regarding the suggestion, we should definitely note that this exception would not cover โ€œproperโ€ deprecations in test code, e.g., when some part of a test base class gets deprecated.

    Furthermore, it might avoid confusion if, instead of an empty tag, weโ€™d prescribe a short standard explanation for the presence of this tag. E.g., something like this:

    /**
     * @deprecated (This tag is only present for technical reasons. See
     *   https://www.drupal.org/node/3263109.)
     */
  • Status changed to Postponed: needs info about 2 months ago
  • ๐Ÿ‡ณ๐Ÿ‡ฟNew Zealand quietone

    โœจ Use PHPStan for deprecation checking Active is closed as outdated.

    Is this still needed?

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly mondrake ๐Ÿ‡ฎ๐Ÿ‡น

    I do not think so. BTW PHPUnit 10 has its own #[IgnoreDeprecations] attribute for this purpose.

    See for example https://git.drupalcode.org/project/drupal/-/blob/11.x/core/tests/Drupal/...

  • ๐Ÿ‡ณ๐Ÿ‡ฟNew Zealand quietone

    @mondrake, thank you.

    Closing as outdated.

Production build 0.71.5 2024