The with function returns the value it is given. If a closure is passed as the second argument to the function, the closure will be executed and its returned value will be returned:
<?php $callback = function ($value) {
    return (is_numeric($value)) ? $value * 2 : 0;
};

$result = with(5, $callback);


$result = with(null, $callback);


$result = with(5, null);
<?php         $key = self::class;

        $extensions = app('statamic.extensions');



        $extensions[$key] = with($extensions[$key] ?? collect(), function ($bindings) {

            $bindings[static::handle()] = static::class;



            if (method_exists(static::class, 'aliases')) {

                foreach (static::aliases() as $alias) {

                    $bindings[$alias] = static::class;

                }

            }



            return $bindings;

        });

    }

}
<?php     {

        Carbon::setTestNow(Carbon::parse('2015-09-24'));



        $dateEntry = with('', function () {

            $collection = tap(Collection::make('dated')->dated(true))->save();



            return (new Entry)->collection($collection);

        });



        $numberEntry = with('', function () {

            $collection = tap(Collection::make('ordered')->structureContents(['max_depth' => 1, 'tree' => []]))->save();
<?php             return (new Entry)->collection($collection);

        });



        $numberEntry = with('', function () {

            $collection = tap(Collection::make('ordered')->structureContents(['max_depth' => 1, 'tree' => []]))->save();



            return (new Entry)->collection($collection);

        });



        $dateEntry->date('2017-01-02');