code: public static function replaceCallback($pattern, $callback, $subject, $limit = -1, &$count = null)
      {
          $result = @preg_replace_callback(self::addUtf8Modifier($pattern), $callback, $subject, $limit, $count);
          if (null !== $result && PREG_NO_ERROR === preg_last_error()) {
              return $result;
          }
  
          $result = @preg_replace_callback(self::removeUtf8Modifier($pattern), $callback, $subject, $limit, $count);
          if (null !== $result && PREG_NO_ERROR === preg_last_error()) {
              return $result;
          }
  
          throw new PregException('Error occurred when calling preg_replace_callback.', preg_last_error());
      }
docs: @param string|string[] $pattern
  @param callable        $callback
  @param string|string[] $subject
  @param int             $limit
  @param null|int        $count
  
  @throws PregException
  
  @return string|string[]