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         return tap($this->callAfterCallbacks(

            $user, $ability, $arguments, $result

        ), function ($result) use ($user, $ability, $arguments) {

            $this->dispatchGateEvaluatedEvent($user, $ability, $arguments, $result);

        });

    }
<?php     protected function buildAblyMessage($event, array $payload = [])

    {

        return tap(new AblyMessage, function ($message) use ($event, $payload) {

            $message->name = $event;

            $message->data = $payload;

            $message->connectionKey = data_get($payload, 'socket');

        });

    }
<?php                         ->lockForUpdate()

                        ->first();



            return is_null($batch) ? [] : tap($callback($batch), function ($values) use ($batchId) {

                $this->connection->table($this->table)->where('id', $batchId)->update($values);

            });

        });

    }
<?php     public function dispatchNextJobInChain()

    {

        if (! empty($this->chained)) {

            dispatch(tap(unserialize(array_shift($this->chained)), function ($next) {

                $next->chained = $this->chained;



                $next->onConnection($next->connection ?: $this->chainConnection);

                $next->onQueue($next->queue ?: $this->chainQueue);



                $next->chainConnection = $this->chainConnection;

                $next->chainQueue = $this->chainQueue;

                $next->chainCatchCallbacks = $this->chainCatchCallbacks;

            }));

        }

    }
<?php     public function increment($key, $value = 1)

    {

        if (! is_null($existing = $this->get($key))) {

            return tap(((int) $existing) + $value, function ($incremented) use ($key) {

                $value = $this->serializesValues ? serialize($incremented) : $incremented;



                $this->storage[$key]['value'] = $value;

            });

        }



        $this->forever($key, $value);
<?php     public function repository(Store $store, array $config = [])

    {

        return tap(new Repository($store, Arr::only($config, ['store'])), function ($repository) use ($config) {

            if ($config['events'] ?? true) {

                $this->setEventDispatcher($repository);

            }

        });

    }
<?php     {

        $raw = $this->getPayload($key);



        return tap(((int) $raw['data']) + $value, function ($newValue) use ($key, $raw) {

            $this->put($key, $newValue, $raw['time'] ?? 0);

        });

    }
<?php             $result = true;

        }



        return tap($result, function () use ($key, $decaySeconds) {

            $this->hit($key, $decaySeconds);

        });

    }
<?php     public function pull($key, $default = null)

    {

        return tap($this->get($key, $default), function () use ($key) {

            $this->forget($key);

        });

    }
<?php     public function forget($key)

    {

        return tap($this->store->forget($this->itemKey($key)), function ($result) use ($key) {

            if ($result) {

                $this->event(new KeyForgotten($this->getName(), $key));

            }

        });

    }
<?php     #[\Override]

    protected function getDefaultInputDefinition(): InputDefinition

    {

        return tap(parent::getDefaultInputDefinition(), function ($definition) {

            $definition->addOption($this->getEnvironmentOption());

        });

    }
<?php     public function fetch()

    {

        return tap($this->buffer, function () {

            $this->buffer = '';

        });

    }
<?php         if ($this->shouldUseLocks($store->getStore())) {

            $lock = $store->getStore()->lock($this->commandMutexName($command));



            return tap(! $lock->get(), function ($exists) use ($lock) {

                if ($exists) {

                    $lock->release();

                }

            });

        }



        return $this->cache->store($this->store)->has($this->commandMutexName($command));
<?php     protected function createInputFromArguments(array $arguments)

    {

        return tap(new ArrayInput(array_merge($this->context(), $arguments)), function ($input) {

            if ($input->getParameterOption('--no-interaction')) {

                $input->setInteractive(false);

            }

        });

    }
<?php         include __DIR__."/../../resources/views/components/$view.php";



        return tap(ob_get_contents(), function () {

            ob_end_clean();

        });

    }