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(7mo ago)01LGPL-3.0-or-laterPHPPHP ^8.1CI passing

Since Sep 29Pushed 7mo agoCompare

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

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

28

—

LowBetter than 54% of packages

Maintenance63

Regular maintenance activity

Popularity1

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity36

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

226d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/86be890d6b82e0a0048eeebc88672c30efa3ddc68982adfde0b54d8230d763dc?d=identicon)[dhaeckel](/maintainers/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)
```

###  Alternatives

[nystudio107/craft-disqus

Integrates the Disqus commenting system into Craft CMS websites, including Single Sign On (SSO) and custom login/logout URLs

1318.4k](/packages/nystudio107-craft-disqus)[kaitai-io/kaitai_struct_php_runtime

Kaitai Struct: runtime library for PHP

128.0k](/packages/kaitai-io-kaitai-struct-php-runtime)

PHPackages © 2026

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