PHPackages                             stormmore/method-overloader - 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. stormmore/method-overloader

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

stormmore/method-overloader
===========================

1.0.1(1y ago)22PHP

Since Jan 9Pushed 1y ago1 watchersCompare

[ Source](https://github.com/stormmore-com/php-storm-method-overloader)[ Packagist](https://packagist.org/packages/stormmore/method-overloader)[ RSS](/packages/stormmore-method-overloader/feed)WikiDiscussions main Synced 1mo ago

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

Storm Method Overloader
=======================

[](#storm-method-overloader)

It's simple tool enabling overloading methods in convenient way by types and number of arguments like in other languages.

```
$userRepository = new UserRepository();
$userRepository->add('Michael','Jordan', 23);
$userRepository->add('Michael Jordan', 23);
$userRepository->add(new User("Michael", "Jordan", 23));
$userRepository->add(new Player("Michael", "Jordan", 23));
$userRepository->add(['fist_name' => 'Michael', 'last_name' => 'Jordan', 'number' => 23]);
```

### Installation

[](#installation)

```
composer require stormmore/method-overloader
```

### Usage

[](#usage)

Use `register` method to register overloaded methods with their arguments and run `invoke`.
In case of no proper method`InvalidArgumentException` will be thrown or you can define default behaviour with `onFailure` callback.

```
use \Storm\MethodOverload\MethodOverloader;

class UserRepository
{

    public function add(mixed ...$args): void
    {
            $addMethodOverloader = MethodOverloader::create($this)
            ->register($this->addByFirstNameLastNameAndNumber(...),'string', 'string', 'int')
            ->register($this->adddByUser(...), User::Class)
            ->register($this->addByPlayer(...), Player::class)
            ->register($this->addByArray(...), 'array')
            ->register($this->addNyNameAndNumber(...), 'string', 'int')
            ->onFailure(function() {
                throw new MyCustomException();
            });

        $addMethodOverloader->invoke($args);
    }

    private function addByFirstNameLastNameAndNumber(): void
    {
    }

    private function addNyNameAndNumber(string name, int number): void
    {
    }

    private function addByUser(User $user): void
    {
    }

    private function addByPlayer(Player $player): void
    {
    }

    private function addByArray($array): void
    {
    }
}
```

Supported types: `string`, `int`, `float`, `numeric`, `bool`, `array`, `resource`, `callable`, `object`, `mixed`, user defined class.

### Requiments

[](#requiments)

This library requires PHP 8.0 and above.

To use [`First class callabe syntax`](https://www.php.net/manual/en/functions.first_class_callable_syntax.php)

```
$callable = $object->methodName(...);
```

you will need php 8.1 and above.

Author
------

[](#author)

Michał Czerski

If you have any question or ideas you want share with me contact me on GitHub.

License
-------

[](#license)

StormMethodOverloader is licensed under MIT licence.

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance41

Moderate activity, may be stable

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity39

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.

###  Release Activity

Cadence

Every ~1 days

Total

2

Last Release

492d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/70d562b2d7b157638390d787ca8c83b449cf5dec1d0f65dbd4c1788a7aada744?d=identicon)[Stormmore](/maintainers/Stormmore)

---

Top Contributors

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

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/stormmore-method-overloader/health.svg)

```
[![Health](https://phpackages.com/badges/stormmore-method-overloader/health.svg)](https://phpackages.com/packages/stormmore-method-overloader)
```

PHPackages © 2026

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