tap

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     static function generateBladeView($subject, $data = [])

    {

        if (! is_string($subject)) {

            return tap($subject)->with($data);

        }



        $component = new class($subject) extends \Illuminate\View\Component
<?php         $reflected = new ReflectionObject($subTarget ?? $component);



        foreach (static::getClassAttributesRecursively($reflected) as $attribute) {

            $instance->push(tap($attribute->newInstance(), function ($attribute) use ($component, $subTarget) {

                $attribute->__boot($component, AttributeLevel::ROOT, null, null, $subTarget);

            }));

        }



        foreach ($reflected->getMethods() as $method) {
<?php         foreach ($reflected->getMethods() as $method) {

            foreach ($method->getAttributes(Attribute::class, ReflectionAttribute::IS_INSTANCEOF) as $attribute) {

                $instance->push(tap($attribute->newInstance(), function ($attribute) use ($component, $method, $propertyNamePrefix, $subTarget) {

                    $attribute->__boot($component, AttributeLevel::METHOD, $propertyNamePrefix . $method->getName(), $method->getName(), $subTarget);

                }));

            }

        }
<?php         foreach ($reflected->getProperties() as $property) {

            foreach ($property->getAttributes(Attribute::class, ReflectionAttribute::IS_INSTANCEOF) as $attribute) {

                $instance->push(tap($attribute->newInstance(), function ($attribute) use ($component, $property, $propertyNamePrefix, $subTarget) {

                    $attribute->__boot($component, AttributeLevel::PROPERTY, $propertyNamePrefix . $property->getName(), $property->getName(), $subTarget);

                }));

            }

        }
<?php                 public function __call($method, $params)

                {

                    return tap($this->browser->{$method}(...$params), function ($browser) {

                        $browser->waitUsing(6, 25, function () use ($browser) {

                            return $browser->driver->executeScript("return window.duskIsWaitingForLivewireRequest{$this->id} === undefined");

                        }, 'Livewire request was never triggered');

                    });

                }

            };

        };
<?php                 public function __call($method, $params)

                {

                    return tap($this->browser->{$method}(...$params), function ($browser) {

                        $browser->waitUsing(6, 25, function () use ($browser) {

                            return $browser->driver->executeScript("return window.duskIsWaitingForLivewireRequest{$this->id}");

                        }, 'Livewire request was triggered');

                    });

                }

            };

        };
<?php                 public function __call($method, $params)

                {

                    return tap($this->browser->{$method}(...$params), function ($browser) {

                        $browser->waitUsing(6, 25, function () use ($browser) {

                            return $browser->driver->executeScript("return window.duskIsWaitingForLivewireNavigate{$this->id} === undefined");

                        }, 'Livewire navigate was never triggered');

                    });

                }

            };

        };
<?php                 public function __call($method, $params)

                {

                    return tap($this->browser->{$method}(...$params), function ($browser) {

                        $browser->waitUsing(6, 25, function () use ($browser) {

                            return $browser->driver->executeScript("return window.duskIsWaitingForLivewireNavigateRequestFinished{$this->id} === undefined");

                        }, 'Livewire navigate request was never completed');

                    });

                }

            };

        };
<?php                 public function __call($method, $params)

                {

                    return tap($this->browser->{$method}(...$params), function ($browser) {

                        $browser->waitUsing(6, 25, function () use ($browser) {

                            return $browser->driver->executeScript("return window.duskIsWaitingForLivewireNavigateRequestStarted{$this->id}");

                        }, 'Livewire navigate request was completed');

                    });

                }

            };

        };
<?php     {

        return function () {


            return tap($this)->script("window.dispatchEvent(new Event('online'))");

        };

    }
<?php     {

        return function () {


            return tap($this)->script("window.dispatchEvent(new Event('offline'))");

        };

    }
<?php         $content = $this->html();



        tap(strip_tags($content), function ($content) use ($values) {

            foreach ($values as $value) {

                PHPUnit::assertStringContainsString((string) $value, $content);

            }

        });



        return $this;

    }
<?php     {

        array_push(static::$renderStack, $component);



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

            array_pop(static::$renderStack);

        });

    }



    protected function updateProperties($component, $updates, $data, $context)
<?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');

        });

    }