PHPackages                             vectorial1024/alof-lib - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. vectorial1024/alof-lib

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

vectorial1024/alof-lib
======================

PHP array-like object functions library.

0.1.1(1y ago)05[1 issues](https://github.com/Vectorial1024/alof-lib/issues)MITPHPPHP ^8.1

Since Nov 23Pushed 1y ago1 watchersCompare

[ Source](https://github.com/Vectorial1024/alof-lib)[ Packagist](https://packagist.org/packages/vectorial1024/alof-lib)[ RSS](/packages/vectorial1024-alof-lib/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (1)Versions (4)Used By (0)

alof-lib
========

[](#alof-lib)

[![Packagist License](https://camo.githubusercontent.com/6277bc67a9ff405302db32e853fb16369f32e8e355946a504c271468539e040e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f766563746f7269616c313032342f616c6f662d6c69623f7374796c653d706c6173746963)](https://packagist.org/packages/vectorial1024/alof-lib)[![Packagist Version](https://camo.githubusercontent.com/43e93250365a3944ebea518d84fd5ca7437a743d27f3b428d90fc1349b09035d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f766563746f7269616c313032342f616c6f662d6c69623f7374796c653d706c6173746963)](https://packagist.org/packages/vectorial1024/alof-lib)[![Packagist Downloads](https://camo.githubusercontent.com/64da0e36eca41599e002ee1e489854fb1cad448df03d16fac70f610f15fe8c28/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f766563746f7269616c313032342f616c6f662d6c69623f7374796c653d706c6173746963)](https://packagist.org/packages/vectorial1024/alof-lib/stats)[![PHP Dependency Version](https://camo.githubusercontent.com/4c744c6ef0cc496f7dd6d46220b429b4dbb19675669369bcad3adb582fdd3870/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f766563746f7269616c313032342f616c6f662d6c69622f7068703f7374796c653d706c6173746963266c6162656c3d504850)](https://packagist.org/packages/vectorial1024/alof-lib)[![GitHub Actions Workflow Status](https://camo.githubusercontent.com/858fea8b941a5c194301c601a9371312753f48f6cce87802c7807c4b2587db6a/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f566563746f7269616c313032342f616c6f662d6c69622f7068702e796d6c3f7374796c653d706c6173746963)](https://github.com/Vectorial1024/alof-lib/actions/workflows/php.yml)[![GitHub Repo Stars](https://camo.githubusercontent.com/55810973dc080bf4463cc62a1197cc8ba53007ce94a9ce4ba11e9db6e0b8a275/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f766563746f7269616c313032342f616c6f662d6c6962)](https://github.com/Vectorial1024/alof-lib)[![readthedocs](https://camo.githubusercontent.com/bc7292e8f704a9f7da538c19fbedc414cd3cc1825ac7b719a850a6297255691d/68747470733a2f2f72656164746865646f63732e6f72672f70726f6a656374732f616c6f662d6c69622f62616467652f3f76657273696f6e3d6c6174657374)](https://alof-lib.readthedocs.io/en/latest/?badge=latest)

(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](https://www.php.net/manual/en/ref.array.php). 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:

- [ArrayObject](https://www.php.net/manual/en/class.arrayobject.php) (since PHP 5)
- [ArrayIterator](https://www.php.net/manual/en/class.arrayiterator.php) (since PHP 5)
- [SplObjectStorage](https://www.php.net/manual/en/class.splobjectstorage.php) (since PHP 5.1)
- [SplDoublyLinkedList](https://www.php.net/manual/en/class.spldoublylinkedlist.php) (since PHP 5.3)
- [SplFixedArray](https://www.php.net/manual/en/class.splfixedarray.php) (since PHP 5.3)
- [SplStack](https://www.php.net/manual/en/class.splstack.php) (since PHP 5.3)
- [SplQueue](https://www.php.net/manual/en/class.splqueue.php) (since PHP 5.3)
- [WeakMap](https://www.php.net/manual/en/class.weakmap.php) (since PHP 8)
- ... and perhaps more

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](https://github.com/Vectorial1024/transmutation).

Notes and Disclaimers
---------------------

[](#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
------------

[](#installation)

via Composer:

```
composer require vectorial1024/alof_lib
```

Testing
-------

[](#testing)

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

```
composer run-script test
```

Example Usage
-------------

[](#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`
---------------------------------

[](#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.

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance38

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~174 days

Total

3

Last Release

554d ago

PHP version history (2 changes)0.1.0PHP &gt;=8.1

0.1.1PHP ^8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/c11ba39366ac06b348619a7db14816075a374a8dd6895cbb7016892507dab5bc?d=identicon)[Vectorial1024](/maintainers/Vectorial1024)

---

Top Contributors

[![Vectorial1024](https://avatars.githubusercontent.com/u/17726797?v=4)](https://github.com/Vectorial1024 "Vectorial1024 (69 commits)")

---

Tags

arrayaccessphpphp8traversableutilitylibraryarrayobjectsplfixedarrayArrayAccessweakmaptraversableSplObjectStoragearrayiterator

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/vectorial1024-alof-lib/health.svg)

```
[![Health](https://phpackages.com/badges/vectorial1024-alof-lib/health.svg)](https://phpackages.com/packages/vectorial1024-alof-lib)
```

###  Alternatives

[nette/utils

🛠 Nette Utils: lightweight utilities for string &amp; array manipulation, image handling, safe JSON encoding/decoding, validation, slug or strong password generating etc.

2.1k394.3M1.5k](/packages/nette-utils)[league/iso3166

ISO 3166-1 PHP Library

69536.3M116](/packages/league-iso3166)[maciejczyzewski/bottomline

A full-on PHP manipulation utility belt that provides support for working with arrays, objects, and iterables; a lodash or underscore equivalent for PHP.

477631.4k10](/packages/maciejczyzewski-bottomline)[phpcsstandards/phpcsutils

A suite of utility functions for use with PHP\_CodeSniffer

6233.4M58](/packages/phpcsstandards-phpcsutils)[me-io/php-lodash

A full-on PHP manipulation utility-belt that provides support for the usual functional.

38100.0k](/packages/me-io-php-lodash)[kisma/kisma

PHP Utility Belt

178.5k8](/packages/kisma-kisma)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
