PHPackages                             haeckel/generics - 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. haeckel/generics

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

haeckel/generics
================

Support for generic classes

0.2.0(9mo ago)01LGPL-3.0-or-laterPHPPHP ^8.1CI passing

Since Sep 29Pushed 9mo agoCompare

[ Source](https://github.com/dhaeckel/php-generics)[ Packagist](https://packagist.org/packages/haeckel/generics)[ RSS](/packages/haeckel-generics/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (6)Versions (4)Used By (0)

[![codecov](https://camo.githubusercontent.com/586066df625b81ba1e0fb2e92da6b21037fc906d5bc79e06ca3df4f383b35001/68747470733a2f2f636f6465636f762e696f2f67682f64686165636b656c2f7068702d67656e65726963732f67726170682f62616467652e7376673f746f6b656e3d514e515943324f383042)](https://codecov.io/gh/dhaeckel/php-generics)[![ci](https://github.com/dhaeckel/php-generics/actions/workflows/php.yml/badge.svg)](https://github.com/dhaeckel/php-generics/actions/workflows/php.yml)[![Static Badge](https://camo.githubusercontent.com/14995ff65edea59395c224e37e4fc66f91c1e601c1a58311e3c6f38c4fe37feb/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d6c6576656c2532306d61782d627269676874677265656e)](https://phpstan.org/user-guide/rule-levels)[![Static Badge](https://camo.githubusercontent.com/b4dd7de37447bf201a1b6bfa4758fb5e24cbf79eb4f9c412a7705ec1b17315bf/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d7374726963745f72756c65732d627269676874677265656e)](https://phpstan.org/user-guide/rule-levels#want-to-go-further%3F)[![Packagist License](https://camo.githubusercontent.com/bdd16a91b04c836797936a204ee42f7f0d9fad9ea73841abdd863abd708a1f81/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f686165636b656c2f67656e6572696373)](https://camo.githubusercontent.com/bdd16a91b04c836797936a204ee42f7f0d9fad9ea73841abdd863abd708a1f81/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f686165636b656c2f67656e6572696373)

haeckel/php-generics
====================

[](#haeckelphp-generics)

haeckel/generics is a php Library for dealing with generic data structures. It aims for simplicity and being fully typesafe at runtime, so unit tests will make errors visible. Uses PHPStan's generic syntax for type documentation and static analysis.

Features
--------

[](#features)

- [Types](src/Type) classes that denote php types for usage, where the native type system cannot be used, e.g. in terms of generics for parameters, because they violate the LSP rules. All type classes can be used to type check at runtime and you can get a string representation that matches the native php notation.
- [Filters](src/Filter) the filter interfaces enforce callable signatures, by specifying the \_\_invoke() method signature. These are used to filter generic data structures (e.g. find a subset of a collection) or to remove specific elements.
- [Struct](src/Struct/) contains standard data structures that support generic usage. There is always an interface and an abstract base class for these structures.

PHPStan
-------

[](#phpstan)

This project uses the max level of [PHPStan](https://phpstan.org/) and [phpstan/phpstan-strict-rules](https://github.com/phpstan/phpstan-strict-rules)to ensure the code follows a good standard. Here are the places, where @phpstan-ignore is used to step around a check (cf. unsafe mode in rust or go, where you can opt out of compiler guarantees).

- [equal.notAllowed (necessary for object cmp)](src/Struct/BaseCollection.php) in method remove()

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

[](#installation)

```
composer require haeckel/generics
```

Usage
-----

[](#usage)

See the tests Folder for runnable implementations.

Contributing
------------

[](#contributing)

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

[Source Code](https://github.com/dhaeckel/php-generics)

Support
-------

[](#support)

Let us know if you have issues.

[Issue Tracker](https://github.com/dhaeckel/php-generics/issues)

License
-------

[](#license)

[LGPL-3.0-or-later](COPYING.LESSER)

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance58

Moderate activity, may be stable

Popularity1

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

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

Total

2

Last Release

273d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/65503128?v=4)[dhaeckel](/maintainers/dhaeckel)[@dhaeckel](https://github.com/dhaeckel)

---

Top Contributors

[![dhaeckel](https://avatars.githubusercontent.com/u/65503128?v=4)](https://github.com/dhaeckel "dhaeckel (24 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/haeckel-generics/health.svg)

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

PHPackages © 2026

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