Skip to content

Replace deprecated WordPress.WP.TimezoneChange sniff #452

@kevinfodness

Description

@kevinfodness

Bug Description

With the release of wpcs v2.2.0 on 2019-11-11, the WordPress.WP.TimezoneChange sniff was deprecated in favor of WordPress.DateTime.RestrictedFunctions. Recommend switching to the new sniff name.

Minimal Code Snippet

Create a test file called test.php with the following contents:

<?php
$date = date( DATE_W3C );

Then run the WordPressVIPMinimum standard against that file:

phpcs --standard=WordPressVIPMinimum test.php

Or using the WordPress-VIP-Go standard:

phpcs --standard=WordPress-VIP-Go test.php

Error Code

FILE: /Users/kevinfodness/Desktop/vipwpcs/test.php
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 1 | WARNING | The "WordPress.WP.TimezoneChange" sniff has been deprecated. Use the "WordPress.DateTime.RestrictedFunctions" sniff instead. Please update your custom ruleset.
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Environment

Use php -v and composer show to get versions.

Question Answer
PHP version 7.3.0
PHP_CodeSniffer version 3.5.2
VIPCS version 2.0.0

Additional Context (optional)

The difficulty with a fix here is that the new standard was introduced and the old standard was deprecated in the same release, so if users have an older version of wpcs but the latest version of vipcs then they would get a sniff not found error. However, we (and I assume others) rely on clean output of phpcs in Travis in order to pass a PR, and the deprecation warning is causing all of our automated CI checks to fail, so it would be nice if it was fixed in the upstream.

Tested Against master branch?

  • I have verified the issue still exists in the master branch of VIPCS.

Additionally, I tested against the develop branch and checked for open issues or PRs relating to this issue and didn't find any.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions