PHPackages                             slpxxv/stdlib - 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. slpxxv/stdlib

ActiveLibrary

slpxxv/stdlib
=============

An extension to the Standard PHP Library (SPL), introducing abstract data types like stacks, maps, and hash maps. Enjoy the benefits of class-based functions in PHP with an intuitive and object-oriented API.

3.0.0(today)02↑2900%MITPHPPHP &gt;= 8.2CI failing

Since Oct 15Pushed today1 watchersCompare

[ Source](https://github.com/slpxxv/stdlib)[ Packagist](https://packagist.org/packages/slpxxv/stdlib)[ GitHub Sponsors](https://github.com/slpxxv)[ RSS](/packages/slpxxv-stdlib/feed)WikiDiscussions master Synced today

READMEChangelog (7)Dependencies (5)Versions (8)Used By (0)

slpxxv/stdlib
=============

[](#slpxxvstdlib)

**StdLib** is an extension to the Standard PHP Library (SPL), introducing abstract data types like stacks, maps, and hash maps. Enjoy the benefits of class-based functions in PHP with an intuitive and object-oriented API.

Features
--------

[](#features)

- **Extended Abstract Data Types**: Augment your PHP experience with extended abstract data types, such as stacks, maps, and hash maps, providing powerful and versatile tools for data manipulation.
- **Class-Based Functions: Enjoy** the benefits of PHP class-based functions, offering a more organized and object-oriented approach to handling various tasks.
- **Object-Oriented API**: Leverage an intuitive and object-oriented API for seamless integration and utilization of the extended SPL features.

Installation
------------

[](#installation)

Install the Standard Library for PHP using [Composer](https://getcomposer.org/):

```
composer require slpxxv/stdlib
```

Collections
-----------

[](#collections)

`ArrayCollection` preserves keys and provides non-mutating functional operations:

```
use Slpxxv\Stdlib\ArrayCollection;

$values = ArrayCollection::fromIterable(['a' => 1, 'b' => 2, 'c' => 3]);

$result = $values
    ->filter(static fn(int $value): bool => $value > 1)
    ->map(static fn(int $value): int => $value * 10);

$result->toArray(); // ['b' => 20, 'c' => 30]
```

`StdArray` remains available as a compatibility layer. New code should prefer `ArrayCollection` and `isEmpty()` over `StdArray` and `empty()`.

Maps and sets
-------------

[](#maps-and-sets)

Maps distinguish a missing key from a key containing `null`:

```
use Slpxxv\Stdlib\Map\Map;

$map = new Map(['answer' => null]);

$map->has('answer');       // true
$map->get('answer', 42);   // null
$map->get('missing', 42);  // 42
$map->require('missing');  // KeyNotFoundException
```

Sets reject duplicate values and support standard set operations:

```
use Slpxxv\Stdlib\Set\Set;

$left = new Set([1, 2]);
$right = new Set([2, 3]);

$left->union($right)->all();     // [1, 2, 3]
$left->intersect($right)->all(); // [2]
$left->diff($right)->all();      // [1]
```

Lazy sequences
--------------

[](#lazy-sequences)

`LazySequence` evaluates its source only during iteration:

```
use Slpxxv\Stdlib\LazySequence;

$lines = new LazySequence(static function (): iterable {
    $file = new SplFileObject('large.csv');

    foreach ($file as $line) {
        yield $line;
    }
});

$firstTenNonEmptyLines = $lines
    ->filter(static fn(string $line): bool => trim($line) !== '')
    ->take(10)
    ->toArray();
```

The factory is called for each iteration. Pass a factory instead of a bare `Iterator` when the source needs to be repeatable.

XML
---

[](#xml)

Canonicalization algorithms have a typed representation:

```
use Slpxxv\Stdlib\XML\CanonicalizationAlgorithm;
use Slpxxv\Stdlib\XML\XmlCanonicalizer;

$canonicalXml = XmlCanonicalizer::canonicalize(
    $document,
    CanonicalizationAlgorithm::Exclusive,
);
```

`DOMDocumentFactory` disables network access by default, rejects `DOCTYPE`, and restores the global libxml error state after success or failure.

Development
-----------

[](#development)

```
composer install
composer check
```

Development commands:

```
composer cs:check         # coding standard
composer cs:fix           # automatically fix formatting
composer analyse          # Psalm level 1
composer test             # PHPUnit
composer test-coverage    # coverage report in build/
composer refactor:check   # Rector dry run
composer refactor         # apply Rector refactorings
composer security:check   # Composer security audit
composer check:all        # all non-mutating checks
composer mutation         # Infection mutation tests
```

Rector is installed with project dependencies. Infection should be installed as an isolated PHAR or global tool because Composer releases compatible with PHP 8.1 conflict with the parser versions required by the current PHPUnit and Psalm. The official Infection PHAR is the recommended distribution:

```
phive install infection
# or install the verified infection.phar and expose it as `infection`
```

The repository includes `.editorconfig`, `rector.php` and `infection.json5`, so editors and tools use the same project settings locally and in CI.

License
-------

[](#license)

The MIT License (MIT). Please see [License](LICENSE.md) for more information.

###  Health Score

46

—

FairBetter than 92% of packages

Maintenance100

Actively maintained with recent releases

Popularity3

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 94.6% 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 ~172 days

Recently: every ~228 days

Total

7

Last Release

0d ago

Major Versions

v1.1.0 → 2.0.02024-02-15

2.3.0 → 3.0.02026-08-14

PHP version history (3 changes)2.0.0PHP 8.1.0 || ~8.2.0 || ~8.3.0

2.2.0PHP &gt;= 8.1

3.0.0PHP &gt;= 8.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/10816981?v=4)[Dominik Szamburski](/maintainers/slpxxv)[@slpxxv](https://github.com/slpxxv)

---

Top Contributors

[![slpxxv](https://avatars.githubusercontent.com/u/10816981?v=4)](https://github.com/slpxxv "slpxxv (70 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (2 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (2 commits)")

---

Tags

php-libraryphp8spl

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm, Rector

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/slpxxv-stdlib/health.svg)

```
[![Health](https://phpackages.com/badges/slpxxv-stdlib/health.svg)](https://phpackages.com/packages/slpxxv-stdlib)
```

PHPackages © 2026

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