src/helpers/BaseYaml.php
/**
     * Get the default dumper config
     *
     * @return array
     */
Get the default dumper config
@return array
Get the default dumper config @return array
protected static function defaultDumperConfig()
    {
        $expPrefix = uniqid('', true);
        $expressions = [];
        return [
            'on yii\helpers\UnsetArrayValue' => function ($event) {
                $event->handleValue(new TaggedValue('yii/helpers/UnsetArrayValue', null));
            },
            'on yii\helpers\ReplaceArrayValue' => function ($event) {
                $replaceArrayValue = $event->value;
                $event->handleValue(new TaggedValue('yii/helpers/ReplaceArrayValue', $replaceArrayValue->value));
            },
            'on yii\web\JsExpression' => function ($event) use (&$expressions, $expPrefix) {
                $data = $event->value;
                $token = "!{[$expPrefix=" . count($expressions) . ']}!';
                $expressions['"' . $token . '"'] = $data->expression;
                $event->handleValue($token);
            },
            'on ' . Dumper::EVENT_AFTER_DUMP => function ($event) use (&$expressions) {
                $yaml = $event->value;
                $event->value = $expressions === [] ? $yaml : strtr($yaml, $expressions);
            },
            'on JsonSerializable' => function ($event) {
                $value = Json::decode($event->value->jsonSerialize(), true);
                if ($value === []) {
                    $value = new \stdClass();
                }
                $event->handleValue($value);
            },
            'on yii\base\Arrayable' => function ($event) {
                $value = $event->value->toArray();
                if ($value === []) {
                    $value = new \stdClass();
                }
                $event->handleValue($value);
            },
            'on SimpleXMLElement' => function ($event) {
                $value = (array) $event->value;
                if ($value === []) {
                    $value = new \stdClass();
                }
                $event->handleValue($value);
            },
            'on ' . Dumper::EVENT_UNHANDLED_OBJECT => function ($event) {
                $result = [];
                foreach ($event->value as $name => $value) {
                    $result[$name] = $value;
                }
                if ($result === []) {
                    $result = new \stdClass();
                }
                $event->handleValue($result);
            }
        ];
    }
protected static function defaultDumperConfig ( ) { $ expPrefix = uniqid ( '' , true ) ; $ expressions = [ ] ; return [ 'on yii\helpers\UnsetArrayValue' => function ( $ event ) { $ event -> handleValue ( new TaggedValue ( 'yii/helpers/UnsetArrayValue' , null ) ) ; } , 'on yii\helpers\ReplaceArrayValue' => function ( $ event ) { $ replaceArrayValue = $ event -> value ; $ event -> handleValue ( new TaggedValue ( 'yii/helpers/ReplaceArrayValue' , $ replaceArrayValue -> value ) ) ; } , 'on yii\web\JsExpression' => function ( $ event ) use ( & $ expressions , $ expPrefix ) { $ data = $ event -> value ; $ token = " !{[ $ expPrefix = " . count ( $ expressions ) . ']}!' ; $ expressions [ '"' . $ token . '"' ] = $ data -> expression ; $ event -> handleValue ( $ token ) ; } , 'on ' . Dumper :: EVENT_AFTER_DUMP => function ( $ event ) use ( & $ expressions ) { $ yaml = $ event -> value ; $ event -> value = $ expressions === [ ] ? $ yaml : strtr ( $ yaml , $ expressions ) ; } , 'on JsonSerializable' => function ( $ event ) { $ value = Json :: decode ( $ event -> value -> jsonSerialize ( ) , true ) ; if ( $ value === [ ] ) { $ value = new \ stdClass ( ) ; } $ event -> handleValue ( $ value ) ; } , 'on yii\base\Arrayable' => function ( $ event ) { $ value = $ event -> value -> toArray ( ) ; if ( $ value === [ ] ) { $ value = new \ stdClass ( ) ; } $ event -> handleValue ( $ value ) ; } , 'on SimpleXMLElement' => function ( $ event ) { $ value = ( array ) $ event -> value ; if ( $ value === [ ] ) { $ value = new \ stdClass ( ) ; } $ event -> handleValue ( $ value ) ; } , 'on ' . Dumper :: EVENT_UNHANDLED_OBJECT => function ( $ event ) { $ result = [ ] ; foreach ( $ event -> value as $ name => $ value ) { $ result [ $ name ] = $ value ; } if ( $ result === [ ] ) { $ result = new \ stdClass ( ) ; } $ event -> handleValue ( $ result ) ; } ] ; }
Get the default dumper config
 @return array
Get the default dumper config @return array