Skip to content
This repository has been archived by the owner on Jul 8, 2023. It is now read-only.

Mocking problematic classes

Erin edited this page Feb 14, 2023 · 7 revisions

Some PHP classes can be difficult, if not impossible, to mock. This page lists classes that may cause issues when mocking with Phony.

Final classes

In general, classes marked as final cannot be mocked. However, if the class in question implements an interface, or extends another class that can be mocked, proxy mocks may be a workable solution.

Enumerations

Enumerations are marked final internally. See the section on Final classes for options.

Unsupported classes

Mocking of the following classes is not supported by Phony:

  • __PHP_Incomplete_Class
  • Closure (because it's final)

The Phony wiki is a place for documentation that may be frequently updated, or where updates do not necessarily coincide with a particular release.

These pages are only an addendum to the main documentation, which contains more detailed information.

Clone this wiki locally