rector/build/target-repository/docs/how_to_register_custom_setlist_constant.md
Tomas Votruba 8d92c466fd
[DX] Use RectorConfig in configs (#2063)
* use RectorConfig in configs

* update variable name

* remove extra spaces

* apply on configs

* apply on e2e

* update markdown files

* remove extra spaces
2022-04-12 13:46:07 +02:00

1.1 KiB

How To Register Custom SetList Constant

You can have custom SetList class that has constants that pointed to your own config, for example:

<?php

namespace App\Set\ValueObject;

use Rector\Set\Contract\SetListInterface;

class SetList implements SetListInterface
{
    public const MY_FRAMEWORK_20 = __DIR__ . '/../../../config/set/my-framework-20.php';
}

Now, you can register your custom SetList's constant via import from $containerConfigurator, for example:

use Rector\Core\Configuration\Option;
use App\Set\ValueObject\SetList;
use Rector\Config\RectorConfig;

return static function (RectorConfig $rectorConfig): void {
    $rectorConfig->sets([SetList::MY_FRAMEWORK_20]);

    $rectorConfig->paths([__DIR__ . '/src']);
};

Note that if you are looking for the downgrade categories, there is already the DowngradeSetList:

use Rector\Core\Configuration\Option;
use Rector\Set\ValueObject\DowngradeSetList;
use Rector\Config\RectorConfig;

return static function (RectorConfig $rectorConfig): void {
    $rectorConfig->sets([DowngradeSetList::PHP_70])

    $rectorConfig->paths([__DIR__ . '/src']);
};