1<?php
2/**
3 * Diff API: WP_Text_Diff_Renderer_inline class
4 *
5 * @package WordPress
6 * @subpackage Diff
7 * @since 4.7.0
8 */
9
10/**
11 * Better word splitting than the PEAR package provides.
12 *
13 * @since 2.6.0
14 * @uses Text_Diff_Renderer_inline Extends
15 */
16#[AllowDynamicProperties]
17class WP_Text_Diff_Renderer_inline extends Text_Diff_Renderer_inline {
18
19 /**
20 * @ignore
21 * @since 2.6.0
22 *
23 * @param string $string
24 * @param string $newlineEscape
25 * @return string
26 */
27 public function _splitOnWords( $string, $newlineEscape = "\n" ) { // phpcs:ignore Universal.NamingConventions.NoReservedKeywordParameterNames.stringFound,WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase
28 $string = str_replace( "\0", '', $string );
29 $words = preg_split( '/([^\w])/u', $string, -1, PREG_SPLIT_DELIM_CAPTURE );
30 $words = str_replace( "\n", $newlineEscape, $words ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase
31 return $words;
32 }
33}
34