false, 'FoundPropertyForDeprecatedSniff' => false, ); /** * Groups of variables to restrict. * * Example: groups => array( * 'wpdb' => array( * 'type' => 'error' | 'warning', * 'message' => 'Dont use this one please!', * 'variables' => array( '$val', '$var' ), * 'object_vars' => array( '$foo->bar', .. ), * 'array_members' => array( '$foo['bar']', .. ), * ) * ) * * @return array */ public function getGroups() { return array( // @link https://lobby.vip.wordpress.com/wordpress-com-documentation/code-review-what-we-look-for/#wp_users-and-user_meta 'user_meta' => array( 'type' => 'error', 'message' => 'Usage of users/usermeta tables is highly discouraged in VIP context, For storing user additional user metadata, you should look at User Attributes.', 'object_vars' => array( '$wpdb->users', '$wpdb->usermeta', ), ), // @link https://lobby.vip.wordpress.com/wordpress-com-documentation/code-review-what-we-look-for/#caching-constraints 'cache_constraints' => array( 'type' => 'warning', 'message' => 'Due to using Batcache, server side based client related logic will not work, use JS instead.', 'variables' => array( '$_COOKIE', ), 'array_members' => array( '$_SERVER[\'HTTP_USER_AGENT\']', '$_SERVER[\'REMOTE_ADDR\']', ), ), ); } /** * Process the token and handle the deprecation notices. * * @since 1.0.0 Added to allow for throwing the deprecation notices. * * @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.VIP.RestrictedVariables" sniff has been deprecated. Please update your custom ruleset.', 0, 'DeprecatedSniff' ); } if ( ! empty( $this->exclude ) && false === $this->thrown['FoundPropertyForDeprecatedSniff'] ) { $this->thrown['FoundPropertyForDeprecatedSniff'] = $this->phpcsFile->addWarning( 'The "WordPress.VIP.RestrictedVariables" sniff has been deprecated. Please update your custom ruleset.', 0, 'FoundPropertyForDeprecatedSniff' ); } return parent::process_token( $stackPtr ); } }