mirror of
https://github.com/WordPress/WordPress.git
synced 2024-11-10 21:00:59 +01:00
HTML API: Add sentinels for unreachable code.
There are places in the HTML API code where some tools get confused and flag invalid types for the return of a function because they are unable to detect that the end of the function is unreachable. Since PHP doesn't provide a way to encode total matching in the source code, this patch adds a few extra lines in those unreachable locations to satisfy any tooling which isn't able to fully analyze the code. Additionally this serves as extra guarding in case someone changes these functions in a way which would break them and the existing test suite doesn't catch those breakages. Developed in https://github.com/WordPress/wordpress-develop/pull/7315 Discussed in https://core.trac.wordpress.org/ticket/62018 Props dlh, dmsnell. Fixes #62018. Built from https://develop.svn.wordpress.org/trunk@59001 git-svn-id: http://core.svn.wordpress.org/trunk@58397 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
7f0a5f518b
commit
011d45abbc
@ -2770,6 +2770,10 @@ class WP_HTML_Processor extends WP_HTML_Tag_Processor {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->bail( 'Should not have been able to reach end of IN BODY processing. Check HTML API code.' );
|
||||
// This unnecessary return prevents tools from inaccurately reporting type errors.
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -4645,6 +4649,10 @@ class WP_HTML_Processor extends WP_HTML_Tag_Processor {
|
||||
$this->bail( "Unaware of the requested parsing mode: '{$this->state->insertion_mode}'." );
|
||||
}
|
||||
}
|
||||
|
||||
$this->bail( 'Should not have been able to reach end of IN FOREIGN CONTENT processing. Check HTML API code.' );
|
||||
// This unnecessary return prevents tools from inaccurately reporting type errors.
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -5878,6 +5886,10 @@ class WP_HTML_Processor extends WP_HTML_Tag_Processor {
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$this->bail( 'Should not have reached end of HTML Integration Point detection: check HTML API code.' );
|
||||
// This unnecessary return prevents tools from inaccurately reporting type errors.
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2965,6 +2965,9 @@ class WP_HTML_Tag_Processor {
|
||||
return $lower_tag_name;
|
||||
}
|
||||
}
|
||||
|
||||
// This unnecessary return prevents tools from inaccurately reporting type errors.
|
||||
return $tag_name;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -16,7 +16,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '6.7-alpha-59000';
|
||||
$wp_version = '6.7-alpha-59001';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
Loading…
Reference in New Issue
Block a user