You are here

class Kint_Objects_Closure in Devel 8

Same name and namespace in other branches
  1. 8.2 kint/kint/parsers/objects/closure.php \Kint_Objects_Closure

Hierarchy

Expanded class hierarchy of Kint_Objects_Closure

File

kint/kint/parsers/objects/closure.php, line 3

View source
class Kint_Objects_Closure extends KintObject {
  public function parse(&$variable) {
    if (!$variable instanceof Closure) {
      return false;
    }
    $this->name = 'Closure';
    $reflection = new ReflectionFunction($variable);
    $ret = array(
      'Parameters' => array(),
    );
    if ($val = $reflection
      ->getParameters()) {
      foreach ($val as $parameter) {

        // todo http://php.net/manual/en/class.reflectionparameter.php
        $ret['Parameters'][] = $parameter->name;
      }
    }
    if ($val = $reflection
      ->getStaticVariables()) {
      $ret['Uses'] = $val;
    }
    if (method_exists($reflection, 'getClousureThis') && ($val = $reflection
      ->getClosureThis())) {
      $ret['Uses']['$this'] = $val;
    }
    if ($val = $reflection
      ->getFileName()) {
      $this->value = Kint::shortenPath($val) . ':' . $reflection
        ->getStartLine();
    }
    return $ret;
  }
  public function isDefaultValueAvailable() {
    if (PHP_VERSION_ID === 50316) {

      // PHP bug #62988
      try {
        $this
          ->getDefaultValue();
        return true;
      } catch (\ReflectionException $e) {
        return false;
      }
    }
    return parent::isDefaultValueAvailable();
  }

}

Members

Namesort descending Modifiers Type Description Overrides
KintObject::$name public property @var string type of variable, can be set in inherited object or in static::parse() method
KintObject::$value public property @var string quick variable value displayed inline
Kint_Objects_Closure::isDefaultValueAvailable public function
Kint_Objects_Closure::parse public function * returns false or associative array - each key represents a tab in default view, values may be anything * * Overrides KintObject::parse