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

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

jcergolj/custom-rector-rules
============================

custom rector rules

v0.2(1y ago)0517MITPHP

Since Oct 9Pushed 1y ago1 watchersCompare

[ Source](https://github.com/jcergolj/custom-rector-rules)[ Packagist](https://packagist.org/packages/jcergolj/custom-rector-rules)[ RSS](/packages/jcergolj-custom-rector-rules/feed)WikiDiscussions master Synced 1mo ago

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

Custom Rector Rules
===================

[](#custom-rector-rules)

This package contains a custom rector rule.

#### Installation

[](#installation)

```
composer require jcergolj/custom-rector-rules
```

Add the following to the rector.php file

```
    // find or add withRules method
    ->withRules([
        // other rules
        \Jcergolj\CustomRectorRules\Rector\Rules\FixMissingCoverClassAttributeRector::class,
    ])
```

#### Add #CoversClass and #CoversMethod Attribute for each Feature or Unit test class, if missing

[](#add-coversclass-and-coversmethod-attribute-for-each-feature-or-unit-test-class-if-missing)

If you follow the convection to store test in the same namespace as the class that is being tested e.g. `App/Http/Controllers/UserController -> Tests/Features/Http/Controllers/UserControllerTest` this rule would add the #See attribute if missing referencing the App/Http/Controllers/UserController class.

Same rule applies for Unit tests.

My convection is to if there is a lot to test in CRUD controllers I split test according to methods e.g. `App/Http/Controllers/UserController/CreateTest`, App/Http/Controllers/UserController/UpdateTest and so forth. In this case the #See attribute references `App/Http/Controllers/UserController` class automatically.

```
// before
