PHPackages                             mbretter/stk-immutable - 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. mbretter/stk-immutable

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

mbretter/stk-immutable
======================

Stk Immutable Data objects

2.1.0(2y ago)03.0k↓100%3BSD-3-ClausePHPPHP ^8.0CI failing

Since Sep 16Pushed 1y ago1 watchersCompare

[ Source](https://github.com/mbretter/stk-immutable)[ Packagist](https://packagist.org/packages/mbretter/stk-immutable)[ Docs](https://www.bretterklieber.com)[ RSS](/packages/mbretter-stk-immutable/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (8)Dependencies (3)Versions (9)Used By (3)

immutable data objects for php
==============================

[](#immutable-data-objects-for-php)

[![License](https://camo.githubusercontent.com/2b599ab1ace97388d4375b87919f92781a1a61d016fe640a5c4d15fc365deed1/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4253442d626c75652e737667)](https://opensource.org/licenses/BSD-3-Clause)[![PHP 8](https://camo.githubusercontent.com/1fb120b28c01242c7b808a19d88391780a96ce77b0e348ab4e8b51cbb585c394/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d382d79656c6c6f772e737667)](http://www.php.net)[![CI](https://github.com/mbretter/stk-immutable/actions/workflows/ci.yml/badge.svg)](https://github.com/mbretter/stk-immutable/actions/workflows/ci.yml/badge.svg)[![codecov](https://camo.githubusercontent.com/d49af33ea11d4bc3fa7a34012fe1ae989213cecdb3819093b186a113ff795f3b/68747470733a2f2f636f6465636f762e696f2f6769746875622f6d627265747465722f73746b2d696d6d757461626c652f6272616e63682f6d61737465722f67726170682f62616467652e7376673f746f6b656e3d52316879514857723155)](https://codecov.io/github/mbretter/stk-immutable)[![Latest Stable Version](https://camo.githubusercontent.com/b195711f33cb75c237f9b9fd1cfc56bbf85b8c6e212282e8bd845909c85a0c61/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d627265747465722f73746b2d696d6d757461626c652e737667)](https://packagist.org/packages/mbretter/stk-immutable)[![Total Downloads](https://camo.githubusercontent.com/3170cb3840db5f6672eda07b79c9089090a103edc6dfc7d9ad491f7874f9af50/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d627265747465722f73746b2d696d6d757461626c652e737667)](https://packagist.org/packages/mbretter/stk-immutable)

This library implements the immutable design pattern for objects holding some kind of data.

Maps
----

[](#maps)

Maps can hold objects (stdClass) and/or arrays, they can be nested, very useful when reading/writing from/to noSQL databases like MongoDB.

```
use Stk\Immutable\Map;

$a = new Map((object)['x' => 'foo', 'y' => 'bar']);
$b = $a->set('x', 'whatever');
```

Calling the set method on the object $a does not modify it, a clone with the modifications is returned instead, the original Map will never be modified.

Comparing two Maps is easy, there is no need for writing complicated and resource consuming comparision functions, simply use the identical operator:

```
if ($a === $b) {
    ...
}
```

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance27

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity68

Established project with proven stability

 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 ~198 days

Recently: every ~334 days

Total

8

Last Release

1037d ago

Major Versions

1.0.4 → 2.0.02021-02-26

PHP version history (2 changes)1.0.0PHP ^7.2

2.0.0PHP ^8.0

### Community

Maintainers

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

---

Top Contributors

[![mbretter](https://avatars.githubusercontent.com/u/1787808?v=4)](https://github.com/mbretter "mbretter (9 commits)")

---

Tags

immutablephpimmutablestk

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/mbretter-stk-immutable/health.svg)

```
[![Health](https://phpackages.com/badges/mbretter-stk-immutable/health.svg)](https://phpackages.com/packages/mbretter-stk-immutable)
```

###  Alternatives

[aeon-php/calendar

PHP type safe, immutable calendar library

2079.7M16](/packages/aeon-php-calendar)[qaribou/immutable.php

Immutable, highly-performant collections, well-suited for functional programming and memory-intensive applications.

344146.0k](/packages/qaribou-immutablephp)[innmind/immutable

Immutable PHP primitive wrappers

75218.0k73](/packages/innmind-immutable)[rtlopez/decimal

An object oriented immutable arbitrary-precision arithmetic library for PHP

27262.8k2](/packages/rtlopez-decimal)[aeon-php/calendar-holidays

Holidays calendar abstraction layer for Aeon Time management framework

14212.4k3](/packages/aeon-php-calendar-holidays)[aeon-php/business-hours

Abstraction allowing to define and check against business hours

10135.8k](/packages/aeon-php-business-hours)

PHPackages © 2026

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