PHPackages                             sergiors/functional - 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. sergiors/functional

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

sergiors/functional
===================

Functional Programming for PHP no loop behind

23852PHP

Since Jul 4Pushed 9y ago3 watchersCompare

[ Source](https://github.com/sergiors/functional)[ Packagist](https://packagist.org/packages/sergiors/functional)[ RSS](/packages/sergiors-functional/feed)WikiDiscussions php7 Synced 4w ago

READMEChangelogDependenciesVersions (2)Used By (0)

Functional
----------

[](#functional)

[![Scrutinizer Code Quality](https://camo.githubusercontent.com/7e19374087be68fa0fd31905f096b0442b2e6f8c9ec372d891de402c4436e649/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f73657267696f72732f66756e6374696f6e616c2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/sergiors/functional/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/268e569641885ac22741087bcbb4264e25f02c31a7ae202660b4e15ffb44c7ee/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f73657267696f72732f66756e6374696f6e616c2f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/sergiors/functional/?branch=master)[![Build Status](https://camo.githubusercontent.com/11f43d03c2671e419dd0328a8b7c5331f31773fa41b91329731f4f71446ecf66/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f73657267696f72732f66756e6374696f6e616c2f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/sergiors/functional/build-status/master)

Motivation
----------

[](#motivation)

I did create this project to explore **Functional Programming**.
**This project doesn't use any loop!**

Install
-------

[](#install)

```
composer require sergiors/functional "dev-master"
```

How to use
----------

[](#how-to-use)

```
use Sergiors\Functional as F;

$addFourNumbers = function ($a, $b, $c, $d) {
    return $a + $b + $c + $d;
};

$partialAddFourNumbers = F\partial($addFourNumbers);
$f = $partialAddFourNumbers(1, 2);
$g = $f(3);

echo $g(4); // => 10
```

You can hold native functions with `Sergiors\Funcional\hold`.

```
use Sergiors\Functional as F;

$implode = F\hold('implode', ',');
echo $implode(['a', 'b']); // => a,b

// something more complex
$pipe = F\pipe(
    F\hold('array_slice', F\_, 2),
    F\hold('array_map', function ($x) {
        return $x * 2;
    }),
    F\hold('implode', ',')
);

echo $pipe([10, 20, 30, 40, 50]); // => 60,80,100
```

`Sergiors\Functional\_` is the placeholder for payload. If you don't set the placeholder, the payload will be last argument.

Collection
----------

[](#collection)

You can wrap an array with `Sergiors\Functional\Collection` to use fluent interface.

```
use Sergiors\Functional\Collection;

$ls1 = new Collection([1, 2, 3, 4, 5, 6]);

$ls2 = $ls1->filter(function ($x) {
    return $x > 2;
})->map(function ($x) {
    return $x + 1;
});

print_r($ls1->toArray()); // => [1, 2, 3, 4, 5, 6]
print_r($ls2->toArray()); // => [4, 5, 6, 7]
```

API
---

[](#api)

All functions are automatically applied partial application.

```
always()
append()
compose()
concat()
diff()
drop()
each()
equals()
filter()
find()
flatten()
get()
getin()
gt()
gte()
has()
head()
hold()
id()
ifelse()
last()
lt()
lte()
map()
not()
partial()
pipe()
prop()
prepend()
reduce()
sort()
tail()
take()
takewhile()

```

```
Collection::concat()
Collection::filter()
Collection::map()
Collection::each()
Collection::prepend()
Collection::append()
Collection::reduce()
Collection::count()
Collection::getIterator()
Collection::toArray()

```

License
-------

[](#license)

MIT

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 96.4% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/75b67763139f7a8c96302299f5a40a386d565829af3061bb55465c8808d54428?d=identicon)[sergiors](/maintainers/sergiors)

---

Top Contributors

[![sergiors](https://avatars.githubusercontent.com/u/2046276?v=4)](https://github.com/sergiors "sergiors (107 commits)")[![haskellcamargo](https://avatars.githubusercontent.com/u/7553006?v=4)](https://github.com/haskellcamargo "haskellcamargo (3 commits)")[![joaolucasl](https://avatars.githubusercontent.com/u/11381624?v=4)](https://github.com/joaolucasl "joaolucasl (1 commits)")

### Embed Badge

![Health badge](/badges/sergiors-functional/health.svg)

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

###  Alternatives

[wordpress/phpdoc-parser

Static code parser for WordPress source.

23920.0k](/packages/wordpress-phpdoc-parser)[webdevstudios/cmb2-user-select

Special CMB2 Field that allows users to define an autocomplete text field for users

211.3k1](/packages/webdevstudios-cmb2-user-select)

PHPackages © 2026

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