Skip to content

Commit c1094c3

Browse files
committed
Revert "Try using global namespace for special functions"
This reverts commit 06b0370. It seemed to have no impact on parsing, likely because no namespace is used.
1 parent 06b0370 commit c1094c3

2 files changed

Lines changed: 80 additions & 80 deletions

File tree

src/wp-includes/html-api/class-wp-html-processor.php

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ public static function create_fragment( $html, $context = '<body>', $encoding =
299299
return null;
300300
}
301301

302-
if ( ! \is_string( $html ) ) {
302+
if ( ! is_string( $html ) ) {
303303
_doing_it_wrong(
304304
__METHOD__,
305305
__( 'The HTML parameter must be a string.' ),
@@ -350,7 +350,7 @@ public static function create_full_parser( $html, $known_definite_encoding = 'UT
350350
if ( 'UTF-8' !== $known_definite_encoding ) {
351351
return null;
352352
}
353-
if ( ! \is_string( $html ) ) {
353+
if ( ! is_string( $html ) ) {
354354
_doing_it_wrong(
355355
__METHOD__,
356356
__( 'The HTML parameter must be a string.' ),
@@ -386,7 +386,7 @@ public function __construct( $html, $use_the_static_create_methods_instead = nul
386386
if ( self::CONSTRUCTOR_UNLOCK_CODE !== $use_the_static_create_methods_instead ) {
387387
_doing_it_wrong(
388388
__METHOD__,
389-
\sprintf(
389+
sprintf(
390390
/* translators: %s: WP_HTML_Processor::create_fragment(). */
391391
__( 'Call %s to create an HTML Processor instead of calling the constructor directly.' ),
392392
'<code>WP_HTML_Processor::create_fragment()</code>'
@@ -492,7 +492,7 @@ private function create_fragment_at_current_node( string $html ) {
492492
if ( 'html' === $namespace && self::is_void( $tag_name ) ) {
493493
_doing_it_wrong(
494494
__METHOD__,
495-
\sprintf(
495+
sprintf(
496496
// translators: %s: A tag name like INPUT or BR.
497497
__( 'The context element cannot be a void element, found "%s".' ),
498498
$tag_name
@@ -508,11 +508,11 @@ private function create_fragment_at_current_node( string $html ) {
508508
*/
509509
if (
510510
'html' === $namespace &&
511-
\in_array( $tag_name, array( 'IFRAME', 'NOEMBED', 'NOFRAMES', 'SCRIPT', 'STYLE', 'TEXTAREA', 'TITLE', 'XMP', 'PLAINTEXT' ), true )
511+
in_array( $tag_name, array( 'IFRAME', 'NOEMBED', 'NOFRAMES', 'SCRIPT', 'STYLE', 'TEXTAREA', 'TITLE', 'XMP', 'PLAINTEXT' ), true )
512512
) {
513513
_doing_it_wrong(
514514
__METHOD__,
515-
\sprintf(
515+
sprintf(
516516
// translators: %s: A tag name like IFRAME or TEXTAREA.
517517
__( 'The context element "%s" is not supported.' ),
518518
$tag_name
@@ -699,11 +699,11 @@ public function next_tag( $query = null ): bool {
699699
return false;
700700
}
701701

702-
if ( \is_string( $query ) ) {
702+
if ( is_string( $query ) ) {
703703
$query = array( 'breadcrumbs' => array( $query ) );
704704
}
705705

706-
if ( ! \is_array( $query ) ) {
706+
if ( ! is_array( $query ) ) {
707707
_doing_it_wrong(
708708
__METHOD__,
709709
__( 'Please pass a query array to this function.' ),
@@ -716,11 +716,11 @@ public function next_tag( $query = null ): bool {
716716
$query['tag_name'] = strtoupper( $query['tag_name'] );
717717
}
718718

719-
$needs_class = ( isset( $query['class_name'] ) && \is_string( $query['class_name'] ) )
719+
$needs_class = ( isset( $query['class_name'] ) && is_string( $query['class_name'] ) )
720720
? $query['class_name']
721721
: null;
722722

723-
if ( ! ( \array_key_exists( 'breadcrumbs', $query ) && \is_array( $query['breadcrumbs'] ) ) ) {
723+
if ( ! ( array_key_exists( 'breadcrumbs', $query ) && is_array( $query['breadcrumbs'] ) ) ) {
724724
while ( $this->next_token() ) {
725725
if ( '#tag' !== $this->get_token_type() ) {
726726
continue;
@@ -919,7 +919,7 @@ private function is_virtual(): bool {
919919
*/
920920
public function matches_breadcrumbs( $breadcrumbs ): bool {
921921
// Everything matches when there are zero constraints.
922-
if ( 0 === \count( $breadcrumbs ) ) {
922+
if ( 0 === count( $breadcrumbs ) ) {
923923
return true;
924924
}
925925

@@ -930,7 +930,7 @@ public function matches_breadcrumbs( $breadcrumbs ): bool {
930930
return false;
931931
}
932932

933-
for ( $i = \count( $this->breadcrumbs ) - 1; $i >= 0; $i-- ) {
933+
for ( $i = count( $this->breadcrumbs ) - 1; $i >= 0; $i-- ) {
934934
$node = $this->breadcrumbs[ $i ];
935935
$crumb = strtoupper( current( $breadcrumbs ) );
936936

@@ -982,7 +982,7 @@ public function expects_closer( ?WP_HTML_Token $node = null ): ?bool {
982982
// Void elements.
983983
( 'html' === $token_namespace && self::is_void( $token_name ) ) ||
984984
// Special atomic elements.
985-
( 'html' === $token_namespace && \in_array( $token_name, array( 'IFRAME', 'NOEMBED', 'NOFRAMES', 'SCRIPT', 'STYLE', 'TEXTAREA', 'TITLE', 'XMP' ), true ) ) ||
985+
( 'html' === $token_namespace && in_array( $token_name, array( 'IFRAME', 'NOEMBED', 'NOFRAMES', 'SCRIPT', 'STYLE', 'TEXTAREA', 'TITLE', 'XMP' ), true ) ) ||
986986
// Self-closing elements in foreign content.
987987
( 'html' !== $token_namespace && $token_has_self_closing )
988988
);
@@ -1067,7 +1067,7 @@ public function step( $node_to_process = self::PROCESS_NEXT_NODE ): bool {
10671067
(
10681068
'math' === $adjusted_current_node->integration_node_type &&
10691069
(
1070-
( $is_start_tag && ! \in_array( $token_name, array( 'MGLYPH', 'MALIGNMARK' ), true ) ) ||
1070+
( $is_start_tag && ! in_array( $token_name, array( 'MGLYPH', 'MALIGNMARK' ), true ) ) ||
10711071
'#text' === $token_name
10721072
)
10731073
) ||
@@ -1219,7 +1219,7 @@ public function get_breadcrumbs(): array {
12191219
* @return int Nesting-depth of current location in the document.
12201220
*/
12211221
public function get_current_depth(): int {
1222-
return \count( $this->breadcrumbs );
1222+
return count( $this->breadcrumbs );
12231223
}
12241224

12251225
/**
@@ -1418,7 +1418,7 @@ public function serialize_token(): string {
14181418
$html .= " {$this->get_qualified_attribute_name( $attribute_name )}";
14191419
$value = $this->get_attribute( $attribute_name );
14201420

1421-
if ( \is_string( $value ) ) {
1421+
if ( is_string( $value ) ) {
14221422
$html .= '="' . htmlspecialchars( $value, ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML5 ) . '"';
14231423
}
14241424

@@ -1458,7 +1458,7 @@ public function serialize_token(): string {
14581458
}
14591459

14601460
// Flush out self-contained elements.
1461-
if ( $in_html && \in_array( $tag_name, array( 'IFRAME', 'NOEMBED', 'NOFRAMES', 'SCRIPT', 'STYLE', 'TEXTAREA', 'TITLE', 'XMP' ), true ) ) {
1461+
if ( $in_html && in_array( $tag_name, array( 'IFRAME', 'NOEMBED', 'NOFRAMES', 'SCRIPT', 'STYLE', 'TEXTAREA', 'TITLE', 'XMP' ), true ) ) {
14621462
$text = $this->get_modifiable_text();
14631463

14641464
switch ( $tag_name ) {
@@ -1839,7 +1839,7 @@ private function step_in_head(): bool {
18391839
* > tentative, then change the encoding to the resulting encoding.
18401840
*/
18411841
$charset = $this->get_attribute( 'charset' );
1842-
if ( \is_string( $charset ) ) {
1842+
if ( is_string( $charset ) ) {
18431843
$this->bail( 'Cannot yet process META tags with charset to determine encoding.' );
18441844
}
18451845

@@ -1854,8 +1854,8 @@ private function step_in_head(): bool {
18541854
$http_equiv = $this->get_attribute( 'http-equiv' );
18551855
$content = $this->get_attribute( 'content' );
18561856
if (
1857-
\is_string( $http_equiv ) &&
1858-
\is_string( $content ) &&
1857+
is_string( $http_equiv ) &&
1858+
is_string( $content ) &&
18591859
0 === strcasecmp( $http_equiv, 'Content-Type' )
18601860
) {
18611861
$this->bail( 'Cannot yet process META tags with http-equiv Content-Type to determine encoding.' );
@@ -2473,7 +2473,7 @@ private function step_in_body(): bool {
24732473
}
24742474

24752475
if (
2476-
\in_array(
2476+
in_array(
24772477
$this->state->stack_of_open_elements->current_node()->node_name,
24782478
array( 'H1', 'H2', 'H3', 'H4', 'H5', 'H6' ),
24792479
true
@@ -2965,7 +2965,7 @@ private function step_in_body(): bool {
29652965
* > string "hidden", then: set the frameset-ok flag to "not ok".
29662966
*/
29672967
$type_attribute = $this->get_attribute( 'type' );
2968-
if ( ! \is_string( $type_attribute ) || 'hidden' !== strtolower( $type_attribute ) ) {
2968+
if ( ! is_string( $type_attribute ) || 'hidden' !== strtolower( $type_attribute ) ) {
29692969
$this->state->frameset_ok = false;
29702970
}
29712971

@@ -3467,7 +3467,7 @@ private function step_in_table(): bool {
34673467
*/
34683468
case '+INPUT':
34693469
$type_attribute = $this->get_attribute( 'type' );
3470-
if ( ! \is_string( $type_attribute ) || 'hidden' !== strtolower( $type_attribute ) ) {
3470+
if ( ! is_string( $type_attribute ) || 'hidden' !== strtolower( $type_attribute ) ) {
34713471
goto anything_else;
34723472
}
34733473
// @todo Indicate a parse error once it's possible.
@@ -5678,7 +5678,7 @@ public function seek( $bookmark_name ): bool {
56785678
}
56795679

56805680
$this->reset_insertion_mode_appropriately();
5681-
$this->breadcrumbs = \array_slice( $this->breadcrumbs, 0, 2 );
5681+
$this->breadcrumbs = array_slice( $this->breadcrumbs, 0, 2 );
56825682
parent::seek( $this->context_node->bookmark_name );
56835683
}
56845684
}
@@ -5861,7 +5861,7 @@ private function generate_implied_end_tags( ?string $except_for_this_element = n
58615861

58625862
while (
58635863
( $no_exclusions || ! $this->state->stack_of_open_elements->current_node_is( $except_for_this_element ) ) &&
5864-
\in_array( $this->state->stack_of_open_elements->current_node()->node_name, $elements_with_implied_end_tags, true )
5864+
in_array( $this->state->stack_of_open_elements->current_node()->node_name, $elements_with_implied_end_tags, true )
58655865
) {
58665866
$this->state->stack_of_open_elements->pop();
58675867
}
@@ -5902,7 +5902,7 @@ private function generate_implied_end_tags_thoroughly(): void {
59025902
'TR',
59035903
);
59045904

5905-
while ( \in_array( $this->state->stack_of_open_elements->current_node()->node_name, $elements_with_implied_end_tags, true ) ) {
5905+
while ( in_array( $this->state->stack_of_open_elements->current_node()->node_name, $elements_with_implied_end_tags, true ) ) {
59065906
$this->state->stack_of_open_elements->pop();
59075907
}
59085908
}
@@ -6464,7 +6464,7 @@ private function is_html_integration_point(): bool {
64646464
$encoding = $this->get_attribute( 'encoding' );
64656465

64666466
return (
6467-
\is_string( $encoding ) &&
6467+
is_string( $encoding ) &&
64686468
(
64696469
0 === strcasecmp( $encoding, 'application/xhtml+xml' ) ||
64706470
0 === strcasecmp( $encoding, 'text/html' )
@@ -6488,7 +6488,7 @@ private function is_html_integration_point(): bool {
64886488
* @return bool Whether the element of the given name is in the special category.
64896489
*/
64906490
public static function is_special( $tag_name ): bool {
6491-
if ( \is_string( $tag_name ) ) {
6491+
if ( is_string( $tag_name ) ) {
64926492
$tag_name = strtoupper( $tag_name );
64936493
} else {
64946494
$tag_name = 'html' === $tag_name->namespace

0 commit comments

Comments
 (0)