awurth / functional
Functional primitives for PHP
v0.2.0
2025-07-14 13:01 UTC
Requires
- php: ^8.2
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.82.2
- phpstan/phpstan: ^2.1.17
- phpstan/phpstan-deprecation-rules: ^2.0.3
- phpstan/phpstan-phpunit: ^2.0.6
- phpstan/phpstan-strict-rules: ^2.0.4
- phpunit/phpunit: ^10.5.48
- rector/rector: ^2.1.1
This package is auto-updated.
Last update: 2025-07-14 15:23:06 UTC
README
NOTE: functional-php used to come with a C extension that implemented most of the functions natively. As the performance differences weren’t that huge compared to the maintenance cost it has been removed.
A set of functional primitives for PHP, heavily inspired by Scala’s traversable collection, Dojo’s array functions and Underscore.js
- Works with arrays and everything implementing interface
Traversable
- Consistent interface: for functions taking collections and callbacks, first parameter is always the collection, then the callback.
Callbacks are always passed
$value
,$index
,$collection
. - All functions reside in namespace
Functional
to not raise conflicts with any other extension or library
Installation
Run the following command in your project root:
$ composer require awurth/functional
Docs
Contributing
- Fork and
git clone
the project - Install dependencies via
composer install
- Run the tests via
composer run tests
- Write code and create a PR
Thank you
- Richard Quadling and Pierre Joye for Windows build help
- David Soria Parra for various ideas and the userland version of
Functional\flatten()
- Max Beutel for
Functional\unique()
,Functional\invoke_first()
,Functional\invoke_last()
and all the discussions - An Phan for many great contributions