wpml / fp
Requires
None
Requires (Dev)
- clean/phpdoc-md: ^0.19.3
- jakeasmith/http_build_url: ^1.0
- lucatume/function-mocker: ^2.0
- phpunit/phpunit: ^9.6
- wpml/collect: dev-wpml-collect-rename
Suggests
None
Provides
None
Conflicts
None
Replaces
None
- dev-develop
- 5.0.0
- 0.2.11
- 0.2.10
- 0.2.9
- 0.2.8
- 0.2.7
- 0.2.6
- 0.2.5
- 0.2.4
- 0.2.3
- 0.2.2
- 0.2.1
- 0.2.0
- 0.1.9
- 0.1.8
- 0.1.7
- 0.1.6
- 0.1.5
- 0.1.4
- 0.1.3
- 0.1.2
- 0.1.1
- 0.1.0
- dev-wpmldev-12548
- dev-wpmldev-12549
- dev-wpmldev-7474
- dev-release/4.9.5
- dev-master
- dev-wpmldev-5364-2
- dev-wpmldev-3714
- dev-wpmldev-3840
- dev-wp-6.5-4.6.10
- dev-wpmlpb-292
- dev-wpmldev-486
- dev-lens-iso
- dev-str-trimPrefix
- dev-release/0.1.8
- dev-demo-2
- dev-demo
- dev-pierre-composition-example
- dev-wpmltm-4320
- dev-memorizeByArgs
- dev-hotfix/wpmlcore-7860
- dev-hotfix/wpmltm-3930
- dev-wpmlst-2280
- dev-pattern-match
- dev-demo-1
- dev-pair-monad
- dev-reader-monad
- dev-before-after-invoker
- dev-sonarqube-test
- dev-sequence
- dev-hotfix/security-checks-bruce
- dev-hotfix/security-checks
- dev-lst-flatten
- dev-add-more-functions
- dev-improve-always
This package is auto-updated.
Last update: 2026-11-07 13:13:18 UTC
README
Many functional programming resources can be difficult for beginners to understand. Functional programming isn’t exactly a friendly paradigm for new programmers, and maintenance can be difficult during the coding phase. The switch to functional programming requires time, practice, and a change in the approach to writing code and solving problems. Although we reviewed many libraries, several of which were excellent, we weren’t able to find what we needed to write expressive code in a functional style - so we decided to create our own. Take a look at the Functional Programming Library built by our developers to see a collection of functions we’ve used in WPML projects.
Documentation
Calling convention (since wpmldev-12549)
The hot entry points are real static methods: Obj::prop, propOr, path, pathOr, assoc, has, keys, values,
Str::startsWith, includes, Lst::includes, Relation::equals, propEq. Called with all their arguments
(and no Fns::__) they run plain PHP in one frame: 10-20x cheaper than the curried dispatch, the caller at the top
of every backtrace, a real signature for PHPStan and "go to definition". Called with fewer arguments or a placeholder
they return the curried macro's partial application, exactly as before (tests/FastPathTest.php pins both forms to
the pre-12549 implementations).
For new and changed code in the products:
- call
wpml/fpfully applied, or write plain PHP (the closure, the loop, theif); - no new partial application (
Obj::prop( 'id' )as a callback),Fns::__,pipe(),compose(),spreadArgs(),curryN()orEither/Maybeflow; - wpml-core's
build/quality/fp-style-check.shis the full-tree ratchet that fails CI on a new one.
Adding a fast path to another entry point follows the pattern in core/Obj.php: a real static method with the macro's
name and argument order that hands over to self::$macros[ $name ] when not fully applied, a macro that delegates to
it, and a FastPathTest row set against a frozen copy of the previous implementation.