<?php
/**
 * Gigaom_Sniffs_CodeAnalysis_RedirectAndDieSniff
 *
 * Throw an error if error loggins functions are in use
 *
 * @category  PHP
 * @package   PHP_CodeSniffer
 * @author    Matthew Batchelder <borkweb@gmail.com>
 * @copyright 2014 Gigaom
 * @license   https://github.com/GigaOM/gigaom-codesniffer/blob/master/licence.txt BSD Licence
 * @version   Release: 1.4.0
 * @link      http://pear.php.net/package/PHP_CodeSniffer
 */
class Gigaom_Sniffs_CodeAnalysis_RedirectAndDieSniff implements PHP_CodeSniffer_Sniff
{
	/**
	 * A list of tokenizers this sniff supports.
	 *
	 * @var array
	 */
	public $supportedTokenizers = array(
		'PHP',
	);

	/**
	 * Returns an array of tokens this test wants to listen for.
	 *
	 * @return array
	 */
	public function register()
	{
		return array(
			T_STRING,
		);
	}//end register

	/**
	 * Processes this test, when one of its tokens is encountered.
	 *
	 * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
	 * @param int                  $stackPtr  The position of the current token in
	 *                                        the stack passed in $tokens.
	 *
	 * @return void
	 */
	public function process( PHP_CodeSniffer_File $phpcsFile, $stackPtr )
	{
		$tokens = $phpcsFile->getTokens();
		$token = $tokens[ $stackPtr ];
		$function = strtolower( $token['content'] );

		$ignore = array(
			T_DOUBLE_COLON,
			T_OBJECT_OPERATOR,
			T_FUNCTION,
			T_CONST,
		);

		$prevToken = $phpcsFile->findPrevious( T_WHITESPACE, ( $stackPtr - 1 ), null, true );

		if ( in_array( $tokens[ $prevToken ]['code'], $ignore ) === true )
		{
			// Not a call to a PHP function.
			return;
		}//end if

		if ( ! in_array( $function, array( 'wp_redirect', 'wp_safe_redirect' ) ) )
		{
			return;
		}//end if

		$semicolon = $phpcsFile->findNext( T_SEMICOLON, $stackPtr );
		$next = $tokens[ $phpcsFile->findNext( T_WHITESPACE, $semicolon + 1, NULL, TRUE ) ];

		if ( T_EXIT == $next['code'] )
		{
			return;
		}//end if

		$data = array( $function );
		$type  = 'Error';
		$error = "die must follow {$function}";
		$phpcsFile->addError( $error, $stackPtr, $type, $data );
	}//end process
}//end class

Add a sniff for requiring die/exit after wp(_safe)_redirect
Add a sniff for requiring die/exit after wp(_safe)_redirect
