* - In a pattern $1, $2, etc... will be replaced with the relevant contents
* - If you used a keyed array as a path pattern, $key will be replaced with
* the relevant contents
- * - The default behavior is equivalent to `array( 'title' => '$1' )`,
- * if you don't want the title parameter you can explicitly use `array( 'title' => false )`
+ * - The default behavior is equivalent to `[ 'title' => '$1' ]`,
+ * if you don't want the title parameter you can explicitly use `[ 'title' => false ]`
* - You can specify a value that won't have replacements in it
* using `'foo' => [ 'value' => 'bar' ];`
*
/**
* Protected helper to do the actual bulk work of adding a single pattern.
* This is in a separate method so that add() can handle the difference between
- * a single string $path and an array() $path that contains multiple path
+ * a single string $path and an array $path that contains multiple path
* patterns each with an associated $key to pass on.
* @param string $path
* @param array $params
// Loop over our options and convert any single value $# restrictions
// into an array so we only have to do in_array tests.
foreach ( $options as $optionName => $optionData ) {
- if ( preg_match( '/^\$\d+$/u', $optionName ) ) {
- if ( !is_array( $optionData ) ) {
- $options[$optionName] = [ $optionData ];
- }
+ if ( preg_match( '/^\$\d+$/u', $optionName ) && !is_array( $optionData ) ) {
+ $options[$optionName] = [ $optionData ];
}
}
}
// We know the difference between null (no matches) and
- // array() (a match with no data) but our WebRequest caller
- // expects array() even when we have no matches so return
- // a array() when we have null
- return is_null( $matches ) ? [] : $matches;
+ // [] (a match with no data) but our WebRequest caller
+ // expects [] even when we have no matches so return
+ // a [] when we have null
+ return $matches ?? [];
}
/**