mirror of
https://github.com/10h30/genesis-simple-sidebars.git
synced 2026-07-18 05:53:26 +09:00
Introducing coding standards validation.
This commit is contained in:
committed by
Nathan Rice
parent
6e40c921ab
commit
fd504d41ac
+73
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
/**
|
||||
* WordPress Coding Standard.
|
||||
*
|
||||
* @package WPCS\WordPressCodingStandards
|
||||
* @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards
|
||||
* @license https://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
|
||||
namespace WordPress\Sniffs\Functions;
|
||||
|
||||
use WordPress\AbstractFunctionRestrictionsSniff;
|
||||
|
||||
/**
|
||||
* Restricts the usage of extract().
|
||||
*
|
||||
* @link https://make.wordpress.org/core/handbook/best-practices/coding-standards/php/#dont-extract
|
||||
*
|
||||
* @package WPCS\WordPressCodingStandards
|
||||
*
|
||||
* @since 0.10.0 Previously this check was contained within WordPress_Sniffs_VIP_RestrictedFunctionsSniff.
|
||||
* @since 0.13.0 Class name changed: this class is now namespaced.
|
||||
*
|
||||
* @deprecated 1.0.0 This sniff has been moved to the `PHP` category.
|
||||
* This file remains for now to prevent BC breaks.
|
||||
*/
|
||||
class DontExtractSniff extends \WordPress\Sniffs\PHP\DontExtractSniff {
|
||||
|
||||
/**
|
||||
* Keep track of whether the warnings have been thrown to prevent
|
||||
* the messages being thrown for every token triggering the sniff.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $thrown = array(
|
||||
'DeprecatedSniff' => false,
|
||||
'FoundPropertyForDeprecatedSniff' => false,
|
||||
);
|
||||
|
||||
/**
|
||||
* Don't use.
|
||||
*
|
||||
* @deprecated 1.0.0
|
||||
*
|
||||
* @param int $stackPtr The position of the current token in the stack.
|
||||
*
|
||||
* @return void|int
|
||||
*/
|
||||
public function process_token( $stackPtr ) {
|
||||
if ( false === $this->thrown['DeprecatedSniff'] ) {
|
||||
$this->thrown['DeprecatedSniff'] = $this->phpcsFile->addWarning(
|
||||
'The "WordPress.Functions.DontExtract" sniff has been renamed to "WordPress.PHP.DontExtract". Please update your custom ruleset.',
|
||||
0,
|
||||
'DeprecatedSniff'
|
||||
);
|
||||
}
|
||||
|
||||
if ( ! empty( $this->exclude )
|
||||
&& false === $this->thrown['FoundPropertyForDeprecatedSniff']
|
||||
) {
|
||||
$this->thrown['FoundPropertyForDeprecatedSniff'] = $this->phpcsFile->addWarning(
|
||||
'The "WordPress.Functions.DontExtract" sniff has been renamed to "WordPress.PHP.DontExtract". Please update your custom ruleset.',
|
||||
0,
|
||||
'FoundPropertyForDeprecatedSniff'
|
||||
);
|
||||
}
|
||||
|
||||
return parent::process_token( $stackPtr );
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user