You are here

protected function Dbug::varIsObject in dBug for Drupal 2.0.x

Same name and namespace in other branches
  1. 8 src/Dbug.php \Drupal\dbug\Dbug::varIsObject()
  2. 1.0.x src/Dbug.php \Drupal\dbug\Dbug::varIsObject()

If variable is an object type.

Parameters

mixed $var: The variable.

1 call to Dbug::varIsObject()
Dbug::checkType in src/Dbug.php
Check variable type.

File

src/Dbug.php, line 406

Class

Dbug
Implementation of dBug for Drupal.

Namespace

Drupal\dbug

Code

protected function varIsObject($var) {
  $var_ser = serialize($var);
  array_push($this->arrHistory, $var_ser);
  $this
    ->makeTableHeader("object", "object");
  if (is_object($var)) {
    $arrObjVars = get_object_vars($var);
    foreach ($arrObjVars as $key => $value) {
      $value = !is_object($value) && !is_array($value) && trim($value) == "" ? "[empty string]" : $value;
      $this
        ->makeTdHeader("object", $key);

      // Check for recursion.
      if (is_object($value) || is_array($value)) {
        $var_ser = serialize($value);
        if (in_array($var_ser, $this->arrHistory, TRUE)) {
          $value = is_object($value) ? "*RECURSION* -> \$" . get_class($value) : "*RECURSION*";
        }
      }
      if (in_array(gettype($value), $this->arrType)) {
        $this
          ->checkType($value);
      }
      else {
        $this->output[] = $value;
      }
      $this->output[] = $this
        ->closeTdRow();
    }
    $arrObjMethods = get_class_methods(get_class($var));
    foreach ($arrObjMethods as $key => $value) {
      $this
        ->makeTdHeader("object", $value);
      $this->output[] = "[function]" . $this
        ->closeTdRow();
    }
  }
  else {
    $this->output[] = "<tr><td>" . $this
      ->error("object") . $this
      ->closeTdRow();
  }
  array_pop($this->arrHistory);
  $this->output[] = "</table>";
}