WordPress/Sniffs/WP/I18nSniff.php
public function process_matched_token( $stack_ptr, $group_name, $matched_content ) {

		$func_open_paren_token = $this->phpcsFile->findNext( Tokens::$emptyTokens, ( $stack_ptr + 1 ), null, true );
		if ( false === $func_open_paren_token
			|| \T_OPEN_PARENTHESIS !== $this->tokens[ $func_open_paren_token ]['code']
			|| ! isset( $this->tokens[ $func_open_paren_token ]['parenthesis_closer'] )
		) {
			// Live coding, parse error or not a function call.
			return;
		}

		if ( 'typos' === $group_name && '_' === $matched_content ) {
			$this->phpcsFile->addError( 'Found single-underscore "_()" function when double-underscore expected.', $stack_ptr, 'SingleUnderscoreGetTextFunction' );
			return;
		}

		if ( \in_array( $matched_content, array( 'translate', 'translate_with_gettext_context' ), true ) ) {
			$this->phpcsFile->addWarning( 'Use of the "%s()" function is reserved for low-level API usage.', $stack_ptr, 'LowLevelTranslationFunction', array( $matched_content ) );
		}

		$arguments_tokens = array();
		$argument_tokens  = array();
		$tokens           = $this->tokens;

		// Look at arguments.
		for ( $i = ( $func_open_paren_token + 1 ); $i < $this->tokens[ $func_open_paren_token ]['parenthesis_closer']; $i++ ) {
			$this_token                = $this->tokens[ $i ];
			$this_token['token_index'] = $i;
			if ( isset( Tokens::$emptyTokens[ $this_token['code'] ] ) ) {
				continue;
			}
			if ( \T_COMMA === $this_token['code'] ) {
				$arguments_tokens[] = $argument_tokens;
				$argument_tokens    = array();
				continue;
			}

			// Merge consecutive single or double quoted strings (when they span multiple lines).
			if ( isset( Tokens::$textStringTokens[ $this_token['code'] ] ) ) {
				for ( $j = ( $i + 1 ); $j < $this->tokens[ $func_open_paren_token ]['parenthesis_closer']; $j++ ) {
					if ( $this_token['code'] === $this->tokens[ $j ]['code'] ) {
						$this_token['content'] .= $this->tokens[ $j ]['content'];
						$i                      = $j;
					} else {
						break;
					}
				}
			}
			$argument_tokens[] = $this_token;

			// Include everything up to and including the parenthesis_closer if this token has one.
			if ( ! empty( $this_token['parenthesis_closer'] ) ) {
				for ( $j = ( $i + 1 ); $j <= $this_token['parenthesis_closer']; $j++ ) {
					$tokens[ $j ]['token_index'] = $j;
					$argument_tokens[]           = $tokens[ $j ];
				}
				$i = $this_token['parenthesis_closer'];
			}
		}

		if ( ! empty( $argument_tokens ) ) {
			$arguments_tokens[] = $argument_tokens;
		}
		unset( $argument_tokens );

		$argument_assertions = array();
		if ( 'simple' === $this->i18n_functions[ $matched_content ] ) {
			$argument_assertions[] = array(
				'arg_name' => 'text',
				'tokens'   => array_shift( $arguments_tokens ),
			);
			$argument_assertions[] = array(
				'arg_name' => 'domain',
				'tokens'   => array_shift( $arguments_tokens ),
			);
		} elseif ( 'context' === $this->i18n_functions[ $matched_content ] ) {
			$argument_assertions[] = array(
				'arg_name' => 'text',
				'tokens'   => array_shift( $arguments_tokens ),
			);
			$argument_assertions[] = array(
				'arg_name' => 'context',
				'tokens'   => array_shift( $arguments_tokens ),
			);
			$argument_assertions[] = array(
				'arg_name' => 'domain',
				'tokens'   => array_shift( $arguments_tokens ),
			);
		} elseif ( 'number' === $this->i18n_functions[ $matched_content ] ) {
			$argument_assertions[] = array(
				'arg_name' => 'single',
				'tokens'   => array_shift( $arguments_tokens ),
			);
			$argument_assertions[] = array(
				'arg_name' => 'plural',
				'tokens'   => array_shift( $arguments_tokens ),
			);
			array_shift( $arguments_tokens );
			$argument_assertions[] = array(
				'arg_name' => 'domain',
				'tokens'   => array_shift( $arguments_tokens ),
			);
		} elseif ( 'number_context' === $this->i18n_functions[ $matched_content ] ) {
			$argument_assertions[] = array(
				'arg_name' => 'single',
				'tokens'   => array_shift( $arguments_tokens ),
			);
			$argument_assertions[] = array(
				'arg_name' => 'plural',
				'tokens'   => array_shift( $arguments_tokens ),
			);
			array_shift( $arguments_tokens );
			$argument_assertions[] = array(
				'arg_name' => 'context',
				'tokens'   => array_shift( $arguments_tokens ),
			);
			$argument_assertions[] = array(
				'arg_name' => 'domain',
				'tokens'   => array_shift( $arguments_tokens ),
			);
		} elseif ( 'noopnumber' === $this->i18n_functions[ $matched_content ] ) {
			$argument_assertions[] = array(
				'arg_name' => 'single',
				'tokens'   => array_shift( $arguments_tokens ),
			);
			$argument_assertions[] = array(
				'arg_name' => 'plural',
				'tokens'   => array_shift( $arguments_tokens ),
			);
			$argument_assertions[] = array(
				'arg_name' => 'domain',
				'tokens'   => array_shift( $arguments_tokens ),
			);
		} elseif ( 'noopnumber_context' === $this->i18n_functions[ $matched_content ] ) {
			$argument_assertions[] = array(
				'arg_name' => 'single',
				'tokens'   => array_shift( $arguments_tokens ),
			);
			$argument_assertions[] = array(
				'arg_name' => 'plural',
				'tokens'   => array_shift( $arguments_tokens ),
			);
			$argument_assertions[] = array(
				'arg_name' => 'context',
				'tokens'   => array_shift( $arguments_tokens ),
			);
			$argument_assertions[] = array(
				'arg_name' => 'domain',
				'tokens'   => array_shift( $arguments_tokens ),
			);
		}

		if ( ! empty( $arguments_tokens ) ) {
			$this->phpcsFile->addError( 'Too many arguments for function "%s".', $func_open_paren_token, 'TooManyFunctionArgs', array( $matched_content ) );
		}

		foreach ( $argument_assertions as $argument_assertion_context ) {
			if ( empty( $argument_assertion_context['tokens'][0] ) ) {
				$argument_assertion_context['stack_ptr'] = $func_open_paren_token;
			} else {
				$argument_assertion_context['stack_ptr'] = $argument_assertion_context['tokens'][0]['token_index'];
			}
			$this->check_argument_tokens( $argument_assertion_context );
		}

		// For _n*() calls, compare the singular and plural strings.
		if ( false !== strpos( $this->i18n_functions[ $matched_content ], 'number' ) ) {
			$single_context = $argument_assertions[0];
			$plural_context = $argument_assertions[1];

			$this->compare_single_and_plural_arguments( $stack_ptr, $single_context, $plural_context );
		}

		if ( true === $this->check_translator_comments ) {
			$this->check_for_translator_comment( $stack_ptr, $argument_assertions );
		}
	}
