WPThemeReview/Sniffs/Plugins/CorrectTGMPAVersionSniff.php
public function process_token( $stackPtr ) {

		$has_class_function = $this->phpcsFile->findNext( array( T_CLASS, T_FUNCTION ), ( $stackPtr + 1 ) );
		if ( false === $has_class_function ) {
			// No class, function or constant declaration found, definitely not TGMPA file.
			// Skip this file from further checks.
			return ( $this->phpcsFile->numTokens + 1 );
		}

		$is_tgmpa = false;

		// First check based on filename.
		$file_name = basename( $this->phpcsFile->getFileName() );
		if ( false !== $file_name ) {
			$file_name = strtolower( $file_name );
			if ( strpos( $file_name, 'class-tgm-plugin-activation.php' ) !== false ) {
				$is_tgmpa = true;
			} elseif ( defined( 'PHP_CODESNIFFER_IN_TESTS' ) && preg_match( '`class-tgm-plugin-activation[^.]+\.inc`', $file_name, $discard ) > 0 ) {
				$is_tgmpa = true;
			}
		}

		/*
		 * Otherwise, check whether any of the TGMPA classes or function names are encountered.
		 *
		 * Will detect TGMPA, even when:
		 * - the class and function prefix has been changed
		 * - the file has been split up into several files
		 * - the file is combined with other code
		 */
		if ( false === $is_tgmpa ) {
			while ( false !== $has_class_function ) {
				$name = $this->phpcsFile->getDeclarationName( $has_class_function );
				if ( ! empty( $name ) ) {
					if ( isset( $this->tgmpa_classes_functions[ $name ] ) ) {
						$is_tgmpa = true;
						break;
					} elseif ( strpos( $name, '_Plugin_Activation' ) !== false ) {
						// This may be TGMPA with renamed prefixes, so look for typical class comment.
						$prev = $this->phpcsFile->findPrevious( T_WHITESPACE, ( $has_class_function - 1 ), null, true );
						while ( false !== $prev && isset( Tokens::$commentTokens[ $this->tokens[ $prev ]['code'] ] ) ) {
							if ( ( T_COMMENT === $this->tokens[ $prev ]['code']
								|| T_DOC_COMMENT_STRING === $this->tokens[ $prev ]['code'] )
								&& ( strpos( $this->tokens[ $prev ]['content'], 'Automatic plugin installation and activation library' ) !== false
								|| strpos( $this->tokens[ $prev ]['content'], 'Automatic plugin installation and activation class' ) !== false )
							) {
								$is_tgmpa = true;
								break;
							}

							$prev = $this->phpcsFile->findPrevious( T_WHITESPACE, ( $prev - 1 ), null, true );
						}
					}
				}

				$start = ( $has_class_function + 1 );
				if ( isset( $this->tokens[ $has_class_function ]['scope_condition'], $this->tokens[ $stackPtr ]['scope_closer'] )
					&& $this->tokens[ $has_class_function ]['scope_condition'] === $has_class_function
				) {
					// Skip past anything within the class or function.
					$start = $this->tokens[ $stackPtr ]['scope_closer'];
				}

				$has_class_function = $this->phpcsFile->findNext( array( T_CLASS, T_FUNCTION ), $start );
			}
		}

		// If we're still not 100% sure this is TGMPA, exclude the file from further checks.
		if ( false === $is_tgmpa ) {
			return ( $this->phpcsFile->numTokens + 1 );
		}

		// Check whether the correct version of TGMPA is being used.
		$version = $this->uses_latest_version();

		// Check for typical manual search & replace error.
		$this->detect_manual_editing( $version );

		// No need to check the same file again.
		return ( $this->phpcsFile->numTokens + 1 );
	}
public function process_token( $stackPtr ) {

		$has_class_function = $this->phpcsFile->findNext( array( T_CLASS, T_FUNCTION ), ( $stackPtr + 1 ) );
		if ( false === $has_class_function ) {
			// No class, function or constant declaration found, definitely not TGMPA file.
			// Skip this file from further checks.
			return ( $this->phpcsFile->numTokens + 1 );
		}

		$is_tgmpa = false;

		// First check based on filename.
		$file_name = basename( $this->phpcsFile->getFileName() );
		if ( false !== $file_name ) {
			$file_name = strtolower( $file_name );
			if ( strpos( $file_name, 'class-tgm-plugin-activation.php' ) !== false ) {
				$is_tgmpa = true;
			} elseif ( defined( 'PHP_CODESNIFFER_IN_TESTS' ) && preg_match( '`class-tgm-plugin-activation[^.]+\.inc`', $file_name, $discard ) > 0 ) {
				$is_tgmpa = true;
			}
		}

		/*
		 * Otherwise, check whether any of the TGMPA classes or function names are encountered.
		 *
		 * Will detect TGMPA, even when:
		 * - the class and function prefix has been changed
		 * - the file has been split up into several files
		 * - the file is combined with other code
		 */
		if ( false === $is_tgmpa ) {
			while ( false !== $has_class_function ) {
				$name = $this->phpcsFile->getDeclarationName( $has_class_function );
				if ( ! empty( $name ) ) {
					if ( isset( $this->tgmpa_classes_functions[ $name ] ) ) {
						$is_tgmpa = true;
						break;
					} elseif ( strpos( $name, '_Plugin_Activation' ) !== false ) {
						// This may be TGMPA with renamed prefixes, so look for typical class comment.
						$prev = $this->phpcsFile->findPrevious( T_WHITESPACE, ( $has_class_function - 1 ), null, true );
						while ( false !== $prev && isset( Tokens::$commentTokens[ $this->tokens[ $prev ]['code'] ] ) ) {
							if ( ( T_COMMENT === $this->tokens[ $prev ]['code']
								|| T_DOC_COMMENT_STRING === $this->tokens[ $prev ]['code'] )
								&& ( strpos( $this->tokens[ $prev ]['content'], 'Automatic plugin installation and activation library' ) !== false
								|| strpos( $this->tokens[ $prev ]['content'], 'Automatic plugin installation and activation class' ) !== false )
							) {
								$is_tgmpa = true;
								break;
							}

							$prev = $this->phpcsFile->findPrevious( T_WHITESPACE, ( $prev - 1 ), null, true );
						}
					}
				}

				$start = ( $has_class_function + 1 );
				if ( isset( $this->tokens[ $has_class_function ]['scope_condition'], $this->tokens[ $stackPtr ]['scope_closer'] )
					&& $this->tokens[ $has_class_function ]['scope_condition'] === $has_class_function
				) {
					// Skip past anything within the class or function.
					$start = $this->tokens[ $stackPtr ]['scope_closer'];
				}

				$has_class_function = $this->phpcsFile->findNext( array( T_CLASS, T_FUNCTION ), $start );
			}
		}

		// If we're still not 100% sure this is TGMPA, exclude the file from further checks.
		if ( false === $is_tgmpa ) {
			return ( $this->phpcsFile->numTokens + 1 );
		}

		// Check whether the correct version of TGMPA is being used.
		$version = $this->uses_latest_version();

		// Check for typical manual search & replace error.
		$this->detect_manual_editing( $version );

		// No need to check the same file again.
		return ( $this->phpcsFile->numTokens + 1 );
	}
Processes this test, when one of its tokens is encountered.

@param int $stackPtr The position of the current token in the stack.

@return int|void Integer stack pointer to skip forward or void to continue
normal file processing.