WordPress/Sniffs/WP/CapitalPDangitSniff.php
public function process_token( $stackPtr ) {

		if ( $this->has_whitelist_comment( 'spelling', $stackPtr ) ) {
			return;
		}

		/*
		 * Ignore tokens within an array definition as this is a false positive in 80% of all cases.
		 *
		 * The return values skip to the end of the array.
		 * This prevents the sniff "hanging" on very long configuration arrays.
		 */
		if ( \T_OPEN_SHORT_ARRAY === $this->tokens[ $stackPtr ]['code'] && isset( $this->tokens[ $stackPtr ]['bracket_closer'] ) ) {
			return $this->tokens[ $stackPtr ]['bracket_closer'];
		} elseif ( \T_ARRAY === $this->tokens[ $stackPtr ]['code'] && isset( $this->tokens[ $stackPtr ]['parenthesis_closer'] ) ) {
			return $this->tokens[ $stackPtr ]['parenthesis_closer'];
		}

		/*
		 * Deal with misspellings in class/interface/trait names.
		 * These are not auto-fixable, but need the attention of a developer.
		 */
		if ( isset( Tokens::$ooScopeTokens[ $this->tokens[ $stackPtr ]['code'] ] ) ) {
			$classname = $this->phpcsFile->getDeclarationName( $stackPtr );
			if ( empty( $classname ) ) {
				return;
			}

			if ( preg_match_all( self::WP_CLASSNAME_REGEX, $classname, $matches, \PREG_PATTERN_ORDER ) > 0 ) {
				$mispelled = $this->retrieve_misspellings( $matches[1] );

				if ( ! empty( $mispelled ) ) {
					$this->phpcsFile->addWarning(
						'Please spell "WordPress" correctly. Found: "%s" as part of the class/interface/trait name.',
						$stackPtr,
						'MisspelledClassName',
						array( implode( ', ', $mispelled ) )
					);
				}
			}

			return;
		}

		/*
		 * Deal with misspellings in text strings and documentation.
		 */

		// Ignore content of docblock @link tags.
		if ( \T_DOC_COMMENT_STRING === $this->tokens[ $stackPtr ]['code']
			|| \T_DOC_COMMENT === $this->tokens[ $stackPtr ]['code']
		) {

			$comment_start = $this->phpcsFile->findPrevious( \T_DOC_COMMENT_OPEN_TAG, ( $stackPtr - 1 ) );
			if ( false !== $comment_start ) {
				$comment_tag = $this->phpcsFile->findPrevious( \T_DOC_COMMENT_TAG, ( $stackPtr - 1 ), $comment_start );
				if ( false !== $comment_tag && '@link' === $this->tokens[ $comment_tag ]['content'] ) {
					// @link tag, so ignore.
					return;
				}
			}
		}

		// Ignore any text strings which are array keys `$var['key']` as this is a false positive in 80% of all cases.
		if ( \T_CONSTANT_ENCAPSED_STRING === $this->tokens[ $stackPtr ]['code'] ) {
			$prevToken = $this->phpcsFile->findPrevious( Tokens::$emptyTokens, ( $stackPtr - 1 ), null, true, null, true );
			if ( false !== $prevToken && \T_OPEN_SQUARE_BRACKET === $this->tokens[ $prevToken ]['code'] ) {
				$nextToken = $this->phpcsFile->findNext( Tokens::$emptyTokens, ( $stackPtr + 1 ), null, true, null, true );
				if ( false !== $nextToken && \T_CLOSE_SQUARE_BRACKET === $this->tokens[ $nextToken ]['code'] ) {
					return;
				}
			}
		}

		$content = $this->tokens[ $stackPtr ]['content'];

		if ( preg_match_all( self::WP_REGEX, $content, $matches, ( \PREG_PATTERN_ORDER | \PREG_OFFSET_CAPTURE ) ) > 0 ) {
			/*
			 * Prevent some typical false positives.
			 */
			if ( isset( $this->text_and_comment_tokens[ $this->tokens[ $stackPtr ]['code'] ] ) ) {
				$offset = 0;
				foreach ( $matches[1] as $key => $match_data ) {
					$next_offset = ( $match_data[1] + \strlen( $match_data[0] ) );

					// Prevent matches on part of a URL.
					if ( preg_match( '`http[s]?://[^\s<>\'"()]*' . preg_quote( $match_data[0], '`' ) . '`', $content, $discard, 0, $offset ) === 1 ) {
						unset( $matches[1][ $key ] );
					} elseif ( preg_match( '`[a-z]+=(["\'])' . preg_quote( $match_data[0], '`' ) . '\1`', $content, $discard, 0, $offset ) === 1 ) {
						// Prevent matches on html attributes like: `value="wordpress"`.
						unset( $matches[1][ $key ] );
					} elseif ( preg_match( '`\\\\\'' . preg_quote( $match_data[0], '`' ) . '\\\\\'`', $content, $discard, 0, $offset ) === 1 ) {
						// Prevent matches on xpath queries and such: `\'wordpress\'`.
						unset( $matches[1][ $key ] );
					} elseif ( preg_match( '`(?:\?|&amp;|&)[a-z0-9_]+=' . preg_quote( $match_data[0], '`' ) . '(?:&|$)`', $content, $discard, 0, $offset ) === 1 ) {
						// Prevent matches on url query strings: `?something=wordpress`.
						unset( $matches[1][ $key ] );
					}

					$offset = $next_offset;
				}

				if ( empty( $matches[1] ) ) {
					return;
				}
			}

			$mispelled = $this->retrieve_misspellings( $matches[1] );

			if ( empty( $mispelled ) ) {
				return;
			}

			$fix = $this->phpcsFile->addFixableWarning(
				'Please spell "WordPress" correctly. Found %s misspelling(s): %s',
				$stackPtr,
				'Misspelled',
				array(
					\count( $mispelled ),
					implode( ', ', $mispelled ),
				)
			);

			if ( true === $fix ) {
				// Apply fixes based on offset to ensure we don't replace false positives.
				$replacement = $content;
				foreach ( $matches[1] as $match ) {
					$replacement = substr_replace( $replacement, 'WordPress', $match[1], \strlen( $match[0] ) );
				}

				$this->phpcsFile->fixer->replaceToken( $stackPtr, $replacement );
			}
		}
	}
