class@anonymous::block_core_image_extract_empty_figcaption_element(): WP_HTML_Span|false
- Since
- 6.9.0
- Source
wp-includes/blocks/image.php:36
Description
Returns span of input for an empty FIGCAPTION, if currently matched on a FIGCAPTION opening tag and if the element is properly closed and empty.
Compatibility
- WordPress
- since 6.9.0
- PHP
- 7.4–8.6-dev
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in 3 of the 5 tracked releases, added in 6.9.0, and compiles on PHP 7.4 through 8.6-dev.
Return value
WP_HTML_Span|false- Span of input if the element is empty; otherwise false.
Performance profile
How much work a call to class@anonymous::block_core_image_extract_empty_figcaption_element() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.
- Cost class
- Light
- Scaling
- Scales with input
- Instructions
- 13–36
- Plugin surface
- None
- Called by
- 0
Touches nothing outside its own arguments.
The body loops, so the work grows with how much data it finds.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 37.
Nothing here hands control to plugin code.
Nothing in core calls this; the cost is only what you spend yourself.
What one call costs · 6 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost class@anonymous::block_core_image_extract_empty_figcaption_element() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
!->next_token() | 13 | ->set_bookmark(), ->next_token(), ->get_tag() |
!->next_token() && !->is_tag_closer() | 16 | ->set_bookmark(), ->next_token(), ->get_tag(), ->is_tag_closer() |
->next_token() | 17 | ->set_bookmark(), ->next_token(), ->get_token_name(), ->get_tag() |
->next_token() && !->is_tag_closer() | 20 | ->set_bookmark(), ->next_token(), ->get_token_name(), ->get_tag(), ->is_tag_closer() |
!->next_token() && ->is_tag_closer() | 32 | ->set_bookmark(), ->next_token(), ->get_tag(), ->is_tag_closer(), ->set_bookmark() |
->next_token() && ->is_tag_closer() | 36 | ->set_bookmark(), ->next_token(), ->get_token_name(), ->get_tag(), ->is_tag_closer(), ->set_bookmark() |
Across PHP versions
Compiles the same on PHP 7.4, 8.1, 8.2, 8.3, 8.4, 8.5 and 8.6-dev: 37 instructions, 13–36 executed per call, 4 branches. The work does not change between versions.
An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.
Uses · 6
- \\class@anonymous::set_bookmark()
- \\class@anonymous::next_token()
- \\class@anonymous::get_token_name()
- \\class@anonymous::get_tag()
- \\class@anonymous::is_tag_closer()
- WP_HTML_Span::__construct()Constructor.
Source code
public function block_core_image_extract_empty_figcaption_element() { $this->set_bookmark( 'here' ); $opener = $this->bookmarks['here']; // Allow comments within the definition of “empty.” while ( $this->next_token() && '#comment' === $this->get_token_name() ) { continue; } if ( 'FIGCAPTION' !== $this->get_tag() || ! $this->is_tag_closer() ) { return false; } $this->set_bookmark( 'here' ); $closer = $this->bookmarks['here']; return new WP_HTML_Span( $opener->start, $closer->start + $closer->length - $opener->start ); }Changelog
Introduced in 6.9.0. Unchanged from 6.9.7 through 7.1.0.
Signature, return type and hooks compared across 3 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 7.1.0 tag, from
src/wp-includes/blocks/image.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.