定制 xwero/paf 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

xwero/paf

最新稳定版本:0.6.0

Composer 安装命令:

composer require xwero/paf

包简介

pipe operator array functions

README 文档

README

We complained for years that the array functions are messy.

  • The array is the first argument in array_filter, but the last in array_map.
  • Some functions are by value and other are by reference.

And while there are good reasons those functions are how they are, they don't feel developer friendly.

Most solutions use the builder pattern. The functions in this library are meant to be used with the pipe operator.

All the function return an array.

Filter functions

filterBoth

This function replaces array_filter($arr, $filterFunction, ARRAY_FILTER_USE_BOTH).

In addition to adding the array and the filter function it is possible to reindex the keys, with or without a custom reindex function.

filterKeys

This function replaces array_filter($arr, $filterFunction, ARRAY_FILTER_USE_KEY).

filterValues

This function replaces array_filter($arr, $filterFunction).

In addition to adding the array and the filter function it is possible to reindex the keys, with or without a custom reindex function.

removeEmpty

This function replaces array_filter($arr).

In addition to adding the array it is possible to reindex the keys, with or without a custom reindex function.

Map functions

mapValues

This function replaces array_map($mapFunction, $array, ...$arrays) and array_map($mapFunction, $array).

In addition to adding the arrays and the map function it is possible to reindex the keys, with or without a custom reindex function.

mapBoth

This function replaces array_map($mapFunction, $array, array_keys($array)).

In addition to adding the array and the map function it is possible to reindex the keys, with or without a custom reindex function.

zip

This function replaces array_map(null, $array, ...$arrays).

Sort functions

sortKeys

This function replaces ksort($array, $flags) and krsort($array, $flags).

The switch between the two functions is done with the $decending boolean argument, that is by default false.

sortKeysCustom

This function replaces uksort($array, $sortFunction).

sortValues

This function replaces sort($array, $flags), rsort($array, $flags), asort($array, $flags) and arsort($array, $flags).

The switch between the function is done by the combination of the $decending boolean argument and the $reIndex boolean argument. Both are false by default.

sortValuesCustom

This function replaces usort($array, $sortFunction) and uasort($array, $sortFunction).

The switch between the function is done by the $reIndex boolean argument, that is by default false.

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 7
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-04-29

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固