Changeset 48790 for trunk/tests/phpunit/includes/plural-form-function.php
- Timestamp:
- 08/13/2020 12:32:03 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/includes/plural-form-function.php
r46586 r48790 8 8 */ 9 9 function tests_make_plural_form_function( $nplurals, $expression ) { 10 $expression = str_replace( 'n', '$n', $expression ); 11 $func_body = " 12 \$index = (int)($expression); 13 return (\$index < $nplurals)? \$index : $nplurals - 1;"; 10 $closure = function ( $n ) use ( $nplurals, $expression ) { 11 $expression = str_replace( 'n', $n, $expression ); 14 12 15 // phpcs:ignore WordPress.PHP.RestrictedPHPFunctions.create_function_create_function 16 return create_function( '$n', $func_body ); 13 // phpcs:ignore Squiz.PHP.Eval -- This is test code, not production. 14 $index = (int) eval( 'return ' . $expression . ';' ); 15 16 return ( $index < $nplurals ) ? $index : $nplurals - 1; 17 }; 18 19 return $closure; 17 20 }
Note: See TracChangeset
for help on using the changeset viewer.