PHPackages                             grikdotnet/z-unfinal - 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. grikdotnet/z-unfinal

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

grikdotnet/z-unfinal
====================

Library allows converting final classes to non-final, abstract to non-abstract, and adding traits

v1.0(10mo ago)12MITPHPPHP &gt;=8.0

Since Nov 5Pushed 10mo ago1 watchersCompare

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

READMEChangelogDependencies (1)Versions (12)Used By (0)

Z-Engine Unfinal
================

[](#z-engine-unfinal)

**This is a partial fork of the [z-engine](https://github.com/lisachenko/z-engine) library, compatibile with PHP 8.4.**

This package allows you to:

- Extend final classes
- Create instances of abstract classes
- Add traits to existing classes dynamically

Intended Use Cases
------------------

[](#intended-use-cases)

- **Unit Testing:**
    - Mock or extend classes declared as `final` or `abstract` in your tests.
    - Enable mocking frameworks to work with classes that would otherwise be unmockable.
- **Dynamic Trait Injection:**
    - Augment class functionality for testing
    - Implement behaviors such as "friendly" classes that access each other's protected methods.

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

[](#installation)

```
composer require --dev grikdotnet/z-unfinal
```

Examples:
---------

[](#examples)

### Extend a final class

[](#extend-a-final-class)

```
use ZEngine\Core;
use ZEngine\Reflection\ReflectionClass;

Core::init();

// Get reflection for a final class
$reflectionClass = new ReflectionClass(FinalClass::class);

// Remove the final flag
$reflectionClass->setFinal(false);

// Now you can extend the class in your tests
class ExtendedClass extends FinalClass {
    // Test-specific functionality
}
```

### Create an instance of an abstract class

[](#create-an-instance-of-an-abstract-class)

```
use ZEngine\Core;
use ZEngine\Reflection\ReflectionClass;

Core::init();

$reflectionClass = new ReflectionClass(AbstractClass::class);
$reflectionClass->setAbstract(false);

// Now you can create an instance of the abstract class
$instance = new AbstractClass();
```

### Dynamically Add Traits to a Class

[](#dynamically-add-traits-to-a-class)

```
use ZEngine\Core;
use ZEngine\Reflection\ReflectionClass;

Core::init();

$reflectionClass = new ReflectionClass(TargetClass::class);
$reflectionClass->addTraits(SomeTrait::class);

// Now TargetClass has all methods from SomeTrait
(new TestClass())->traitMethod()
```

License
-------

[](#license)

MIT. See [LICENSE](LICENSE) for details.

---

Original project: [lisachenko/z-engine](https://github.com/lisachenko/z-engine)

Pre-requisites and initialization
---------------------------------

[](#pre-requisites-and-initialization)

- PHP 8 or higher, x64 non-thread-safe version
- FFI extension enabled
- To use in fcgi mode, call `Core::preload()` in your script specified by `opcache.preload`. Check `preload.php` for an example.

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance54

Moderate activity, may be stable

Popularity4

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor1

Top contributor holds 94.3% 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 ~259 days

Recently: every ~488 days

Total

9

Last Release

308d ago

Major Versions

0.9.1 → v1.02025-07-14

PHP version history (3 changes)0.5.0PHP ~7.4

0.9.0PHP 8.0.\*

v1.0PHP &gt;=8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/2fed4bdab3645292e4fa5e0bd12054f33e15c82b059bccd06b711be009f76d55?d=identicon)[grikdotnet](/maintainers/grikdotnet)

---

Top Contributors

[![lisachenko](https://avatars.githubusercontent.com/u/640114?v=4)](https://github.com/lisachenko "lisachenko (164 commits)")[![grikdotnet](https://avatars.githubusercontent.com/u/1154121?v=4)](https://github.com/grikdotnet "grikdotnet (5 commits)")[![dependabot-preview[bot]](https://avatars.githubusercontent.com/in/2141?v=4)](https://github.com/dependabot-preview[bot] "dependabot-preview[bot] (2 commits)")[![szepeviktor](https://avatars.githubusercontent.com/u/952007?v=4)](https://github.com/szepeviktor "szepeviktor (2 commits)")[![MateuszJozwik1](https://avatars.githubusercontent.com/u/20594715?v=4)](https://github.com/MateuszJozwik1 "MateuszJozwik1 (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/grikdotnet-z-unfinal/health.svg)

```
[![Health](https://phpackages.com/badges/grikdotnet-z-unfinal/health.svg)](https://phpackages.com/packages/grikdotnet-z-unfinal)
```

###  Alternatives

[larapack/hooks

A Laravel Hook system

2171.5M21](/packages/larapack-hooks)[himiklab/yii2-sortable-grid-view-widget

Sortable modification of standard Yii2 GridView widget

80351.1k7](/packages/himiklab-yii2-sortable-grid-view-widget)[torann/hashids

Laravel package for Hashids

54335.1k](/packages/torann-hashids)[wapmorgan/binary-stream

A handy tool for working with binary data

52263.1k6](/packages/wapmorgan-binary-stream)[tomaj/hermes

Simple php background processing library

38251.0k5](/packages/tomaj-hermes)[smile/module-store-delivery

Smile Store Delivery

23348.7k1](/packages/smile-module-store-delivery)

PHPackages © 2026

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