PHPackages                             jdwx/iproxy - 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. jdwx/iproxy

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

jdwx/iproxy
===========

v0.0.2(3y ago)16PHPPHP ^8.0

Since Apr 6Pushed 3y ago1 watchersCompare

[ Source](https://github.com/jdwx/iproxy)[ Packagist](https://packagist.org/packages/jdwx/iproxy)[ RSS](/packages/jdwx-iproxy/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)DependenciesVersions (3)Used By (0)

iproxy
======

[](#iproxy)

This automatically generates the code for a PHP proxy trait for a given interface. The Proxy pattern allows incorporating functionality into a class without using inheritance. This is useful when extending an interface with multiple implementations that may need to be swapped out at runtime.

This is a very limited implementation of the "20% of the effort gives 80% of the results" variety. It works well for my needs, but there are known limitations, and probably some unknown ones.

- Does not (yet) support DNF types for arguments and return types.
- Does not (yet) support variadic functions.
- Does not (yet) support default values for arguments.
- Does not support interfaces that inherit from other interfaces. (This would be very challenging.)

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

[](#installation)

Via composer:

`composer require jdwx/iproxy`

This requires the [PHP AST extension](https://github.com/nikic/php-ast) to run, but generates new PHP source files that have no external dependencies.

Usage
-----

[](#usage)

Create a file (e.g. IFoo.php) with an interface to proxy:

```