public function process_token( $stackPtr ) {

		if ( $this->has_whitelist_comment( 'spelling', $stackPtr ) ) {
			return;
		}

		/*
		 * Ignore tokens within an array definition as this is a false positive in 80% of all cases.
		 *
		 * The return values skip to the end of the array.
		 * This prevents the sniff "hanging" on very long configuration arrays.
		 */
		if ( \T_OPEN_SHORT_ARRAY === $this->tokens[ $stackPtr ]['code'] && isset( $this->tokens[ $stackPtr ]['bracket_closer'] ) ) {
			return $this->tokens[ $stackPtr ]['bracket_closer'];
		} elseif ( \T_ARRAY === $this->tokens[ $stackPtr ]['code'] && isset( $this->tokens[ $stackPtr ]['parenthesis_closer'] ) ) {
			return $this->tokens[ $stackPtr ]['parenthesis_closer'];
		}

		/*
		 * Deal with misspellings in class/interface/trait names.
		 * These are not auto-fixable, but need the attention of a developer.
		 */
		if ( isset( Tokens::$ooScopeTokens[ $this->tokens[ $stackPtr ]['code'] ] ) ) {
			$classname = $this->phpcsFile->getDeclarationName( $stackPtr );
			if ( empty( $classname ) ) {
				return;
			}

			if ( preg_match_all( self::WP_CLASSNAME_REGEX, $classname, $matches, \PREG_PATTERN_ORDER ) > 0 ) {
				$mispelled = $this->retrieve_misspellings( $matches[1] );

				if ( ! empty( $mispelled ) ) {
					$this->phpcsFile->addWarning(
						'Please spell "WordPress" correctly. Found: "%s" as part of the class/interface/trait name.',
						$stackPtr,
						'MisspelledClassName',
						array( implode( ', ', $mispelled ) )
					);
				}
			}

			return;
		}

		/*
		 * Deal with misspellings in text strings and documentation.
		 */

		// Ignore content of docblock @link tags.
		if ( \T_DOC_COMMENT_STRING === $this->tokens[ $stackPtr ]['code']
			|| \T_DOC_COMMENT === $this->tokens[ $stackPtr ]['code']
		) {

			$comment_start = $this->phpcsFile->findPrevious( \T_DOC_COMMENT_OPEN_TAG, ( $stackPtr - 1 ) );
			if ( false !== $comment_start ) {
				$comment_tag = $this->phpcsFile->findPrevious( \T_DOC_COMMENT_TAG, ( $stackPtr - 1 ), $comment_start );
				if ( false !== $comment_tag && '@link' === $this->tokens[ $comment_tag ]['content'] ) {
					// @link tag, so ignore.
					return;
				}
			}
		}

		// Ignore any text strings which are array keys `$var['key']` as this is a false positive in 80% of all cases.
		if ( \T_CONSTANT_ENCAPSED_STRING === $this->tokens[ $stackPtr ]['code'] ) {
			$prevToken = $this->phpcsFile->findPrevious( Tokens::$emptyTokens, ( $stackPtr - 1 ), null, true, null, true );
			if ( false !== $prevToken && \T_OPEN_SQUARE_BRACKET === $this->tokens[ $prevToken ]['code'] ) {
				$nextToken = $this->phpcsFile->findNext( Tokens::$emptyTokens, ( $stackPtr + 1 ), null, true, null, true );
				if ( false !== $nextToken && \T_CLOSE_SQUARE_BRACKET === $this->tokens[ $nextToken ]['code'] ) {
					return;
				}
			}
		}

		$content = $this->tokens[ $stackPtr ]['content'];

		if ( preg_match_all( self::WP_REGEX, $content, $matches, ( \PREG_PATTERN_ORDER | \PREG_OFFSET_CAPTURE ) ) > 0 ) {
			/*
			 * Prevent some typical false positives.
			 */
			if ( isset( $this->text_and_comment_tokens[ $this->tokens[ $stackPtr ]['code'] ] ) ) {
				$offset = 0;
				foreach ( $matches[1] as $key => $match_data ) {
					$next_offset = ( $match_data[1] + \strlen( $match_data[0] ) );

					// Prevent matches on part of a URL.
					if ( preg_match( '`http[s]?://[^\s<>\'"()]*' . preg_quote( $match_data[0], '`' ) . '`', $content, $discard, 0, $offset ) === 1 ) {
						unset( $matches[1][ $key ] );
					} elseif ( preg_match( '`[a-z]+=(["\'])' . preg_quote( $match_data[0], '`' ) . '\1`', $content, $discard, 0, $offset ) === 1 ) {
						// Prevent matches on html attributes like: `value="wordpress"`.
						unset( $matches[1][ $key ] );
					} elseif ( preg_match( '`\\\\\'' . preg_quote( $match_data[0], '`' ) . '\\\\\'`', $content, $discard, 0, $offset ) === 1 ) {
						// Prevent matches on xpath queries and such: `\'wordpress\'`.
						unset( $matches[1][ $key ] );
					} elseif ( preg_match( '`(?:\?|&amp;|&)[a-z0-9_]+=' . preg_quote( $match_data[0], '`' ) . '(?:&|$)`', $content, $discard, 0, $offset ) === 1 ) {
						// Prevent matches on url query strings: `?something=wordpress`.
						unset( $matches[1][ $key ] );
					}

					$offset = $next_offset;
				}

				if ( empty( $matches[1] ) ) {
					return;
				}
			}

			$mispelled = $this->retrieve_misspellings( $matches[1] );

			if ( empty( $mispelled ) ) {
				return;
			}

			$fix = $this->phpcsFile->addFixableWarning(
				'Please spell "WordPress" correctly. Found %s misspelling(s): %s',
				$stackPtr,
				'Misspelled',
				array(
					\count( $mispelled ),
					implode( ', ', $mispelled ),
				)
			);

			if ( true === $fix ) {
				// Apply fixes based on offset to ensure we don't replace false positives.
				$replacement = $content;
				foreach ( $matches[1] as $match ) {
					$replacement = substr_replace( $replacement, 'WordPress', $match[1], \strlen( $match[0] ) );
				}

				$this->phpcsFile->fixer->replaceToken( $stackPtr, $replacement );
			}
		}
	}
Processes this test, when one of its tokens is encountered.

@since 0.12.0

@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.