public function process_matched_token( $stack_ptr, $group_name, $matched_content ) {

		$func_open_paren_token = $this->phpcsFile->findNext( Tokens::$emptyTokens, ( $stack_ptr + 1 ), null, true );
		if ( false === $func_open_paren_token
			|| \T_OPEN_PARENTHESIS !== $this->tokens[ $func_open_paren_token ]['code']
			|| ! isset( $this->tokens[ $func_open_paren_token ]['parenthesis_closer'] )
		) {
			// Live coding, parse error or not a function call.
			return;
		}

		if ( 'typos' === $group_name && '_' === $matched_content ) {
			$this->phpcsFile->addError( 'Found single-underscore "_()" function when double-underscore expected.', $stack_ptr, 'SingleUnderscoreGetTextFunction' );
			return;
		}

		if ( \in_array( $matched_content, array( 'translate', 'translate_with_gettext_context' ), true ) ) {
			$this->phpcsFile->addWarning( 'Use of the "%s()" function is reserved for low-level API usage.', $stack_ptr, 'LowLevelTranslationFunction', array( $matched_content ) );
		}

		$arguments_tokens = array();
		$argument_tokens  = array();
		$tokens           = $this->tokens;

		// Look at arguments.
		for ( $i = ( $func_open_paren_token + 1 ); $i < $this->tokens[ $func_open_paren_token ]['parenthesis_closer']; $i++ ) {
			$this_token                = $this->tokens[ $i ];
			$this_token['token_index'] = $i;
			if ( isset( Tokens::$emptyTokens[ $this_token['code'] ] ) ) {
				continue;
			}
			if ( \T_COMMA === $this_token['code'] ) {
				$arguments_tokens[] = $argument_tokens;
				$argument_tokens    = array();
				continue;
			}

			// Merge consecutive single or double quoted strings (when they span multiple lines).
			if ( isset( Tokens::$textStringTokens[ $this_token['code'] ] ) ) {
				for ( $j = ( $i + 1 ); $j < $this->tokens[ $func_open_paren_token ]['parenthesis_closer']; $j++ ) {
					if ( $this_token['code'] === $this->tokens[ $j ]['code'] ) {
						$this_token['content'] .= $this->tokens[ $j ]['content'];
						$i                      = $j;
					} else {
						break;
					}
				}
			}
			$argument_tokens[] = $this_token;

			// Include everything up to and including the parenthesis_closer if this token has one.
			if ( ! empty( $this_token['parenthesis_closer'] ) ) {
				for ( $j = ( $i + 1 ); $j <= $this_token['parenthesis_closer']; $j++ ) {
					$tokens[ $j ]['token_index'] = $j;
					$argument_tokens[]           = $tokens[ $j ];
				}
				$i = $this_token['parenthesis_closer'];
			}
		}

		if ( ! empty( $argument_tokens ) ) {
			$arguments_tokens[] = $argument_tokens;
		}
		unset( $argument_tokens );

		$argument_assertions = array();
		if ( 'simple' === $this->i18n_functions[ $matched_content ] ) {
			$argument_assertions[] = array(
				'arg_name' => 'text',
				'tokens'   => array_shift( $arguments_tokens ),
			);
			$argument_assertions[] = array(
				'arg_name' => 'domain',
				'tokens'   => array_shift( $arguments_tokens ),
			);
		} elseif ( 'context' === $this->i18n_functions[ $matched_content ] ) {
			$argument_assertions[] = array(
				'arg_name' => 'text',
				'tokens'   => array_shift( $arguments_tokens ),
			);
			$argument_assertions[] = array(
				'arg_name' => 'context',
				'tokens'   => array_shift( $arguments_tokens ),
			);
			$argument_assertions[] = array(
				'arg_name' => 'domain',
				'tokens'   => array_shift( $arguments_tokens ),
			);
		} elseif ( 'number' === $this->i18n_functions[ $matched_content ] ) {
			$argument_assertions[] = array(
				'arg_name' => 'single',
				'tokens'   => array_shift( $arguments_tokens ),
			);
			$argument_assertions[] = array(
				'arg_name' => 'plural',
				'tokens'   => array_shift( $arguments_tokens ),
			);
			array_shift( $arguments_tokens );
			$argument_assertions[] = array(
				'arg_name' => 'domain',
				'tokens'   => array_shift( $arguments_tokens ),
			);
		} elseif ( 'number_context' === $this->i18n_functions[ $matched_content ] ) {
			$argument_assertions[] = array(
				'arg_name' => 'single',
				'tokens'   => array_shift( $arguments_tokens ),
			);
			$argument_assertions[] = array(
				'arg_name' => 'plural',
				'tokens'   => array_shift( $arguments_tokens ),
			);
			array_shift( $arguments_tokens );
			$argument_assertions[] = array(
				'arg_name' => 'context',
				'tokens'   => array_shift( $arguments_tokens ),
			);
			$argument_assertions[] = array(
				'arg_name' => 'domain',
				'tokens'   => array_shift( $arguments_tokens ),
			);
		} elseif ( 'noopnumber' === $this->i18n_functions[ $matched_content ] ) {
			$argument_assertions[] = array(
				'arg_name' => 'single',
				'tokens'   => array_shift( $arguments_tokens ),
			);
			$argument_assertions[] = array(
				'arg_name' => 'plural',
				'tokens'   => array_shift( $arguments_tokens ),
			);
			$argument_assertions[] = array(
				'arg_name' => 'domain',
				'tokens'   => array_shift( $arguments_tokens ),
			);
		} elseif ( 'noopnumber_context' === $this->i18n_functions[ $matched_content ] ) {
			$argument_assertions[] = array(
				'arg_name' => 'single',
				'tokens'   => array_shift( $arguments_tokens ),
			);
			$argument_assertions[] = array(
				'arg_name' => 'plural',
				'tokens'   => array_shift( $arguments_tokens ),
			);
			$argument_assertions[] = array(
				'arg_name' => 'context',
				'tokens'   => array_shift( $arguments_tokens ),
			);
			$argument_assertions[] = array(
				'arg_name' => 'domain',
				'tokens'   => array_shift( $arguments_tokens ),
			);
		}

		if ( ! empty( $arguments_tokens ) ) {
			$this->phpcsFile->addError( 'Too many arguments for function "%s".', $func_open_paren_token, 'TooManyFunctionArgs', array( $matched_content ) );
		}

		foreach ( $argument_assertions as $argument_assertion_context ) {
			if ( empty( $argument_assertion_context['tokens'][0] ) ) {
				$argument_assertion_context['stack_ptr'] = $func_open_paren_token;
			} else {
				$argument_assertion_context['stack_ptr'] = $argument_assertion_context['tokens'][0]['token_index'];
			}
			$this->check_argument_tokens( $argument_assertion_context );
		}

		// For _n*() calls, compare the singular and plural strings.
		if ( false !== strpos( $this->i18n_functions[ $matched_content ], 'number' ) ) {
			$single_context = $argument_assertions[0];
			$plural_context = $argument_assertions[1];

			$this->compare_single_and_plural_arguments( $stack_ptr, $single_context, $plural_context );
		}

		if ( true === $this->check_translator_comments ) {
			$this->check_for_translator_comment( $stack_ptr, $argument_assertions );
		}
	}
Process a matched token.

@since 1.0.0 Logic split off from the `process_token()` method.

@param int    $stack_ptr       The position of the current token in the stack.
@param string $group_name      The name of the group which was matched.
@param string $matched_content The token content (function name) which was matched.

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