$items * @param callable(ItemType $item, int|string $key):array $mapper * * @return ResultType[] */ function flat_map( array $items, callable $mapper ): array { $chunks = array(); foreach ( $items as $key => $item ) { $chunk = $mapper( $item, $key ); $chunks = array_merge( $chunks, $chunk ); } return $chunks; } // int-safe str_repeat - as native throws an error if $count is negative. function repeat_str( string $char, int $count ): string { return $count > 0 ? str_repeat( $char, $count ) : ''; } /** * Executes snippets with the supports of top-file declarations - 'declare(strict_types=1)'. * Intercepts and ignores all the top-level echo statements. * * @param array $__context * @param mixed $__error * * @return mixed */ function eval_snippet( string $__code, array $__context, &$__error ) { // @phpcs:ignore extract( $__context ); $__code = trim( $__code ); // eval snippets without the opening tag, // to ensure it works with 'declare(strict_types=1)'. if ( 0 === strpos( $__code, ' $__context * @param mixed $__error */ function eval_template( string $__code, array $__context, &$__error ): void { // @phpcs:ignore extract( $__context ); try { // @phpcs:ignore @eval( '?>' .$__code ); } catch ( Throwable $error ) { $__error = $error; } }