An open API service indexing awesome lists of open source software.

https://github.com/eliashaeussler/rector-config

🏡 My personal configuration for Rector
https://github.com/eliashaeussler/rector-config

config rector

Last synced: 11 months ago
JSON representation

🏡 My personal configuration for Rector

Awesome Lists containing this project

README

          

# Rector config

[![Coverage](https://img.shields.io/coverallsCoverage/github/eliashaeussler/rector-config?logo=coveralls)](https://coveralls.io/github/eliashaeussler/rector-config)
[![Maintainability](https://img.shields.io/codeclimate/maintainability/eliashaeussler/rector-config?logo=codeclimate)](https://codeclimate.com/github/eliashaeussler/rector-config/maintainability)
[![CGL](https://img.shields.io/github/actions/workflow/status/eliashaeussler/rector-config/cgl.yaml?label=cgl&logo=github)](https://github.com/eliashaeussler/rector-config/actions/workflows/cgl.yaml)
[![Tests](https://img.shields.io/github/actions/workflow/status/eliashaeussler/rector-config/tests.yaml?label=tests&logo=github)](https://github.com/eliashaeussler/rector-config/actions/workflows/tests.yaml)
[![Supported PHP Versions](https://img.shields.io/packagist/dependency-v/eliashaeussler/rector-config/php?logo=php)](https://packagist.org/packages/eliashaeussler/rector-config)

This package contains basic [Rector](https://github.com/rectorphp/rector)
config for use in my personal projects. It is not meant to be used anywhere else.
I won't provide support and don't accept pull requests for this repo.

## 🔥 Installation

[![Packagist](https://img.shields.io/packagist/v/eliashaeussler/rector-config?label=version&logo=packagist)](https://packagist.org/packages/eliashaeussler/rector-config)
[![Packagist Downloads](https://img.shields.io/packagist/dt/eliashaeussler/rector-config?color=brightgreen)](https://packagist.org/packages/eliashaeussler/rector-config)

```bash
composer require --dev eliashaeussler/rector-config
```

## ⚡ Usage

```php
# rector.php

use EliasHaeussler\RectorConfig\Config\Config;
use EliasHaeussler\RectorConfig\Set\CustomSet;
use Rector\Config\RectorConfig;
use Rector\Php80\Rector\Class_\AnnotationToAttributeRector;
use Rector\Set\ValueObject\SetList;
use Rector\ValueObject\PhpVersion;

return static function (RectorConfig $rectorConfig): void {
// Optional: Configure PHP version explicitly
// Can be left out to use the current environment's PHP version
$phpVersion = PhpVersion::PHP_81;

// Create config from Rector config object
$config = Config::create($rectorConfig, $phpVersion)->in(
__DIR__.'/src',
__DIR__.'/tests',
);

// Skip specific paths
$config->not(
__DIR__.'/src/lib',
__DIR__.'/tests/test-application/vendor',
);

// Include default PHPUnit sets
$config->withPHPUnit();

// Include default Symfony sets
$config->withSymfony();

// Include default TYPO3 sets
$config->withTYPO3();

// Include custom sets
$config->withSets(
new CustomSet(
SetList::CODE_QUALITY,
SetList::CODING_STYLE,
),
);

// Skip specific rectors
$config->skip(
AnnotationToAttributeRector::class,
[
__DIR__.'/src/Some/File.php',
],
);

// Apply configuration
$config->apply();
};
```

## ⭐ License

This project is licensed under [GNU General Public License 3.0 (or later)](LICENSE).