false, 'FoundPropertyForDeprecatedSniff' => false, ); /** * Groups of functions to restrict. * * Example: groups => array( * 'lambda' => array( * 'type' => 'error' | 'warning', * 'message' => 'Use anonymous functions instead please!', * 'functions' => array( 'file_get_contents', 'create_function' ), * ) * ) * * @return array */ public function getGroups() { $groups = array( 'file_ops' => array( 'type' => 'error', 'message' => 'Filesystem writes are forbidden, you should not be using %s()', 'functions' => array( 'delete', 'file_put_contents', 'flock', 'fputcsv', 'fputs', 'fwrite', 'ftruncate', 'is_writable', 'is_writeable', 'link', 'rename', 'symlink', 'tempnam', 'touch', 'unlink', ), ), 'directory' => array( 'type' => 'error', 'message' => 'Filesystem writes are forbidden, you should not be using %s()', 'functions' => array( 'mkdir', 'rmdir', ), ), 'chmod' => array( 'type' => 'error', 'message' => 'Filesystem writes are forbidden, you should not be using %s()', 'functions' => array( 'chgrp', 'chown', 'chmod', 'lchgrp', 'lchown', ), ), ); /* * Maintain old behaviour - allow for changing the error type from the ruleset * using the `error` property. */ if ( false === $this->error ) { foreach ( $groups as $group_name => $details ) { $groups[ $group_name ]['type'] = 'warning'; } } return $groups; } /** * 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.FileSystemWritesDisallow" sniff has been deprecated. Please update your custom ruleset.', 0, 'DeprecatedSniff' ); } if ( ( ! empty( $this->exclude ) || true !== $this->error ) && false === $this->thrown['FoundPropertyForDeprecatedSniff'] ) { $this->thrown['FoundPropertyForDeprecatedSniff'] = $this->phpcsFile->addWarning( 'The "WordPress.VIP.FileSystemWritesDisallow" sniff has been deprecated. Please update your custom ruleset.', 0, 'FoundPropertyForDeprecatedSniff' ); } return parent::process_token( $stackPtr ); } }