serendipity_hq/rector-config

Custom configuration for Rector used by Serendipity HQ.

1.0.7 2022-04-20 08:42 UTC

This package is auto-updated.

Last update: 2022-06-20 09:09:59 UTC


README

687474703a2f2f7777772e736572656e64697069747968712e636f6d2f6173736574732f6f70656e2d736f757263652d70726f6a656374732f4c6f676f2d536572656e64697069747948512d49636f6e2d546578742d507572706c652e706e67

Serendipity HQ Rector Configuration

A predefined configuration used in Serendipity HQ's projects.

68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f736572656e6469706974795f68712f726563746f722d636f6e6669672e7376673f7374796c653d666c61742d737175617265 68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265 68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f736572656e6469706974795f68712f726563746f722d636f6e6669673f636f6c6f723d253233383839324246267374796c653d666c61742d737175617265266c6f676f3d706870

Current Status

Phan PHPStan PSalm PHPUnit Composer PHP CS Fixer Rector

Do you like this library?
LEAVE A ★

or run
composer global require symfony/thanks && composer thanks
to say thank you to all libraries you use in your current project, this included!

Install monolog-html-line-formatter via Composer

$ composer require serendipity_hq/rector-config

This library follows the http://semver.org/ versioning conventions.

How to use Serendipity HQ Rector Config

<?php

declare(strict_types = 1);

use SerendipityHQ\Integration\Rector\SerendipityHQ;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Rector\Core\Configuration\Option;
use Rector\Core\ValueObject\PhpVersion;

return static function (ContainerConfigurator $containerConfigurator) : void {
    $parameters = $containerConfigurator->parameters();

    $parameters->set(Option::PHP_VERSION_FEATURES, PhpVersion::PHP_81);
    $parameters->set(Option::PATHS, [__DIR__ . '/src', __DIR__ . '/tests']);
    $parameters->set(Option::BOOTSTRAP_FILES, [__DIR__ . '/vendor-bin/phpunit/vendor/autoload.php']);

    // Import directly the configuration from Serendipity HQ Rector Config
    $containerConfigurator->import(SerendipityHQ::SHQ_SYMFONY_APP);

    // Import the excluded rectors
    $toSkip = SerendipityHQ::buildToSkip(SerendipityHQ::SHQ_SYMFONY_APP_SKIP);
    
    // Set the rectors to exclude
    $parameters->set(Option::SKIP, $toSkip);
};

The method SerendipityHQ::buildToSkip() is variadic: it accepts as many arrays as you need.

Use it to exclude the rectors you don't want to be applied in your project.

If you want to exclude other rectors other than the ones excluded by the predefined config, simply create an array in your rector.php configuration file and pass it to SerendipityHQ::buildToSkip():

<?php

declare(strict_types = 1);

use SerendipityHQ\Integration\Rector\SerendipityHQ;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Rector\Core\Configuration\Option;
use Rector\Core\ValueObject\PhpVersion;

return static function (ContainerConfigurator $containerConfigurator) : void {
    ...
    
    $othersToSkip = [
        \Rector\To\Exclude\Rector::class
    ];

    // Import the excluded rectors
    $toSkip = SerendipityHQ::buildToSkip(SerendipityHQ::SHQ_SYMFONY_APP_SKIP, $othersToSkip);
    
    // Set the rectors to exclude
    $parameters->set(Option::SKIP, $toSkip);
};

Do you like this library?
LEAVE A ★

or run
composer global require symfony/thanks && composer thanks
to say thank you to all libraries you use in your current project, this included!