PHPackages                             idimsh/better-bypass-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. [Testing &amp; Quality](/categories/testing)
4. /
5. idimsh/better-bypass-finals

AbandonedArchivedLibrary[Testing &amp; Quality](/categories/testing)

idimsh/better-bypass-finals
===========================

Removes final keyword from source code on-the-fly and allows mocking of final methods and classes

03.0kPHP

Since Oct 4Pushed 5y ago1 watchersCompare

[ Source](https://github.com/idimsh/better-bypass-finals)[ Packagist](https://packagist.org/packages/idimsh/better-bypass-finals)[ RSS](/packages/idimsh-better-bypass-finals/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependenciesVersions (1)Used By (0)

Bypass Finals
=============

[](#bypass-finals)

[![Downloads this Month](https://camo.githubusercontent.com/dab511a9a6e66eb6c8cb4cb3046f1e8939569f700c4c1e198e364116dba67713/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f6964696d73682f6265747465722d6279706173732d66696e616c732e737667)](https://packagist.org/packages/idimsh/better-bypass-finals)[![Build Status](https://camo.githubusercontent.com/165ee6a2b21c49d039292d12237a2b60efd26002a492b800d0cbd875b2599a17/68747470733a2f2f7472617669732d63692e6f72672f6964696d73682f6265747465722d6279706173732d66696e616c732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/idimsh/better-bypass-finals)[![License](https://camo.githubusercontent.com/fa7d5fcf2c84b580327af52da95dd751703af65f079dc3c5a0081beac0789718/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4e65772532304253442d626c75652e737667)](https://github.com/idimsh/better-bypass-finals/blob/master/license.md)

\#Introduction (idimsh) This is a redistribution of the famous package [bypass-finals](https://github.com/dg/bypass-finals/) with minor modifications that includes:

- making it inheritance ready, allowing subclasses of the main class to continue working.
- code style uses spaces instead of tabs.
- tests are not using Nette Tester, but PHPUnit

The original license remains untouched, and they are BSD and GNU both.
The reason for creating this package is an un answered pull request.

Introduction
------------

[](#introduction)

Removes final keywords from source code on-the-fly and allows mocking of final methods and classes. It can be used together with any test tool such as PHPUnit, Mockery or [Nette Tester](https://tester.nette.org).

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

[](#installation)

The recommended way to install is through Composer:

```
composer require idimsh/better-bypass-finals --dev

```

It requires PHP version 7.1 and supports PHP up to 8.0.

Usage
-----

[](#usage)

Simply call this:

```
\idimsh\BypassFinals::enable();
```

or

```
\idimsh\BypassFinalsCatcher::enable();
```

You need to enable it before the classes you want to remove the final are loaded. So call it as soon as possible, preferably right after `vendor/autoload.php` in loaded.

Note that final internal PHP classes like `Closure` cannot be mocked.

You can choose to only bypass finals in specific files or directories:

```
idimsh\BypassFinals::setWhitelist([
    '*/Nette/*',
]);
```

This gives you finer control and can solve issues with certain frameworks and libraries.

There is also a PHP Unit listener available for usage inside `phpunit.xml` file, like:

```

```

### The *Catcher* version

[](#the-catcher-version)

The extension of the main class with the name: `\idimsh\BypassFinalsCatcher`Will catch syntax errors and echo the file name to STDERR. This is useful for tests that span thousand files, the default behaviour was a silent fatal parse error that does not report the file name.

There is also a listener that uses the catcher.

```

```

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity32

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/6051f256445126a33260284644052c0eafa146bb2877bdd46522a280676e3ccd?d=identicon)[idimsh](/maintainers/idimsh)

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/idimsh-better-bypass-finals/health.svg)

```
[![Health](https://phpackages.com/badges/idimsh-better-bypass-finals/health.svg)](https://phpackages.com/packages/idimsh-better-bypass-finals)
```

###  Alternatives

[dms/phpunit-arraysubset-asserts

This package provides ArraySubset and related asserts once deprecated in PHPUnit 8

14228.7M340](/packages/dms-phpunit-arraysubset-asserts)[orchestra/workbench

Workbench Companion for Laravel Packages Development

8219.1M69](/packages/orchestra-workbench)[phpbenchmark/phpbenchmark

Easy to use benchmark toolkit for your PHP-application. This library contains classes for comparing algorithms as well as benchmarking application responses

8011.5k2](/packages/phpbenchmark-phpbenchmark)

PHPackages © 2026

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