承接 j45l/functional-php 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

j45l/functional-php

Composer 安装命令:

composer require j45l/functional-php

包简介

Functional primitives for PHP

关键字:

README 文档

README

Functional primitives for PHP 8.2+, inspired by several functional libraries such as lstrojny/functional-php, Typelevel Cats, Scala, SML, etc.

This library provides a small, opinionated toolbox to write PHP in a functional style: working with collections as first-class values, composing behaviour out of small functions, and keeping side effects contained.

What you get

Collection filtering and selection

Pick elements out of any iterable without hand-rolling loops: first / last / head / tail, butLast, take, pluck, select / reject, best / worst, and traverse for matching against nested tree-like data.

Collection transformation

Reshape and combine collections: map, flatMap, reindex, fold / foldRight, reduce / reduceRight, sum, merge / mergeGenerator, zip / unzip, concat, cartesianProduct, crossCompareSet, from / upTo, recurseTimes, and conversions between iterables, arrays and generators (toArray, toGenerator, toIterable, yieldIterable, unindex).

Function composition, partial application and currying

Build new functions out of existing ones: compose, pipe, partial, partialRight.

Logic and predicate helpers

Combine and negate predicates and ask boolean questions of collections: every, some, none, not.

Value functions

Tiny building blocks that show up everywhere when composing: identity, nop, trueFn, falseFn, value, with.

Object & type functions

Work with values whose type or shape needs checking or adjusting: isAOr, isClosureOr, cloneWith (clones an object and runs a closure bound to it, so even private properties can be set on the copy).

Loop and effect functions

Express imperative-shaped work without leaving the functional style: doWhile, doUntil, doEach, also (run a side effect and pass the value through), delay, tryOrThrow.

Optimization

tailRecursion decorates a recursive closure with a trampoline so deep recursion does not blow the PHP stack, and MemoizeTrait caches results of pure methods.

Sequences

Lazy numeric sequences as iterable objects: LinearSequence, ExponentialSequence, FibonacciSequence, plus the underlying Sequence / SequenceIterator to roll your own.

Tuples

Simple immutable Pair and Triplet value objects, with factory helpers — useful as return types for functions that naturally produce two or three related values (and as the output of crossCompareSet).

PHPUnit helpers

A handful of assertion helpers in PHPUnitFunctions.php for testing code written in this style.

Design notes

  • The library targets PHP 8.2+.
  • Most functions accept any iterable as input and return an array. Some fully consume generators — beware of infinite ones.
  • Only \Closure is accepted where a function is expected (not the looser callable). Wrap anything else in an arrow function, e.g. fn(...$a) => strtolower(...$a).

Install

composer require j45l/functional-php

Documentation

Per-function reference with signatures and examples: Functions.

For anything not covered there, the unit tests under tests/ are the source of truth.

j45l/functional-php 适用场景与选型建议

j45l/functional-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 20.73k 次下载、GitHub Stars 达 4, 最近一次更新时间为 2022 年 01 月 15 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「functional」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 j45l/functional-php 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 j45l/functional-php 我们能提供哪些服务?
定制开发 / 二次开发

基于 j45l/functional-php 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 20.73k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 4
  • 点击次数: 1
  • 依赖项目数: 3
  • 推荐数: 0

GitHub 信息

  • Stars: 4
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-01-15