Doctrine\Common\Util\Debug::fillReturnWithClassAttributes PHP Method

fillReturnWithClassAttributes() private static method

Fill the $return variable with class attributes
private static fillReturnWithClassAttributes ( object $var, stdClass $return, integer $maxDepth ) : mixed
$var object
$return stdClass
$maxDepth integer
return mixed
    private static function fillReturnWithClassAttributes($var, \stdClass $return, $maxDepth)
    {
        $reflClass = ClassUtils::newReflectionObject($var);
        $parsedAttributes = array();
        do {
            $currentClassName = $reflClass->getName();
            foreach ($reflClass->getProperties() as $reflProperty) {
                $attributeKey = $reflProperty->isPrivate() ? $currentClassName . '#' : '';
                $attributeKey .= $reflProperty->getName();
                if (isset($parsedAttributes[$attributeKey])) {
                    continue;
                }
                $parsedAttributes[$attributeKey] = true;
                $name = $reflProperty->getName() . ($return->__CLASS__ !== $currentClassName || $reflProperty->isPrivate() ? ':' . $currentClassName : '') . ($reflProperty->isPrivate() ? ':private' : '') . ($reflProperty->isProtected() ? ':protected' : '');
                $reflProperty->setAccessible(true);
                $return->{$name} = self::export($reflProperty->getValue($var), $maxDepth - 1);
            }
        } while ($reflClass = $reflClass->getParentClass());
        return $return;
    }