You are here

protected function Kint_Parsers_ClassStatics::_parse in Devel 8.2

Same name and namespace in other branches
  1. 8 kint/kint/parsers/custom/classstatics.php \Kint_Parsers_ClassStatics::_parse()

* main and usually single method a custom parser must implement * *

Parameters

mixed $variable: * * @return mixed [!!!] false is returned if the variable is not of current type

Overrides kintParser::_parse

File

kint/kint/parsers/custom/classstatics.php, line 5

Class

Kint_Parsers_ClassStatics

Code

protected function _parse(&$variable) {
  if (!KINT_PHP53 || !is_object($variable)) {
    return false;
  }
  $extendedValue = array();
  $reflection = new ReflectionClass($variable);

  // first show static values
  foreach ($reflection
    ->getProperties(ReflectionProperty::IS_STATIC) as $property) {
    if ($property
      ->isPrivate()) {
      if (!method_exists($property, 'setAccessible')) {
        break;
      }
      $property
        ->setAccessible(true);
      $access = "private";
    }
    elseif ($property
      ->isProtected()) {
      $property
        ->setAccessible(true);
      $access = "protected";
    }
    else {
      $access = 'public';
    }
    $_ = $property
      ->getValue();
    $output = kintParser::factory($_, '$' . $property
      ->getName());
    $output->access = $access;
    $output->operator = '::';
    $extendedValue[] = $output;
  }
  foreach ($reflection
    ->getConstants() as $constant => $val) {
    $output = kintParser::factory($val, $constant);
    $output->access = 'constant';
    $output->operator = '::';
    $extendedValue[] = $output;
  }
  if (empty($extendedValue)) {
    return false;
  }
  $this->value = $extendedValue;
  $this->type = 'Static class properties';
  $this->size = count($extendedValue);
}