You are here

class kintVariableData in Devel 8.2

Same name and namespace in other branches
  1. 8 kint/kint/inc/kintVariableData.class.php \kintVariableData

Hierarchy

Expanded class hierarchy of kintVariableData

File

kint/kint/inc/kintVariableData.class.php, line 3

View source
class kintVariableData {

  /** @var string */
  public $type;

  /** @var string */
  public $access;

  /** @var string */
  public $name;

  /** @var string */
  public $operator;

  /** @var int */
  public $size;

  /**
   * @var kintVariableData[] array of kintVariableData objects or strings; displayed collapsed, each element from
   * the array is a separate possible representation of the dumped var
   */
  public $extendedValue;

  /** @var string inline value */
  public $value;

  /** @var kintVariableData[] array of alternative representations for same variable, don't use in custom parsers */
  public $_alternatives;

  /* *******************************************
   * HELPERS
   */
  private static $_supportedCharsets = array(
    'UTF-8',
    'Windows-1252',
    # Western; includes iso-8859-1
    'euc-jp',
  );
  protected static function _detectEncoding($value) {
    $ret = null;
    if (function_exists('mb_detect_encoding')) {
      $mbDetected = mb_detect_encoding($value);
      if ($mbDetected === 'ASCII') {
        return 'ASCII';
      }
    }
    if (!function_exists('iconv')) {
      return !empty($mbDetected) ? $mbDetected : 'UTF-8';
    }
    $md5 = md5($value);
    foreach (Kint::$charEncodings as $encoding) {

      # fuck knows why, //IGNORE and //TRANSLIT still throw notice
      if (md5(@iconv($encoding, $encoding, $value)) === $md5) {
        return $encoding;
      }
    }
    return 'ASCII';
  }

  /**
   * returns whether the array:
   *  1) is numeric and
   *  2) in sequence starting from zero
   *
   * @param array $array
   *
   * @return bool
   */
  protected static function _isSequential(array $array) {
    return array_keys($array) === range(0, count($array) - 1);
  }
  protected static function _strlen($string, $encoding = null) {
    if (function_exists('mb_strlen')) {
      $encoding or $encoding = self::_detectEncoding($string);
      return mb_strlen($string, $encoding);
    }
    else {
      return strlen($string);
    }
  }
  protected static function _substr($string, $start, $end, $encoding = null) {
    if (function_exists('mb_substr')) {
      $encoding or $encoding = self::_detectEncoding($string);
      return mb_substr($string, $start, $end, $encoding);
    }
    else {
      return substr($string, $start, $end);
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
kintVariableData::$access public property @var string
kintVariableData::$extendedValue public property * * the array is a separate possible representation of the dumped var
kintVariableData::$name public property @var string
kintVariableData::$operator public property @var string
kintVariableData::$size public property @var int
kintVariableData::$type public property @var string
kintVariableData::$value public property @var string inline value
kintVariableData::$_alternatives public property @var kintVariableData[] array of alternative representations for same variable, don't use in custom parsers
kintVariableData::$_supportedCharsets private static property
kintVariableData::_detectEncoding protected static function
kintVariableData::_isSequential protected static function * returns whether the array: * 1) is numeric and * 2) in sequence starting from zero * *
kintVariableData::_strlen protected static function
kintVariableData::_substr protected static function