data_fill

The data_fill function sets a missing value within a nested array or object using "dot" notation:
<?php $data = ['products' => ['desk' => ['price' => 100]]];

data_fill($data, 'products.desk.price', 200);


data_fill($data, 'products.desk.discount', 10);
<?php     {

        $data = ['foo' => 'bar'];



        $this->assertEquals(['foo' => 'bar', 'baz' => 'boom'], data_fill($data, 'baz', 'boom'));

        $this->assertEquals(['foo' => 'bar', 'baz' => 'boom'], data_fill($data, 'baz', 'noop'));

        $this->assertEquals(['foo' => [], 'baz' => 'boom'], data_fill($data, 'foo.*', 'noop'));

        $this->assertEquals(
<?php         $data = ['foo' => 'bar'];



        $this->assertEquals(['foo' => 'bar', 'baz' => 'boom'], data_fill($data, 'baz', 'boom'));

        $this->assertEquals(['foo' => 'bar', 'baz' => 'boom'], data_fill($data, 'baz', 'noop'));

        $this->assertEquals(['foo' => [], 'baz' => 'boom'], data_fill($data, 'foo.*', 'noop'));

        $this->assertEquals(

            ['foo' => ['bar' => 'kaboom'], 'baz' => 'boom'],
<?php         $this->assertEquals(['foo' => 'bar', 'baz' => 'boom'], data_fill($data, 'baz', 'boom'));

        $this->assertEquals(['foo' => 'bar', 'baz' => 'boom'], data_fill($data, 'baz', 'noop'));

        $this->assertEquals(['foo' => [], 'baz' => 'boom'], data_fill($data, 'foo.*', 'noop'));

        $this->assertEquals(

            ['foo' => ['bar' => 'kaboom'], 'baz' => 'boom'],

            data_fill($data, 'foo.bar', 'kaboom')
<?php         $this->assertEquals(['foo' => [], 'baz' => 'boom'], data_fill($data, 'foo.*', 'noop'));

        $this->assertEquals(

            ['foo' => ['bar' => 'kaboom'], 'baz' => 'boom'],

            data_fill($data, 'foo.bar', 'kaboom')

        );

    }
<?php         $this->assertEquals(

            ['foo' => []],

            data_fill($data, 'foo.*.bar', 'noop')

        );



        $this->assertEquals(
<?php         $this->assertEquals(

            ['foo' => [], 'bar' => [['baz' => 'original'], []]],

            data_fill($data, 'bar', [['baz' => 'original'], []])

        );



        $this->assertEquals(
<?php         $this->assertEquals(

            ['foo' => [], 'bar' => [['baz' => 'original'], ['baz' => 'boom']]],

            data_fill($data, 'bar.*.baz', 'boom')

        );



        $this->assertEquals(
<?php         $this->assertEquals(

            ['foo' => [], 'bar' => [['baz' => 'original'], ['baz' => 'boom']]],

            data_fill($data, 'bar.*', 'noop')

        );

    }
<?php             ],

        ];



        data_fill($data, 'posts.*.comments.*.name', 'Filled');



        $this->assertEquals([

            'posts' => [