WordPress-Coding-Standards/Sniffs/VIP/TimezoneChangeSniff.php
2013-10-20 16:17:59 +02:00

35 lines
1.1 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
/**
* WordPress_Sniffs_VIP_TimezoneChangeSniff.
*
* Disallow the changing of timezone
*
* @category PHP
* @package PHP_CodeSniffer
* @author Shady Sharaf <shady@x-team.com>
* @see http://vip.wordpress.com/documentation/use-current_time-not-date_default_timezone_set/
*/
class WordPress_Sniffs_VIP_TimezoneChangeSniff extends Generic_Sniffs_PHP_ForbiddenFunctionsSniff
{
/**
* A list of forbidden functions with their alternatives.
*
* The value is NULL if no alternative exists. IE, the
* function should just not be used.
*
* @var array(string => string|null)
*/
protected $forbiddenFunctions = array(
'date_default_timezone_set' => null,
);
protected function addError( $phpcsFile, $stackPtr, $function, $pattern = null )
{
$error = 'Using date_default_timezone_set() and similar isnt allowed, instead use WP internal timezone support.';
$phpcsFile->addError( $error, $stackPtr );
}//end addError()
}//end class