src/Dumper.php
/**
     * Recursively process the value to handle any PHP objects.
     *
     * @param  mixed $value a value to process
     *
     * @return mixed the value with any PHP objects having been processed
     *     and possibly replaced.
     */
Recursively process the value to handle any PHP objects.
@param  mixed $value a value to process

@return mixed the value with any PHP objects having been processed
and possibly replaced.
Recursively process the value to handle any PHP objects . @param mixed $value a value to process @return mixed the value with any PHP objects having been processed and possibly replaced .
public function preProcess($value)
    {
        if (is_object($value)) {
            $handled = false;
            $classes = array_merge(
                [get_class($value) => get_class($value)],
                class_parents($value),
                class_implements($value));
            foreach ($classes as $class) {
                if ($this->hasEventHandlers($class)) {
                    $event = Yii::createObject([
                        'class' => ValueEvent::class,
                        'value' => $value,
                    ]);
                    $this->trigger($class, $event);
                    if ($event->handled) {
                        $value = $event->getRawValue();
                        $handled = true;
                        break;
                    }
                }
            }
            if ($value instanceof TaggedValue) {
                $handled = true;
            }
            if (!$handled && $this->hasEventHandlers(self::EVENT_UNHANDLED_OBJECT)) {
                $event = Yii::createObject([
                    'class' => ValueEvent::class,
                    'value' => $value,
                ]);
                $this->trigger(self::EVENT_UNHANDLED_OBJECT, $event);
                if ($event->handled) {
                    $value = $event->getRawValue();
                }
            }
        }
        if (!is_array($value)) {
            return $value;
        }
        foreach ($value as $k=>&$v) {
            $v = $this->preProcess($v);
        }
        return $value;
    }
public function preProcess ( $ value ) { if ( is_object ( $ value ) ) { $ handled = false ; $ classes = array_merge ( [ get_class ( $ value ) => get_class ( $ value ) ] , class_parents ( $ value ) , class_implements ( $ value ) ) ; foreach ( $ classes as $ class ) { if ( $ this -> hasEventHandlers ( $ class ) ) { $ event = Yii :: createObject ( [ 'class' => ValueEvent :: class , 'value' => $ value , ] ) ; $ this -> trigger ( $ class , $ event ) ; if ( $ event -> handled ) { $ value = $ event -> getRawValue ( ) ; $ handled = true ; break ; } } } if ( $ value instanceof TaggedValue ) { $ handled = true ; } if ( ! $ handled && $ this -> hasEventHandlers ( self :: EVENT_UNHANDLED_OBJECT ) ) { $ event = Yii :: createObject ( [ 'class' => ValueEvent :: class , 'value' => $ value , ] ) ; $ this -> trigger ( self :: EVENT_UNHANDLED_OBJECT , $ event ) ; if ( $ event -> handled ) { $ value = $ event -> getRawValue ( ) ; } } } if ( ! is_array ( $ value ) ) { return $ value ; } foreach ( $ value as $ k => & $ v ) { $ v = $ this -> preProcess ( $ v ) ; } return $ value ; }
Recursively process the value to handle any PHP objects.
Recursively process the value to handle any PHP objects .
// prepare a list of $value's class, ancestor classes, interfaces, // and ancestor interfaces: // we don't want to consider this an "unhandled object" // if someone wants to pre-process these, they should add // an explicit handler for the TaggedValue object