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