mirror of
git://develop.git.wordpress.org/
synced 2025-07-11 18:56:28 +02:00
This renames the private `_next_token` method to `next_visitable_token`. It also removes irrelevant assertions from the unit test. Follow-up to [59285]. Props dmsnell, jonsurrell, westonruter. See #62269. git-svn-id: https://develop.svn.wordpress.org/trunk@59364 602fd350-edb4-49c9-b593-d223f7449a82
36 lines
730 B
PHP
36 lines
730 B
PHP
<?php
|
|
|
|
class Token_Counting_HTML_Processor extends WP_HTML_Processor {
|
|
|
|
/**
|
|
* List of tokens that have already been seen.
|
|
*
|
|
* @var array<string, int>
|
|
*/
|
|
public $token_seen_count = array();
|
|
|
|
/**
|
|
* Gets next token.
|
|
*
|
|
* @return bool Whether next token was matched.
|
|
*/
|
|
public function next_token(): bool {
|
|
$result = parent::next_token();
|
|
|
|
if ( $this->get_token_type() === '#tag' ) {
|
|
$token_name = ( $this->is_tag_closer() ? '-' : '+' ) . $this->get_tag();
|
|
} else {
|
|
$token_name = $this->get_token_name();
|
|
}
|
|
|
|
if ( ! isset( $this->token_seen_count[ $token_name ] ) ) {
|
|
$this->token_seen_count[ $token_name ] = 1;
|
|
} else {
|
|
++$this->token_seen_count[ $token_name ];
|
|
}
|
|
|
|
return $result;
|
|
}
|
|
|
|
}
|