PHP code example of kaspiman / rector-longrunning-rules
1. Go to this page and download the library: Download kaspiman/rector-longrunning-rules library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
kaspiman / rector-longrunning-rules example snippets
use Rector\Renaming\Rector\ConstFetch\RenameConstantRector;
return static function (RectorConfig $config): void {
// общие настройки, к примеру директория с проектом...
$config->paths([
'src',
]);
// Встроенное правило в Rector, запрещаем константу PHP_SAPI, меняя на несуществующую
$config->ruleWithConfiguration(RenameConstantRector::class, [
'PHP_SAPI' => 'FORBID',
]);
// Правила без конфигурации
$config->rules([
IncludeRequireRector::class,
ExitAndDieRector::class,
EchoForbidRector::class,
]);
// Правила с возможностью настроить поведение
// Список глобальных переменных находится в файле, можно указать свой набор
$config->ruleWithConfiguration(GlobalVarsForbidRector::class, [
'vars' => е определённых префиксов, например DTO и прочих объектов-переносчиков состояния
'Dto',
'Mock',
'Stub',
'Item',
'Builder',
'Collection',
'Filter',
'Criteria',
'Context',
'Container',
'Object',
'Aggregate',
'Request',
'Response',
'Payload',
'Event',
'Exception',
'Result',
'Message',
'Config',
'Param',
'Params',
'Data',
],
'ignoreAttributes' => [ // Игнорирование определённых аттрибутов, например сущностей Doctrine
'Doctrine\ORM\Mapping\Entity',
],
]);
}
public function work(): {
/**
* @rector-suppress ForbiddenFunctionsRector
*/
ini_set('memory_limit', '42G');
}