WordPress-Coding-Standards icon indicating copy to clipboard operation
WordPress-Coding-Standards copied to clipboard

Feature request: sniff to check that deprecation is properly handled

Open jrfnl opened this issue 8 years ago • 3 comments

In https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/pull/979#issuecomment-310235942 :

Just thinking.... maybe we should create a sniff that checks for calls to any of the deprecated....() functions and ensures that there is a @deprecated tag and visa versa ?

Some ideas for what the sniff should check:

  • That a _deprecated_...() function is called whenever a @deprecated tag is encountered.
  • That a @deprecated tag is used whenever a _deprecated_...() function is called.
  • That the correct flavour of _deprecated_...() function is called.
  • That the version nrs in the tag and the function parameter are in line.
  • That the alternative listed in the tag and the function parameter are in line.
  • That __METHOD__ is used for methods, __FUNCTION__ for functions.

I propose the sniff be added to core based on all the issues related to this we've identified in PR #979.

jrfnl avatar Jun 21 '17 23:06 jrfnl

Related #663

jrfnl avatar Oct 24 '17 03:10 jrfnl

I've been working on this and got quite a lot ready already, but would like to wait to pull this until WPCS 3.0.0 for two reasons:

  • The sniffs could benefit from the PHPCSUtils utility functions and the associated code re-organisation within WPCS once PHPCSUtils gets implemented.
  • I've been testing the sniffs on WP Core and have found quite a lot of inconsistencies in Core. I'll be opening issues with patches to get all of that fixed and pulling the sniffs a little later will allow for those patches to be committed before that time.

Status overview:

  • [x] FileDeprecation sniff
  • [x] HookDeprecation sniff
  • [x] PHP4Constructors Deprecation sniff
  • [ ] FunctionDeprecation sniff
  • [ ] FunctionArgumentDeprecation sniff
  • [x] VersionNrs sniff for _doing_it_wrong() as per #663 (the version nr checks for the _deprecated_...() functions will be contained within the above mentioned sniffs.

jrfnl avatar Oct 08 '19 07:10 jrfnl

Related WP Core tickets:

  • https://core.trac.wordpress.org/ticket/41121 (deprecated functions)
  • https://core.trac.wordpress.org/ticket/48252 (deprecated constructors)
  • https://core.trac.wordpress.org/ticket/48254 (deprecated files)
  • https://core.trac.wordpress.org/ticket/48255 (deprecated hooks)

Also related:

  • https://core.trac.wordpress.org/ticket/48251

jrfnl avatar Oct 08 '19 15:10 jrfnl