WP_View_Config_Data::remove_properties( mixed $current, mixed $spec ): mixed
- Since
- 7.1.0
- Source
wp-includes/class-wp-view-config-data.php:599
Description
The mirror of merge_properties(), applied at every nesting level: a list in $spec names entries to delete from $current — associative keys are unset, and list members are matched by identity (list_item_identity) and dropped — while an associative $spec recurses into each named entry to prune from within it. A name absent from $current is ignored, and a list is renumbered after members are removed so it keeps sequential keys.
Compatibility
- WordPress
- since 7.1.0
- PHP
- 7.4–8.6-dev
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in 1 of the 5 tracked releases, added in 7.1.0, and compiles on PHP 7.4 through 8.6-dev.
Parameters
$currentmixed- The current value.
$specmixed- The names to remove from it.
Return value
mixed- The pruned value.
Performance profile
How much work a call to WP_View_Config_Data::remove_properties() 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
- 5–22
- Plugin surface
- None
- Called by
- 2
Touches nothing outside its own arguments.
The body loops, so the work grows with what you pass in.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 65.
Nothing here hands control to plugin code.
2 places in core call this, so the cost is paid more often than your own code shows.
What one call costs · 3 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost WP_View_Config_Data::remove_properties() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
| always | 5–7 | none |
is_array($current) && is_array($spec) && !array_is_list() | 17–19 | array_is_list(), array_is_list() |
is_array($current) && is_array($spec) && array_is_list() | 20–22 | array_is_list(), array_is_list(), array_values() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 65 | 5–22 | 14 | |
| 8.5 | 65 | 5–22 | 14 | |
| 8.4 | 65 | 5–22 | 14 | |
| 8.3 | 65 | 5–22 | 14 | |
| 8.2 | 65 | 5–22 | 14 | |
| 8.1 | 65 | 5–22 | 14 | 2 fewer instructions than PHP 7.4 |
| 7.4 | 67 | 5–23 | 14 |
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 · 4
- array_is_list()Polyfill for `array_is_list()` function added in PHP 8.1.
- WP_View_Config_Data::remove_list_member()Removes the first list member matching an identity, leaving the rest.
- WP_View_Config_Data::list_item_identity()Resolves the identity used to match a list member against another.
- WP_View_Config_Data::remove_properties()Removes the properties a spec names from the current value.
Used by · 2
- WP_View_Config_Data::remove()Removes named properties from the configuration, leaving the rest alone.
- WP_View_Config_Data::remove_properties()Removes the properties a spec names from the current value.
Source code
private function remove_properties( $current, $spec ) { if ( ! is_array( $current ) || ! is_array( $spec ) ) { return $current; } $current_is_list = array_is_list( $current ); if ( array_is_list( $spec ) ) { // Each entry names something to delete from the current value. foreach ( $spec as $name ) { if ( $current_is_list ) { $current = $this->remove_list_member( $current, $name ); } else { unset( $current[ $name ] ); } } } else { // Each key names an entry to recurse into and prune from within. foreach ( $spec as $name => $subspec ) { if ( $current_is_list ) { foreach ( $current as $index => $member ) { if ( $this->list_item_identity( $member ) === (string) $name ) { $current[ $index ] = $this->remove_properties( $member, $subspec ); break; } } } elseif ( array_key_exists( $name, $current ) ) { $current[ $name ] = $this->remove_properties( $current[ $name ], $subspec ); } } } // Renumber so a list from which a member was removed keeps sequential keys. return $current_is_list ? array_values( $current ) : $current; }Changelog
Introduced in 7.1.0.
Signature, return type and hooks compared across 1 parsed release.
About this page
- Parsed data
- Generated from the wordpress-develop 7.1.0 tag, from
src/wp-includes/class-wp-view-config-data.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.