PHPackages                             awesomite/mock-finals - 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. awesomite/mock-finals

ActiveLibrary

awesomite/mock-finals
=====================

Mocking final classes and methods

v1.0.1(5y ago)1013MITPHPPHP ^7.1

Since Jul 19Pushed 5y agoCompare

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

READMEChangelog (2)Dependencies (1)Versions (3)Used By (0)

[![Build Status](https://github.com/awesomite/mock-finals/workflows/Tests/badge.svg?branch=master)](https://github.com/awesomite/mock-finals/actions?query=workflow%3ATests)

Mock Finals
===========

[](#mock-finals)

Mock final classes and methods in your tests. Library overrides existing class loaders and removes all `final`occurrences in runtime using [`uopz_flags`](https://www.php.net/manual/en/function.uopz-flags.php).

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

[](#installation)

```
composer require --dev awesomite/mock-finals

```

Requirements
------------

[](#requirements)

- PHP ^7.1
- [uopz](https://www.php.net/manual/en/book.uopz.php) (`pecl install uopz`)

Use cases
---------

[](#use-cases)

In general, it's a bad practice to do so. However it may be helpful when you have to deal with legacy code or third party libraries. Please read [the following article](https://ocramius.github.io/blog/when-to-declare-classes-final/) to understand how to properly deal with `final` keyword in your code.

Example
-------

[](#example)

```
class Greeter
{
    final public function sayHello(): string
    {
        return 'hello';
    }
}

class MyTest extends \PHPUnit\Framework\TestCase
{
    public function testSayHello(): void
    {
        $mock = $this->getMockBuilder(Greeter::class)->getMock();
        $mock
            ->expects($this->once())
            ->method('sayHello')
            ->willReturn('goodbye')
        ;
        $this->assertSame('goodbye', $mock->sayHello());
    }
}
```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity51

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

Total

2

Last Release

2114d ago

### Community

Maintainers

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

---

Top Contributors

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

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/awesomite-mock-finals/health.svg)

```
[![Health](https://phpackages.com/badges/awesomite-mock-finals/health.svg)](https://phpackages.com/packages/awesomite-mock-finals)
```

PHPackages © 2026

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