: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
class NF_Handlers_LocaleNumberFormatting
public function __construct($locale) {
public static function create() {
return new self($wp_locale);
public function locale_decode_number( $number ) {
// Be sure we have a string.
$number = strval( $number );
$thousands_sep = $this->locale->number_format['thousands_sep'];
// Account for negative numbers.
if ( '-' == substr( $number, 0, 1 ) ) {
$number = str_replace( '-', '', $number );
// Account for a space as the thousands separator.
$thousands_sep = str_replace( self::NBSP, ' ', $thousands_sep );
$number = str_replace( self::NBSP, ' ', $number );
// Determine what our existing separators are.
$haystack = str_split( $number );
$separators = preg_grep( '/[0-9]/', $haystack, PREG_GREP_INVERT );
$final_separators = array_unique( $separators );
$final_separators = array_values( $final_separators );
switch( count( $final_separators ) ) {
if ( 1 == count( $separators ) ) {
$separator = reset($separators);
list($before, $after) = explode($separator, $number);
if(3 == strlen($after) && $separator == $thousands_sep) {
$formatted = str_replace( $final_separators[0], $replacer, $number );
$formatted = str_replace( $final_separators[0], '', $number );
$formatted = str_replace( $final_separators[1], '.', $formatted );
$formatted = '-' . $formatted;
public function locale_encode_number( $number, $decimal = null, $thousand = null ) {
// Be sure we have a string.
$number = strval( $number );
// Decode our input value.
$number = $this->locale_decode_number( $number );
if ( 'NaN' == $number ) return 'NaN';
$thousands_sep = $this->locale->number_format['thousands_sep'];
$decimal_point = $this->locale->number_format['decimal_point'];
$thousands_sep = ( !is_null($thousand) ) ? $thousand : $thousands_sep;
$decimal_point = ( !is_null($decimal) ) ? $decimal : $decimal_point;
// Account for a space as the thousands separator.
$thousands_sep = str_replace( ' ', self::NBSP, $thousands_sep );
if ( false !== strpos( $number, '.' ) ) {
$tmp = explode( '.', $number );
$precision = strlen( array_pop( $tmp ) );
$number = floatval( $number );
return number_format( $number, $precision, $decimal_point, $thousands_sep );
public function locale_decode_equation( $eq ) {
// Be sure we have a string.
$eq = str_replace( array(' ', ' ', ' '), '', $eq );
$characters = str_split( $eq );
foreach ( $characters as $character ) {
// If it matches the pattern...
if ( preg_match( $pattern, $character ) ) {
$expression .= $character;
// If we reach an operator char, append the expression to the result
if ( 0 < strlen( $expression ) ) {
$result .= $this->locale_decode_number( $expression );
// The following catches the case of the last character being a digit.
if ( 0 < strlen( $expression ) ) {
$result .= $this->locale_decode_number( $expression );