PHPackages                             burnett01/php-piper - 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. burnett01/php-piper

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

burnett01/php-piper
===================

Piper enhances the PHP 8.5 pipe operator (|&gt;) with support for multi-argument functions/callables.

v1.4.2(6mo ago)21[1 PRs](https://github.com/Burnett01/php-piper/pulls)MITPHPPHP ^8.5CI passing

Since Dec 24Pushed 4mo agoCompare

[ Source](https://github.com/Burnett01/php-piper)[ Packagist](https://packagist.org/packages/burnett01/php-piper)[ RSS](/packages/burnett01-php-piper/feed)WikiDiscussions main Synced today

READMEChangelog (7)Dependencies (4)Versions (10)Used By (0)

Piper
=====

[](#piper)

**Piper** enhances the PHP 8.5 pipe operator ([`|>`](https://php.watch/versions/8.5/pipe-operator)) with support for multi-argument functions/callables.

[![phpunit](https://github.com/Burnett01/php-piper/actions/workflows/phpunit.yml/badge.svg)](https://github.com/Burnett01/php-piper/actions/workflows/phpunit.yml) [![phpstan](https://github.com/Burnett01/php-piper/actions/workflows/phpstan.yml/badge.svg)](https://github.com/Burnett01/php-piper/actions/workflows/phpstan.yml) [![phpcs](https://github.com/Burnett01/php-piper/actions/workflows/phpcs.yml/badge.svg)](https://github.com/Burnett01/php-piper/actions/workflows/phpcs.yml) [![Packagist Version](https://camo.githubusercontent.com/f82f9e7e5f57b6149c54d3b6510a0351a72060ff783d83cfcbd8cb8d153d5ad7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6275726e65747430312f7068702d7069706572)](https://camo.githubusercontent.com/f82f9e7e5f57b6149c54d3b6510a0351a72060ff783d83cfcbd8cb8d153d5ad7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6275726e65747430312f7068702d7069706572)

[![Piper Logo](.github/piper-logo.png)](.github/piper-logo.png)

**Background**

In PHP the pipe operator (`|>`) works with single-argument callables, such as `strlen`, `trim`, etc..,

```
$nonce = random_bytes(16)
      |> base64_encode(...);
```

but what if you want to use it with multi-argument callables, such as `rtrim`, `strtr`, etc..

```
// does not work
$nonce = random_bytes(16)
      |> base64_encode(...)
      |> strtr(..., '+/', '-_')
      |> rtrim(..., '=');
```

```
// works but too verbose
$nonce = random_bytes(16)
      |> base64_encode(...)
      |> (fn(string $s): string => strtr($s, '+/', '-_'))
      |> (fn($s) => rtrim($s, '='));
```

This is where **Piper** comes into play!

How it works
------------

[](#how-it-works)

**Piper** is sort of a decorator/wrapper around a callable for the pipe operator `|>`.

### Usage

[](#usage)

> `composer require burnett01/php-piper`

PSR-4 function version:

```
use function Burnett01\Piper\with;

$nonce = random_bytes(16)
      |> base64_encode(...)
      |> with('strtr', '+/', '-_')
      // first-class syntax
      |> with(rtrim(...), '=');

// or pipe() function

use function Burnett01\Piper\pipe;

$nonce = random_bytes(16)
      |> base64_encode(...)
      |> pipe('strtr', '+/', '-_')
      // with first-class syntax
      |> pipe(rtrim(...), '=');
```

PSR-4 class version:

```
use Burnett01\Piper\Piper as pipe;

$nonce = random_bytes(16)
      |> base64_encode(...)
      |> pipe::to('strtr', '+/', '-_')
      // or 'with' + first-class syntax
      |> pipe::with(rtrim(...), '=');
```

The ellipsis `...` represents the first-class callable syntax.

You can use a `callable` as string or first-class syntax for passing the method.

#### Other examples

[](#other-examples)

```
use function Burnett01\Piper\with;

$actual = -1234.5
      |> abs(...)
      |> with(number_format(...), 2, '.', ',')
      |> urlencode(...);
```

Api
---

[](#api)

- #### `Piper::to(callable $fn, mixed ...$args)`

    [](#pipertocallable-fn-mixed-args)

    Creates an instance of Piper for the specificed `$fn`.

    Parameters:

    - callable `$fn` - The name of a callable as string (eg. `'strlen'`) or as first-class syntax (eg. `strlen(...)`)
    - variadic (mixed) `$args` - The arguments for `$fn`

    Context: static

    Returns: instance
- #### `Piper::with(callable $fn, mixed ...$args)`

    [](#piperwithcallable-fn-mixed-args)

    alias for `Piper::to(callable $fn, mixed ...$args)` (see above)
- #### `pipe(callable $fn, mixed ...$args)`

    [](#pipecallable-fn-mixed-args)

    alias for `Piper::to(callable $fn, mixed ...$args)` (see above)
- #### `with(callable $fn, mixed ...$args)`

    [](#withcallable-fn-mixed-args)

    alias for `Piper::to(callable $fn, mixed ...$args)` (see above)

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance71

Regular maintenance activity

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity58

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

Every ~0 days

Total

7

Last Release

190d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1208707?v=4)[Burnett01](/maintainers/Burnett01)[@Burnett01](https://github.com/Burnett01)

---

Top Contributors

[![Burnett01](https://avatars.githubusercontent.com/u/1208707?v=4)](https://github.com/Burnett01 "Burnett01 (47 commits)")

---

Tags

composer-libraryhelperoperatorphpphp85pipe

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/burnett01-php-piper/health.svg)

```
[![Health](https://phpackages.com/badges/burnett01-php-piper/health.svg)](https://phpackages.com/packages/burnett01-php-piper)
```

PHPackages © 2026

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