PHPackages                             rector/argtyper - 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. rector/argtyper

ActiveLibrary

rector/argtyper
===============

Analyze real method argument types, and add them as type declarations

0.6.0(4mo ago)272.8k2[4 issues](https://github.com/rectorphp/argtyper/issues)[1 PRs](https://github.com/rectorphp/argtyper/pulls)11proprietaryPHPPHP &gt;=7.4CI passing

Since Aug 28Pushed 4mo ago2 watchersCompare

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

READMEChangelogDependencies (2)Versions (39)Used By (11)

Fill Parameter Types based on Passed Values
===========================================

[](#fill-parameter-types-based-on-passed-values)

There are often more known types in your project than meets the eye.
This tool detects the **real** types passed into method and function calls using PHPStan.

```
$this->hotelOverview->makeRoomAvailable(324);
```

Later in the code...

```
public function roomDetail(int $roomNumber)
{
    $this->hotelOverview->makeRoomAvailable($roomNumber);
}
```

Later in tests...

```
public function test(int $roomNumber): void
{
    $this->hotelOverview->makeRoomAvailable($roomNumber);
}
```

✅ Three times an `int` value is passed into `makeRoomAvailable()`.

Then [Rector](https://getrector.com) runs and fills in the missing type declarations:

```
 final class HotelOverview
 {
-    public function makeRoomAvailable($roomNumber)
+    public function makeRoomAvailable(int $roomNumber)
     {
     }
 }
```

✅ An `int` parameter type is added to the `makeRoomAvailable()` method.

That’s it.

Install
-------

[](#install)

```
composer require rector/argtyper --dev
```

Usage
-----

[](#usage)

Run it in your project directory:

```
vendor/bin/argtyper add-types .
```

Or on another project:

```
vendor/bin/argtyper add-types project
```

To see more details during the process, add the `--debug` option.

How It Works
------------

[](#how-it-works)

At first, a set of custom PHPStan rules scans your code and records the argument types passed to method calls, static calls, `new` expressions, and function calls. It stores this data in temporary `*.json` files in the following format:

```
[
    {
        "class": "HotelOverview",
        "method": "makeRoomAvailable",
        "position": 0,
        "type": "PHPStan\\Type\\IntegerType"
    }
]
```

Then, custom Rector rules go through the codebase and fill in the known parameter types based on the collected data — but only where they’re missing.

With a few exceptions:

- If multiple types are found → it’s skipped.
- If union or intersection types are found → it’s skipped as ambiguous.
- If a `float` parameter type is declared but only `int` arguments are passed (e.g. `30.0`) → it’s skipped to avoid losing decimal precision.

Verify the Results
------------------

[](#verify-the-results)

It’s not 100 % perfect, but in our tests it fills in about **95 %** of the data correctly and saves a huge amount of manual work.
You can fix the remaining cases manually based on PHPStan or test feedback.

Happy coding!

###  Health Score

45

—

FairBetter than 93% of packages

Maintenance73

Regular maintenance activity

Popularity33

Limited adoption so far

Community21

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 98.9% 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 ~24 days

Recently: every ~11 days

Total

37

Last Release

131d ago

PHP version history (4 changes)0.0.1PHP ^8.1

0.0.4PHP &gt;=7.2

0.1.0PHP ^8.2

0.5.13PHP &gt;=7.4

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/924196?v=4)[Tomas Votruba](/maintainers/TomasVotruba)[@TomasVotruba](https://github.com/TomasVotruba)

---

Top Contributors

[![TomasVotruba](https://avatars.githubusercontent.com/u/924196?v=4)](https://github.com/TomasVotruba "TomasVotruba (88 commits)")[![alleknalle](https://avatars.githubusercontent.com/u/5603434?v=4)](https://github.com/alleknalle "alleknalle (1 commits)")

### Embed Badge

![Health badge](/badges/rector-argtyper/health.svg)

```
[![Health](https://phpackages.com/badges/rector-argtyper/health.svg)](https://phpackages.com/packages/rector-argtyper)
```

###  Alternatives

[larastan/larastan

Larastan - Discover bugs in your code without running it. A phpstan/phpstan extension for Laravel

6.4k43.5M5.2k](/packages/larastan-larastan)[phpstan/phpstan-doctrine

Doctrine extensions for PHPStan

66766.6M1.1k](/packages/phpstan-phpstan-doctrine)[ssch/typo3-rector

Instant fixes for your TYPO3 PHP code by using Rector.

2592.8M263](/packages/ssch-typo3-rector)[ticketswap/phpstan-error-formatter

A minimalistic error formatter for PHPStan

87578.8k35](/packages/ticketswap-phpstan-error-formatter)[savinmikhail/add_named_arguments_rector

Rector rule to add names to arguments for functions'/methods' calls

1969.5k3](/packages/savinmikhail-add-named-arguments-rector)

PHPackages © 2026

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