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

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

phauthentic/rector-rules
========================

Rector Rules

02↓92.3%PHP

Since Mar 9Pushed 3mo agoCompare

[ Source](https://github.com/Phauthentic/Rector-Rules)[ Packagist](https://packagist.org/packages/phauthentic/rector-rules)[ RSS](/packages/phauthentic-rector-rules/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

Phauthentic Rector Rules
========================

[](#phauthentic-rector-rules)

Custom Rector rules for adding `final`/`readonly` modifiers and extracting interfaces based on FQCN regex patterns.

Requirements
------------

[](#requirements)

- PHP 8.2+
- Rector ^2.3

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

[](#installation)

```
composer require phauthentic/rector-rules
```

Rules
-----

[](#rules)

### AddFinalByRegexRector

[](#addfinalbyregexrector)

Adds `final` to classes whose fully qualified class name matches one of the configured regex patterns.

**Configuration:**

```
// rector.php
use Phauthentic\RectorRules\Rector\Class_\AddFinalByRegexRector;
use Rector\Config\RectorConfig;

return RectorConfig::configure()
    ->withPaths(['src'])
    ->withConfiguredRule(AddFinalByRegexRector::class, [
        '#^App\\\\Domain\\\\#',
        '#^App\\\\Service\\\\#',
    ]);
```

Or with explicit `patterns` key:

```
->withConfiguredRule(AddFinalByRegexRector::class, [
    'patterns' => ['#^App\\\\Domain\\\\#'],
])
```

### AddReadonlyByRegexRector

[](#addreadonlybyregexrector)

Adds `readonly` to classes whose FQCN matches one of the configured regex patterns. Requires PHP 8.2+.

**Configuration:**

```
use Phauthentic\RectorRules\Rector\Class_\AddReadonlyByRegexRector;

->withConfiguredRule(AddReadonlyByRegexRector::class, [
    '#^App\\\\ValueObject\\\\#',
])
```

### ExtractInterfaceByRegexRector

[](#extractinterfacebyregexrector)

Extracts methods from matching classes into interfaces and adds `implements` to the class. Creates interface files when missing.

**Configuration:**

```
use Phauthentic\RectorRules\Rector\Class_\ExtractInterfaceByRegexRector;

->withConfiguredRule(ExtractInterfaceByRegexRector::class, [
    'interface_name_template' => '{namespace}\\{shortName}Interface',
    'extract' => [
        [
            'class_regex' => '#^App\\\\Service\\\\#',
            'methods' => [
                'exact' => ['handle', 'supports'],
                'regex' => ['#^get[A-Z].*#'],
            ],
        ],
        [
            'class_regex' => '#^App\\\\Contract\\\\#',
            // methods omitted => extract all public methods (except __construct)
        ],
    ],
])
```

- **interface\_name\_template**: Optional. Placeholders: `{namespace}`, `{shortName}`. Default: `{namespace}\{shortName}Interface`
- **extract**: List of entries, each with:
    - **class\_regex**: Regex to match class FQCN
    - **methods**: Optional. If omitted, all public non-magic methods are extracted.
        - **exact**: List of exact method names
        - **regex**: List of regex patterns to match method names

Development
-----------

[](#development)

```
composer install
composer test
composer phpstan
```

###  Health Score

19

—

LowBetter than 9% of packages

Maintenance53

Moderate activity, may be stable

Popularity3

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity12

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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/4996022?v=4)[Florian Krämer](/maintainers/floriankraemer)[@floriankraemer](https://github.com/floriankraemer)

---

Top Contributors

[![floriankraemer](https://avatars.githubusercontent.com/u/4996022?v=4)](https://github.com/floriankraemer "floriankraemer (1 commits)")

### Embed Badge

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

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

PHPackages © 2026

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