承接 vectorial1024/alof-lib 相关项目开发

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

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

vectorial1024/alof-lib

最新稳定版本:0.1.1

Composer 安装命令:

composer require vectorial1024/alof-lib

包简介

PHP array-like object functions library.

README 文档

README

Packagist License Packagist Version Packagist Downloads PHP Dependency Version GitHub Actions Workflow Status GitHub Repo Stars readthedocs

Warning

Last Updated: 2026-04-21

THIS PROJECT IS ABANDONED AND ARCHIVED!

This project was created as an experimentation for a generic way to manipulate array-like objects in PHP. However, seeing the lack of community interest in this topic, this project has been abandoned and archived. Use at your own risk.

(This is a WIP project!)

PHP array-like object functions library ("alof-lib"). Type-hinted functions for array-like objects, just like those for native arrays. Think of this library as a polyfill of those useful functions for array-like objects, so that you may write clean code with array-like objects.

An array-like object ("ALO") is defined to be implements ArrayAccess and implements Traversable. Examples include:

A PHP array is NOT an ALO. It is still an array.

Latest version requires PHP 8.1+.

See the change log in the CHANGELOG.md file.

Want to easily process ALOs? See vectorial1024/transmutation here.

Notes and Disclaimers

  • ALO functions aim to be faithful user-land reproductions of their array function counterparts, but there might be slight differences between both sides
  • Some ALO functions may not make sense depending on your exact ALO implementation; use judgement before you use the ALO functions

Installation

via Composer:

composer require vectorial1024/alof_lib

Testing

This library uses PHPUnit for testing, which can be triggered from Composer. To test this library, run:

composer run-script test

Example Usage

Refer to the test cases under /tests for more examples, but for a minimal example:

use Vectorial1024\AlofLib\Alof;

$objKey = new stdClass();
$objKey->name = "foo";

// conveniently get the keys of the WeakMap (WeakMap becomes a "WeakHashSet" for objects)
$map = new WeakMap();
$map[$objKey] = "1";
$map[$objKey] = 2;
$map[$objKey] = "Hello World!";
$keys = Alof::alo_keys($map);
assert($keys === [$objKey]); // passes

// correctly get the keys of the SplObjectStorage (no more nasty foreach surprises!)
$splObjectStore = new SplObjectStorage();
$splObjectStore[$objKey] = "Hello World!";
$keys = Alof::alo_keys($splObjectStore);
assert($keys === [$objKey]); // passes

Relationship with transmutation

This library does the dirty work and ensures the correctness of ALO functions, while transmutation provides an easy-to-use API for ALO processing.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-11-23

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固