PHPackages                             linepogl/impartial-pipes - 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. linepogl/impartial-pipes

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

linepogl/impartial-pipes
========================

A PHP library with partial functions suitable for the pipe operator

1.0.0(1mo ago)01.7k↓38.8%11MITPHPPHP ^8.4CI passing

Since Aug 8Pushed 1mo agoCompare

[ Source](https://github.com/linepogl/impartial-pipes)[ Packagist](https://packagist.org/packages/linepogl/impartial-pipes)[ Docs](https://github.com/linepogl/impartial-pipes)[ RSS](/packages/linepogl-impartial-pipes/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (8)Versions (19)Used By (1)

Impartial Pipes
===============

[](#impartial-pipes)

A PHP library providing partial functions suitable for the pipe operator.

```
$users
|> p_filter(static fn (User $user) => $user->isAdmin)
|> p_order_by(static fn (User $x) => $user->age, descending: true)
|> p_then_by(static fn (User $x) => $user->name)
|> p_map(static fn (User $user) => $user->email)
|> p_unique()
|> p_skip(5)
|> p_take(10)
|> p_implode(';')

```

### Features

[](#features)

1. All the produced partial functions have exactly one argument, as the pipe operator expects.
2. Type checking with phpstan and generics.
3. Immutability and lazy evaluation.
4. Iterating with rewindable generators without creating copies of the data. Fallback to array functions when no copies are involved.
5. 100% test coverage.

### Installation

[](#installation)

```
composer require linepogl/impartial-pipes

```

Why use it?
-----------

[](#why-use-it)

The pipe operator of PHP is a great way to chain functions together. However, it is not perfect because it requires that the chained functions accept exactly one mandatory argument. When this is not the case, we have to resort to workarounds by wrapping the functions in a closure.

```
// PHP 8.5
$array
|> static fn ($in) => array_map(static fn (int $x) => $x * $x), $in)
|> static fn ($in) => array_filter($in, static fn (int $x) => $x % 2 === 1)
```

This might be solved in a future version of PHP, with a proposed syntax like this:

```
// PHP > 8.5, if accepted
$array
|> array_map(static fn (int $x) => $x * $x), ...)
|> array_filter(..., static fn (int $x) => $x % 2 === 1)
```

This is a step in the right direction. However, it is still not perfect:

- We still have to remember the infamously inconsistent order of the arguments.
- It works only for arrays, but not for iterables, because the standard library offers too few functions for that.

With Impartial Pipes, we can write the same code as this:

```
// PHP 8.5, with Impartial Pipes
$iterable
|> p_map(static fn (int $x) => $x * $x)
|> p_filter(static fn (int $x) => $x % 2 === 1)
```

### Can I use it before PHP 8.5?

[](#can-i-use-it-before-php-85)

Yes, you can!

Even if the pipe operator is not available, partial functions can still be used. As a result, we get a syntax that is slightly more consistent than that of the standard library. On top of that, we can use these functions with both arrays and iterables.

```
// PHP 8.4, with Impartial Pipes
p_filter(static fn (int $x) => $x % 2 === 1)(
  p_map(static fn (int $x) => $x * $x)(
    $iterable
  )
)
```

Alternatively, you can use the `pipe` function as syntax sugar. In this case, the order of the operations is the same as in the pipe operator.

```
// PHP 8.4, with Impartial Pipes
pipe($iterable)
->to(p_filter(static fn (int $x) => $x % 2 === 1))
->to(p_map(static fn (int $x) => $x * $x))
```

Full Reference
==============

[](#full-reference)

### Combining partial functions

[](#combining-partial-functions)

- [p\_concat](doc/Combining/p_concat.md), [p\_assoc\_concat](doc/Combining/p_assoc_concat.md)

### Mapping partial functions

[](#mapping-partial-functions)

- [p\_map](doc/Mapping/p_map.md), [p\_assoc\_map](doc/Mapping/p_assoc_map.md)
- [p\_flat\_map](doc/Mapping/p_flat_map.md), [p\_assoc\_flat\_map](doc/Mapping/p_assoc_flat_map.md)
- [p\_map\_keys](doc/Mapping/p_map_keys.md)
- [p\_values](doc/Mapping/p_values.md)
- [p\_keys](doc/Mapping/p_keys.md)
- [p\_group\_by](doc/Mapping/p_group_by.md), [p\_assoc\_group\_by](doc/Mapping/p_assoc_group_by.md)
- [p\_order\_by](doc/Mapping/p_order_by.md), [p\_assoc\_order\_by](doc/Mapping/p_assoc_order_by.md)
- [p\_then\_by](doc/Mapping/p_then_by.md)

### Filtering partial functions

[](#filtering-partial-functions)

- [p\_filter](doc/Filtering/p_filter.md), [p\_assoc\_filter](doc/Filtering/p_assoc_filter.md)
- [p\_reject](doc/Filtering/p_reject.md), [p\_assoc\_reject](doc/Filtering/p_assoc_reject.md)
- [p\_compact](doc/Filtering/p_compact.md), [p\_assoc\_compact](doc/Filtering/p_assoc_compact.md)
- [p\_unique](doc/Filtering/p_unique.md), [p\_assoc\_unique](doc/Filtering/p_assoc_unique.md)
- [p\_unique\_keys](doc/Filtering/p_unique_keys.md), [p\_assoc\_unique\_keys](doc/Filtering/p_assoc_unique_keys.md)
- [p\_take](doc/Filtering/p_take.md), [p\_assoc\_take](doc/Filtering/p_assoc_take.md)
- [p\_while](doc/Filtering/p_while.md), [p\_assoc\_while](doc/Filtering/p_assoc_while.md)
- [p\_while\_not\_null](doc/Filtering/p_while_not_null.md), [p\_assoc\_while\_not\_null](doc/Filtering/p_assoc_while_not_null.md)
- [p\_skip](doc/Filtering/p_skip.md), [p\_assoc\_skip](doc/Filtering/p_assoc_skip.md)
- [p\_skip\_while](doc/Filtering/p_skip_while.md), [p\_assoc\_skip\_while](doc/Filtering/p_assoc_skip_while.md)

### Reducing partial functions

[](#reducing-partial-functions)

- [p\_any](doc/Reducing/p_any.md)
- [p\_all](doc/Reducing/p_all.md)
- [p\_count](doc/Reducing/p_count.md)
- [p\_first](doc/Reducing/p_first.md)
- [p\_first\_or](doc/Reducing/p_first_or.md)
- [p\_first\_key](doc/Reducing/p_first_key.md)
- [p\_first\_key\_or](doc/Reducing/p_first_key_or.md)
- [p\_last](doc/Reducing/p_last.md)
- [p\_last\_or](doc/Reducing/p_last_or.md)
- [p\_last\_key](doc/Reducing/p_last_key.md)
- [p\_last\_key\_or](doc/Reducing/p_last_key_or.md)
- [p\_sum](doc/Reducing/p_sum.md)
- [p\_implode](doc/Reducing/p_implode.md)
- [p\_to\_array](doc/Reducing/p_to_array.md)

### Tapping partial functions

[](#tapping-partial-functions)

- [p\_tap](doc/Tapping/p_tap.md)
- [p\_foreach](doc/Tapping/p_foreach.md)
- [p\_narrow](doc/Tapping/p_narrow.md)
- [p\_not\_null](doc/Tapping/p_not_null.md)
- [p\_unfold](doc/Tapping/p_unfold.md)

###  Health Score

49

—

FairBetter than 95% of packages

Maintenance89

Actively maintained with recent releases

Popularity22

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 99.3% 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 ~15 days

Recently: every ~5 days

Total

16

Last Release

58d ago

Major Versions

0.9.2 → 1.0.02026-03-22

### Community

Maintainers

![](https://www.gravatar.com/avatar/4856eaded9e307750ff4ad555c4494390c5ece8ac7bd6fe496f8e0354d848880?d=identicon)[linepogl](/maintainers/linepogl)

---

Top Contributors

[![linepogl](https://avatars.githubusercontent.com/u/464549?v=4)](https://github.com/linepogl "linepogl (149 commits)")[![madelson](https://avatars.githubusercontent.com/u/1269046?v=4)](https://github.com/madelson "madelson (1 commits)")

---

Tags

pipefunctionaliterablelinq

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/linepogl-impartial-pipes/health.svg)

```
[![Health](https://phpackages.com/badges/linepogl-impartial-pipes/health.svg)](https://phpackages.com/packages/linepogl-impartial-pipes)
```

###  Alternatives

[react/stream

Event-driven readable and writable streams for non-blocking I/O in ReactPHP

689126.8M194](/packages/react-stream)[lstrojny/functional-php

Functional primitives for PHP

2.0k7.3M48](/packages/lstrojny-functional-php)[nikic/iter

Iteration primitives using generators

1.1k5.9M38](/packages/nikic-iter)[lambdish/phunctional

λ PHP functional library

3612.0M23](/packages/lambdish-phunctional)[athari/yalinqo

YaLinqo, a LINQ-to-objects library for PHP

4561.2M5](/packages/athari-yalinqo)[sebastiaanluca/php-pipe-operator

Method chaining (or fluent expressions) for any value using any method.

288467.7k2](/packages/sebastiaanluca-php-pipe-operator)

PHPackages © 2026

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