WPThemeReview/Sniffs/Plugins/CorrectTGMPAVersionSniff.php
protected function detect_manual_editing( $version ) {
		// Skip this check for TGMPA versions which didn't have the `tgmpa()` function or
		// didn't have the `function_exists()` wrapper.
		if ( false === $version || true === version_compare( $version, '2.2.0', '<' ) ) {
			return;
		}

		$checkTokens = array(
			// This is what we're looking for.
			T_FUNCTION         => true,
			// These are just here to be able to skip as much as we can.
			T_CLASS            => true,
			T_ARRAY            => true,
			T_OPEN_SHORT_ARRAY => true,
		);

		for ( $ptr = 0; $ptr < $this->phpcsFile->numTokens; $ptr++ ) {
			if ( ! isset( $checkTokens[ $this->tokens[ $ptr ]['code'] ] ) ) {
				continue;
			}

			// Skip as much as we can.
			if ( T_CLASS === $this->tokens[ $ptr ]['code'] && isset( $this->tokens[ $ptr ]['scope_closer'] ) ) {
				$ptr = $this->tokens[ $ptr ]['scope_closer'];
				continue;
			} elseif ( T_OPEN_SHORT_ARRAY === $this->tokens[ $ptr ]['code'] && isset( $this->tokens[ $ptr ]['bracket_closer'] ) ) {
				$ptr = $this->tokens[ $ptr ]['bracket_closer'];
				continue;
			} elseif ( T_ARRAY === $this->tokens[ $ptr ]['code'] && isset( $this->tokens[ $ptr ]['parenthesis_closer'] ) ) {
				$ptr = $this->tokens[ $ptr ]['parenthesis_closer'];
				continue;
			}

			// Detect whether this is the `tgmpa()` function declaration.
			if ( T_FUNCTION === $this->tokens[ $ptr ]['code'] ) {
				$function_name = $this->phpcsFile->getDeclarationName( $ptr );
				if ( 'tgmpa' !== $function_name ) {
					if ( isset( $this->tokens[ $ptr ]['scope_closer'] ) ) {
						// Skip the rest of the function.
						$ptr = $this->tokens[ $ptr ]['scope_closer'];
					}
					continue;
				}

				// Ok, found the tgmpa function declaration. Now let's check for the typical
				// manual text-domain replacement error.
				$function_exists = $this->phpcsFile->findPrevious( T_STRING, ( $ptr - 1 ), null, false, 'function_exists' );
				$param           = false;
				if ( false !== $function_exists ) {
					$param = $this->get_function_call_parameter( $function_exists, 1 );
					$param = $this->strip_quotes( $param['raw'] );
				}

				if ( false === $function_exists || 'tgmpa' !== $param ) {
					$this->phpcsFile->recordMetric( 0, 'Manual editing detected', 'yes' );
					$this->phpcsFile->addError(
						'Manual editing of the TGM Plugin Activation file detected. Your edit will cause fatal errors for end-users. Download an official copy using the Custom TGMPA Generator. http://tgmpluginactivation.com/download/',
						0,
						'ManualEditDetected',
						array(),
						9
					);
				} else {
					$this->phpcsFile->recordMetric( 0, 'Manual editing detected', 'no' );
				}
				break;
			}
		}
	}
protected function detect_manual_editing( $version ) {
		// Skip this check for TGMPA versions which didn't have the `tgmpa()` function or
		// didn't have the `function_exists()` wrapper.
		if ( false === $version || true === version_compare( $version, '2.2.0', '<' ) ) {
			return;
		}

		$checkTokens = array(
			// This is what we're looking for.
			T_FUNCTION         => true,
			// These are just here to be able to skip as much as we can.
			T_CLASS            => true,
			T_ARRAY            => true,
			T_OPEN_SHORT_ARRAY => true,
		);

		for ( $ptr = 0; $ptr < $this->phpcsFile->numTokens; $ptr++ ) {
			if ( ! isset( $checkTokens[ $this->tokens[ $ptr ]['code'] ] ) ) {
				continue;
			}

			// Skip as much as we can.
			if ( T_CLASS === $this->tokens[ $ptr ]['code'] && isset( $this->tokens[ $ptr ]['scope_closer'] ) ) {
				$ptr = $this->tokens[ $ptr ]['scope_closer'];
				continue;
			} elseif ( T_OPEN_SHORT_ARRAY === $this->tokens[ $ptr ]['code'] && isset( $this->tokens[ $ptr ]['bracket_closer'] ) ) {
				$ptr = $this->tokens[ $ptr ]['bracket_closer'];
				continue;
			} elseif ( T_ARRAY === $this->tokens[ $ptr ]['code'] && isset( $this->tokens[ $ptr ]['parenthesis_closer'] ) ) {
				$ptr = $this->tokens[ $ptr ]['parenthesis_closer'];
				continue;
			}

			// Detect whether this is the `tgmpa()` function declaration.
			if ( T_FUNCTION === $this->tokens[ $ptr ]['code'] ) {
				$function_name = $this->phpcsFile->getDeclarationName( $ptr );
				if ( 'tgmpa' !== $function_name ) {
					if ( isset( $this->tokens[ $ptr ]['scope_closer'] ) ) {
						// Skip the rest of the function.
						$ptr = $this->tokens[ $ptr ]['scope_closer'];
					}
					continue;
				}

				// Ok, found the tgmpa function declaration. Now let's check for the typical
				// manual text-domain replacement error.
				$function_exists = $this->phpcsFile->findPrevious( T_STRING, ( $ptr - 1 ), null, false, 'function_exists' );
				$param           = false;
				if ( false !== $function_exists ) {
					$param = $this->get_function_call_parameter( $function_exists, 1 );
					$param = $this->strip_quotes( $param['raw'] );
				}

				if ( false === $function_exists || 'tgmpa' !== $param ) {
					$this->phpcsFile->recordMetric( 0, 'Manual editing detected', 'yes' );
					$this->phpcsFile->addError(
						'Manual editing of the TGM Plugin Activation file detected. Your edit will cause fatal errors for end-users. Download an official copy using the Custom TGMPA Generator. http://tgmpluginactivation.com/download/',
						0,
						'ManualEditDetected',
						array(),
						9
					);
				} else {
					$this->phpcsFile->recordMetric( 0, 'Manual editing detected', 'no' );
				}
				break;
			}
		}
	}
Check against a typical manual search & replace error often encountered.

In that case the `tgmpa` in `if ( ! function_exists( 'tgmpa' ) )` has been replaced
with the theme slug causing fatal errors when an end-user also uses a plugin using TGMPA.

@param string $version The version of TGMPA found.