public function __getToArrayCallBack()
    {
        return function ($subject) {
            static::$__depth++;

            if ($subject instanceof Arrayable) {
                $subject = $subject->toArray();
            }

            if (is_object($subject)) {
                $subject = get_object_vars($subject);
            }

            if (is_array($subject)) {
                if (static::$__depth <= static::$__maxDepth) {
                    $subject = array_map(
                        $this->__getToArrayCallBack(),
                        $subject
                    );
                } else {
                    $subject = null;
                }
            }

            static::$__depth--;

            return $subject;
        };
    }
public function __getToArrayCallBack()
    {
        return function ($subject) {
            static::$__depth++;

            if ($subject instanceof Arrayable) {
                $subject = $subject->toArray();
            }

            if (is_object($subject)) {
                $subject = get_object_vars($subject);
            }

            if (is_array($subject)) {
                if (static::$__depth <= static::$__maxDepth) {
                    $subject = array_map(
                        $this->__getToArrayCallBack(),
                        $subject
                    );
                } else {
                    $subject = null;
                }
            }

            static::$__depth--;

            return $subject;
        };
    }
public function __getToArrayCallBack ( ) { return function ( $ subject ) { static :: $ __depth ++ ; if ( $ subject instanceof Arrayable ) { $ subject = $ subject -> toArray ( ) ; } if ( is_object ( $ subject ) ) { $ subject = get_object_vars ( $ subject ) ; } if ( is_array ( $ subject ) ) { if ( static :: $ __depth <= static :: $ __maxDepth ) { $ subject = array_map ( $ this -> __getToArrayCallBack ( ) , $ subject ) ; } else { $ subject = null ; } } static :: $ __depth -- ; return $ subject ; } ; }
Generate a callback to transform object to array.

@return \Closure
Generate a callback to transform object to array .