Changeset 46127 for trunk/tests/phpunit/includes/utils.php
- Timestamp:
- 09/15/2019 11:03:45 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/includes/utils.php
r45607 r46127 129 129 } 130 130 131 function filterall( $tag, $arg = null) {131 function filterall( $tag, ...$args ) { 132 132 // this one doesn't return the result, so it's safe to use with the new 'all' filter 133 133 if ( $this->debug ) { … … 135 135 } 136 136 137 $args = func_get_args();138 137 $this->events[] = array( 139 138 'filter' => __FUNCTION__, 140 139 'tag' => $tag, 141 'args' => array_slice( $args, 1 ),140 'args' => $args, 142 141 ); 143 142 } … … 245 244 } 246 245 247 function xml_find( $tree /*, $el1, $el2, $el3, .. */ ) { 248 $a = func_get_args(); 249 $a = array_slice( $a, 1 ); 250 $n = count( $a ); 246 function xml_find( $tree, ...$elements ) { 247 $n = count( $elements ); 251 248 $out = array(); 252 249 … … 256 253 257 254 for ( $i = 0; $i < count( $tree ); $i++ ) { 258 # echo "checking '{$tree[$i][name]}' == '{$ a[0]}'\n";259 # var_dump( $tree[$i]['name'], $a[0]);260 if ( $tree[ $i ]['name'] === $ a[0] ) {255 # echo "checking '{$tree[$i][name]}' == '{$elements[0]}'\n"; 256 # var_dump( $tree[$i]['name'], $elements[0] ); 257 if ( $tree[ $i ]['name'] === $elements[0] ) { 261 258 # echo "n == {$n}\n"; 262 259 if ( 1 === $n ) { 263 260 $out[] = $tree[ $i ]; 264 261 } else { 265 $subtree =& $tree[ $i ]['child']; 266 $call_args = array( $subtree ); 267 $call_args = array_merge( $call_args, array_slice( $a, 1 ) ); 268 $out = array_merge( $out, call_user_func_array( 'xml_find', $call_args ) ); 262 $subtree =& $tree[ $i ]['child']; 263 $out = array_merge( $out, xml_find( $subtree, ...array_slice( $elements, 1 ) ) ); 269 264 } 270 265 } … … 301 296 } 302 297 303 function dmp() { 304 $args = func_get_args(); 305 298 function dmp( ...$args ) { 306 299 foreach ( $args as $thing ) { 307 300 echo ( is_scalar( $thing ) ? strval( $thing ) : var_export( $thing, true ) ), "\n";
Note: See TracChangeset
for help on using the changeset viewer.