Download the PHP package athwari/laravel-method-overrider without Composer
On this page you can find all versions of the php package athwari/laravel-method-overrider. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download athwari/laravel-method-overrider
More information about athwari/laravel-method-overrider
Files in athwari/laravel-method-overrider
Package laravel-method-overrider
Short Description Runtime method interception and overriding for Laravel
License MIT
Homepage https://github.com/athwari/laravel-method-overrider
Informations about the package laravel-method-overrider
Laravel Method Overrider
Runtime method interception and overriding for Laravel applications.
This package allows you to override instance and static methods on a class at runtime by generating a proxy class that delegates to an implementation closure.
Installation
Install the package with Composer:
Laravel package auto-discovery is supported, so the service provider and facade are registered automatically.
Configuration
Publish the configuration file:
The published config file is located at config/method-overrider.php.
Default configuration
ignore_final_methods: whentrue, final methods are skipped during override generation instead of throwing an exception.
Usage
Use the MethodOverrider facade to override methods on a target class.
Override a method
Override multiple methods
Supported method signatures
The package supports:
- nullable and union parameter types
- variadic parameters
- reference parameters
- static methods
- return types
Final methods are skipped when ignore_final_methods is enabled.
Exceptions
The package throws exceptions for invalid usage:
Athwari\MethodOverrider\Exceptions\ClassNotFoundExceptionAthwari\MethodOverrider\Exceptions\MethodNotFoundExceptionAthwari\MethodOverrider\Exceptions\InvalidImplementationException
Testing
Run the test suite with Pest:
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Credits
- athwari
- All Contributors
License
The package is open-source software licensed under the MIT License. Please see License File for more information.