-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrector-php84.php
More file actions
57 lines (49 loc) · 2.07 KB
/
rector-php84.php
File metadata and controls
57 lines (49 loc) · 2.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
declare(strict_types=1);
use Rector\Caching\ValueObject\Storage\MemoryCacheStorage;
use Rector\Config\RectorConfig;
use Rector\Php84\Rector\Param\ExplicitNullableParamTypeRector;
use Rector\Set\ValueObject\LevelSetList;
use Rector\Set\ValueObject\SetList;
/*
* PHP 8.4 specific Rector configuration for php-qa-ci
* This runs after rector-safe.php and rector-phpunit.php
*/
return static function (RectorConfig $rectorConfig): void {
// Limit parallel processing to use only half of available CPU threads
// to avoid overwhelming the system
$cpuThreads = (int) shell_exec('nproc') ?: 4; // Default to 4 if nproc fails
$maxProcesses = max(1, (int) floor($cpuThreads / 2)); // Use half the threads, minimum 1
// Parameters: timeout (seconds), max processes, job size (files per job)
$rectorConfig->parallel(
120, // Default timeout
$maxProcesses, // Use only half of available CPU threads
16 // Default job size
);
// PHP 8.4 upgrade sets
// IMPORTANT: SetList::NAMING is EXCLUDED because it includes RenameParamToMatchTypeRector
// which renames constructor parameters like $productsRow → $productsRowDto
// This is a BREAKING CHANGE for any code calling constructors with named parameters
$rectorConfig->sets([
LevelSetList::UP_TO_PHP_84,
SetList::PHP_84,
SetList::DEAD_CODE,
SetList::CODE_QUALITY,
SetList::CODING_STYLE,
SetList::TYPE_DECLARATION,
SetList::PRIVATIZATION,
SetList::EARLY_RETURN,
// SetList::NAMING, // EXCLUDED - causes constructor parameter renaming
]);
// PHP 8.4 specific rules
$rectorConfig->rules([
ExplicitNullableParamTypeRector::class,
]);
// Use memory cache for performance
$rectorConfig->cacheClass(MemoryCacheStorage::class);
// Support for ignoring paths via environment variable
if (isset($_SERVER['rectorIgnorePaths'])) {
$ignorePaths = array_filter(array_map('trim', explode("\n", $_SERVER['rectorIgnorePaths'])));
$rectorConfig->skip($ignorePaths);
}
};