Created
November 15, 2015 16:18
-
-
Save bartfeenstra/e0eb807f3e9ec4fb49ec to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected function inspect($data, array $path = []) { | |
// Depth protection. | |
if (count($path) > 9) { | |
return; | |
} | |
// Make sure the data is either a scalar or an array. | |
if (is_object($data)) { | |
if (strpos(get_class($data), 'Connection') !== FALSE) { | |
var_dump(get_class($data)); | |
print_r($path); | |
} | |
$reflector = new \ReflectionObject($data); | |
$property_values = []; | |
foreach ($reflector->getProperties() as $property) { | |
if ($property->isStatic()) { | |
continue; | |
} | |
$property->setAccessible(TRUE); | |
$property_values[$property->getName()] = $property->getValue($data); | |
} | |
$data = $property_values; | |
} | |
if (is_array($data)) { | |
foreach ($data as $key => $value) { | |
$this->inspect($value, array_merge($path, [$key])); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment