PHPackages                             aldemeery/enum-polyfill - 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. aldemeery/enum-polyfill

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

aldemeery/enum-polyfill
=======================

A Polyfill for the SplEnum type in PHP

v1.0.2(1y ago)1156.6k↓33.6%MITPHPPHP &gt;=7.1

Since Nov 18Pushed 1y ago1 watchersCompare

[ Source](https://github.com/aldemeery/enum-polyfill)[ Packagist](https://packagist.org/packages/aldemeery/enum-polyfill)[ RSS](/packages/aldemeery-enum-polyfill/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)DependenciesVersions (4)Used By (0)

SplEnum
=======

[](#splenum)

Warning

PHP 8.1 introduced native Enumerations (Enums), providing a modern, more efficient approach. This package is intended for projects that rely on `SplEnum` and need backward compatibility or cannot upgrade to PHP 8.1+.

If possible, consider using PHP's native enums for improved type safety, performance, and maintainability.

This package is a polyfill for the now-unsupported `SplEnum` class, originally part of the [PECL SPL\_Types extension](http://pecl.php.net/package/SPL_Types).

By using this polyfill, you can emulate the `SplEnum` behavior in PHP without relying on the extension, which is no longer actively maintained.

The `SplEnum` class provides a way to create enumeration-like objects natively in PHP, offering a structured and type-safe way to work with predefined constant values.

Example
-------

[](#example)

```

```

The above example will output

```
6
Value '13' is not part of the enum Month

```

Class sypnosis
--------------

[](#class-sypnosis)

```
abstract class SplEnum
{
    /* Constants */
    const NULL __default = NULL ;

    /* Methods */
    SplType::__construct ([ mixed $initial_value ] )

    public array getConstList ([ bool $include_default = FALSE ] )

}
```

Predefined Constants
--------------------

[](#predefined-constants)

```
/* The default value of the enum */
SplEnum::__default
```

Methods
-------

[](#methods)

#### SplType::\_\_construct

[](#spltype__construct)

The `SplEnum` constructor.

```
SplType::__construct ([ mixed $initial_value ] )
```

#### Parameters

[](#parameters)

`initial_value`The initial value of the enum.

#### Errors/Exceptions

[](#errorsexceptions)

Throws an `UnexpectedValueException` if incompatible type is given.

---

#### SplEnum::getConstList

[](#splenumgetconstlist)

Returns all the consts as an array

```
public array SplEnum::getConstList ([ bool $include_default = false ] )
```

#### Parameters

[](#parameters-1)

`include_default`Whether to include \_\_default property.

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance37

Infrequent updates — may be unmaintained

Popularity35

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

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

Total

3

Last Release

570d ago

PHP version history (2 changes)v1.0.0PHP ^7.1

v1.0.1PHP &gt;=7.1

### Community

Maintainers

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

---

Top Contributors

[![aldemeery](https://avatars.githubusercontent.com/u/25695783?v=4)](https://github.com/aldemeery "aldemeery (3 commits)")

---

Tags

enumenum-polyfillphppolyfillspl-typessplenumenumenumerationsplenumSplType

### Embed Badge

![Health badge](/badges/aldemeery-enum-polyfill/health.svg)

```
[![Health](https://phpackages.com/badges/aldemeery-enum-polyfill/health.svg)](https://phpackages.com/packages/aldemeery-enum-polyfill)
```

###  Alternatives

[marc-mabe/php-enum

Simple and fast implementation of enumerations with native PHP

49644.8M97](/packages/marc-mabe-php-enum)[cerbero/enum

Zero-dependencies package to supercharge enum functionalities.

359207.5k2](/packages/cerbero-enum)[garoevans/php-enum

Convenient way to always have an Enum object available and utilise Spl Types if available.

19158.8k5](/packages/garoevans-php-enum)[cerbero/laravel-enum

Laravel package to supercharge enum functionalities.

18989.6k](/packages/cerbero-laravel-enum)[emreyarligan/enum-concern

A PHP package for effortless Enumeration handling with Laravel Collections 📦 ✨

21156.3k1](/packages/emreyarligan-enum-concern)[rexlabs/enum

Enumeration (enum) implementation for PHP

48482.2k2](/packages/rexlabs-enum)

PHPackages © 2026

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