The tap function accepts two arguments: an arbitrary $value and a closure. The $value will be passed to the closure and then be returned by the tap function. The return value of the closure is irrelevant:
<?php $user = tap(User::first(), function ($user) {
    $user->name = 'taylor';

    $user->save();
});
<?php     public static function fromModel(Model $model)

    {

        return tap(new static, function ($user) use ($model) {

            $user->model($model);

        });

    }



    public function model(Model $model = null)
<?php     protected function getArtisan()

    {

        return tap(

            new Please($this->app, $this->events, Statamic::version())

        )->setName('Statamic');

    }

}
<?php         }



        if ($this->hasStructure()) {

            tap($this->structure(), function ($structure) {

                tap($structure->in($this->locale()), function ($tree) {


                    $parent = $this->parent();

                    if (optional($parent)->isRoot()) {

                        $parent = null;

                    }

                    $this->page()->pages()->all()->each(function ($child) use ($tree, $parent) {

                        $tree->move($child->id(), optional($parent)->id());

                    });

                    $tree->remove($this);

                })->save();

            });

        }



        Facades\Entry::delete($this);
<?php         if ($this->hasStructure()) {

            tap($this->structure(), function ($structure) {

                tap($structure->in($this->locale()), function ($tree) {


                    $parent = $this->parent();

                    if (optional($parent)->isRoot()) {

                        $parent = null;

                    }

                    $this->page()->pages()->all()->each(function ($child) use ($tree, $parent) {

                        $tree->move($child->id(), optional($parent)->id());

                    });

                    $tree->remove($this);

                })->save();

            });

        }
<?php     public function except(...$keys): self

    {

        return tap(new static)->setFields($this->fields->except(...$keys));

    }



    public function only(...$keys): self
<?php     public function only(...$keys): self

    {

        return tap(new static)->setFields($this->fields->only(...$keys));

    }



    public function newInstance()
<?php             throw new \Exception(__('Form already exists'));

        }



        $form = tap(Form::make($handle)->title($request->title))->save();



        session()->flash('success', __('Form created'));
<?php     private function blueprint($set)

    {

        return tap($set->blueprint() ?? $set->inDefaultSite()->blueprint())

            ->setHandle($set->handle())

            ->setNamespace('globals');

    }
<?php     {

        Partyline::comment('Warming Stache...');



        $lock = tap($this->lock('stache-warming'))->acquire(true);



        $this->startTimer();
<?php         Blink::put('tag-paginator', $paginator);



        return tap($paginator, function ($paginator) {

            $paginator->setCollection($paginator->getCollection()->values());

        });

    }



    protected function queryPaginationFriendlyOffset($query, $offset)
<?php     {

        $tag = is_string($class) ? app($class) : $class;



        return tap($tag, function ($tag) use ($properties) {

            $tag->setProperties($properties);

        });

    }

}
<?php     private function init($class, $config)

    {

        return tap(app($class), function ($widget) use ($config) {

            $widget->setConfig($config);

        });

    }

}
<?php     {

        $container = $this->containerWithDisk();



        tap($container->asset('a.txt'), function ($asset) {

            $this->assertInstanceOf(AssetContract::class, $asset);

            $this->assertEquals('File A', $asset->get('title'));

        });



        $this->assertNull($container->asset('non-existent.txt'));

    }
<?php     public function it_gets_assets_in_a_folder()

    {

        tap($this->containerWithDisk()->assets('/'), function ($assets) {

            $this->assertInstanceOf(Collection::class, $assets);

            $this->assertCount(2, $assets);

            $this->assertEveryItemIsInstanceOf(Asset::class, $assets);

        });



        tap($this->containerWithDisk()->assets('nested'), function ($assets) {

            $this->assertInstanceOf(Collection::class, $assets);
<?php             $this->assertEveryItemIsInstanceOf(Asset::class, $assets);

        });



        tap($this->containerWithDisk()->assets('nested'), function ($assets) {

            $this->assertInstanceOf(Collection::class, $assets);

            $this->assertCount(2, $assets);

            $this->assertEveryItemIsInstanceOf(Asset::class, $assets);

        });

    }