PHPackages                             taq/phpr - 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. taq/phpr

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

taq/phpr
========

Extending some PHP classes to be used on a more functional way

0.0.1(10y ago)312GPL-2.0PHPPHP &gt;=5.3.0

Since Dec 1Pushed 10y ago2 watchersCompare

[ Source](https://github.com/taq/phpr)[ Packagist](https://packagist.org/packages/taq/phpr)[ Docs](http://github.com/taq/phpr)[ RSS](/packages/taq-phpr/feed)WikiDiscussions master Synced 2w ago

READMEChangelogDependenciesVersions (2)Used By (0)

PHPR
====

[](#phpr)

What is - motivation
--------------------

[](#what-is---motivation)

Trying to extend some PHP objects to be used on a more functional way. Once one PHP developer said that nowadays IDE's can help us to avoid remembering the lack of standardization some PHP methods has. As I don't use an IDE, as lots of developers out there, I don't agree with that and I'm kind of tired to try to remember if on `array_filter` or `array_map`the array goes first and the function goes last or what order they are.

So, I think it's easier to use on a function and Ruby style way, where we can call the methods on the **object** and it returns what we need.

One notable exception to try to make things easier is that PHP have some reserved and constant words we cannot reuse even inside a namespace, like `Array`. So I needed to call the `Array` class `Collection`, otherwise it will be impossible to implement. All the classes have the original object accessible with the `values` method.

Other thing is that some methods just returns a value or null, true or false. No more guesses and wonderings of what happened if it returns 0 or false.

Samples
-------

[](#samples)

```
$t = new PHPR\Collection([0 => "zero", 1 => "one", 2 => "two"]);

// outputs:
// null
// yay, no more 'undefined index' messages!
echo $t[10]."\n";

// outputs:
// zero
// one
// two
$t->each(function($e) {
   echo "$e\n";
});

// each
// outputs:
// 0 - zero
// 1 - one
// 2 - two
$t->each(function($key, $val) {
   echo "$key - $val\n";
});

$t->includes("one");    // true
$t->includes("three");  // false

// sort
// outputs:
// array(3) {
//   [0] =>
//   string(3) "one"
//   [1] =>
//   string(3) "two"
//   [2] =>
//   string(4) "zero"
// }
$sorted = $t->sort();
var_dump($sorted->values());

$t->min(); // "one"
$t->max(); // "zero"

// select
// outputs (keeping order):
// array(1) {
//   [0] =>
//   string(4) "zero"
// }
$selected = $t->select(function($e) {
   return strlen($e) > 3;
});
var_dump($selected->values());

// map
// outputs:
// array(3) {
//   [0] =>
//   string(4) "orez"
//   [1] =>
//   string(3) "eno"
//   [2] =>
//   string(3) "owt"
// }
$changed = $t->map(function($e) {
   return strrev($e);
});
var_dump($changed->values());

$t->all(function($e) { return strlen($e) > 2; })); // true
$t->all(function($e) { return strlen($e) > 3; })); // false

$t->any(function($e) { return strlen($e) > 3; })); // true
$t->any(function($e) { return strlen($e) > 4; })); // false

// chainable methods
// outputs:
// array(2) {
//     [0] =>
//     string(3) "eno"
//     [1] =>
//     string(3) "owt"
//   }
$changed = self::$_col->map(function($e) {
   return strrev($e);
})->select(function($e) { return strlen($e) values());
```

###  Health Score

23

—

LowBetter than 26% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity48

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

3856d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/273db918d5bd2c20b61a40797df70fdbee387de22e2c1dd75419868048980d30?d=identicon)[taq](/maintainers/taq)

---

Top Contributors

[![taq](https://avatars.githubusercontent.com/u/9789?v=4)](https://github.com/taq "taq (14 commits)")

---

Tags

languagefunctional

### Embed Badge

![Health badge](/badges/taq-phpr/health.svg)

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

###  Alternatives

[phpoption/phpoption

Option Type for PHP

2.7k566.1M169](/packages/phpoption-phpoption)[lstrojny/functional-php

Functional primitives for PHP

2.0k7.5M50](/packages/lstrojny-functional-php)[nikic/iter

Iteration primitives using generators

1.1k6.2M51](/packages/nikic-iter)[patrickschur/language-detection

A language detection library for PHP. Detects the language from a given text string.

8533.5M20](/packages/patrickschur-language-detection)[wapmorgan/morphos

A morphological solution for Russian and English language written completely in PHP. Provides classes to inflect personal names, geographical names, decline and pluralize nouns, generate cardinal and ordinal numerals, spell out money amounts and time.

8261.3M7](/packages/wapmorgan-morphos)[lambdish/phunctional

λ PHP functional library

3632.1M24](/packages/lambdish-phunctional)

PHPackages © 2026

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