PHPackages                             adrianschubek/with - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. adrianschubek/with

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

adrianschubek/with
==================

Adds with() functionality

1.0(5y ago)210MITPHPPHP &gt;=7.4

Since Jul 18Pushed 5y ago1 watchersCompare

[ Source](https://github.com/adrianschubek/with)[ Packagist](https://packagist.org/packages/adrianschubek/with)[ Docs](https://docs.adriansoftware.de/with)[ RSS](/packages/adrianschubek-with/feed)WikiDiscussions master Synced 5d ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

with()
======

[](#with)

[![Latest Stable Version](https://camo.githubusercontent.com/b713e111d6738ce33a88dc53fdb4a8030e4064f298d5fa7a179abbbab599b057/68747470733a2f2f706f7365722e707567782e6f72672f61647269616e7363687562656b2f776974682f76)](//packagist.org/packages/adrianschubek/with)[![License](https://camo.githubusercontent.com/358ffbffbf512c849101ad71b65811edcc1afbe944fca9e9c7e53833f48d5779/68747470733a2f2f706f7365722e707567782e6f72672f61647269616e7363687562656b2f776974682f6c6963656e7365)](//packagist.org/packages/adrianschubek/with)

```
function with($val, callable $callback = null) : $val | WithProxy
```

Passes `$val` through `$callback` and returns `$val`.
Returns a `WithProxy` instead if `$callback` = null.

Installation
------------

[](#installation)

```
composer require adrianschubek/with

```

Example
-------

[](#example)

#### Using Arrow function/Closure

[](#using-arrow-functionclosure)

```
$user = with(UserRepository::findById(123), function (User $us) {
    $us->setBalance(10);
    $us->sendConfirmation();
});
```

```
$deletedUser = with(UserRepository::findById(123), fn(User $user) => $user->deleteAccount());
```

#### Using Proxy

[](#using-proxy)

```
// sendWelcomeMail() is a method of User.
$randomUser = with(UserRepository::createRandomUser())->sendWelcomeMail();
```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

2128d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/500782457c7bfa139f0c77fc085cceaf6114c39ff2e7551c32bedb36af2a759b?d=identicon)[adrian.schubek](/maintainers/adrian.schubek)

---

Top Contributors

[![adrianschubek](https://avatars.githubusercontent.com/u/19362349?v=4)](https://github.com/adrianschubek "adrianschubek (2 commits)")

### Embed Badge

![Health badge](/badges/adrianschubek-with/health.svg)

```
[![Health](https://phpackages.com/badges/adrianschubek-with/health.svg)](https://phpackages.com/packages/adrianschubek-with)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
