chore: Update php-cs-fixer configuration to use parallel processing (#6771)

This commit is contained in:
Deeka Wong 2024-05-20 09:58:00 +08:00 committed by GitHub
parent 4d054861a0
commit c01cf5b41c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 2 deletions

View File

@ -9,6 +9,10 @@ declare(strict_types=1);
* @contact group@hyperf.io * @contact group@hyperf.io
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE * @license https://github.com/hyperf/hyperf/blob/master/LICENSE
*/ */
use PhpCsFixer\Config;
use PhpCsFixer\Finder;
use PhpCsFixer\Runner\Parallel\ParallelConfig;
$header = <<<'EOF' $header = <<<'EOF'
This file is part of Hyperf. This file is part of Hyperf.
@ -18,7 +22,10 @@ This file is part of Hyperf.
@license https://github.com/hyperf/hyperf/blob/master/LICENSE @license https://github.com/hyperf/hyperf/blob/master/LICENSE
EOF; EOF;
return (new PhpCsFixer\Config()) $maxProcesses = function_exists('swoole_cpu_num') ? swoole_cpu_num() : 4;
return (new Config())
->setParallelConfig(new ParallelConfig($maxProcesses, 20))
->setRiskyAllowed(true) ->setRiskyAllowed(true)
->setRules([ ->setRules([
'@PSR2' => true, '@PSR2' => true,
@ -99,7 +106,7 @@ return (new PhpCsFixer\Config())
'single_line_empty_body' => false, 'single_line_empty_body' => false,
]) ])
->setFinder( ->setFinder(
PhpCsFixer\Finder::create() Finder::create()
->exclude('bin') ->exclude('bin')
->exclude('public') ->exclude('public')
->exclude('runtime') ->exclude('runtime')

View File

@ -6,6 +6,10 @@ parameters:
level: 5 level: 5
bootstrapFiles: bootstrapFiles:
- "bootstrap.php" - "bootstrap.php"
parallel:
jobSize: 20
maximumNumberOfProcesses: 32
minimumNumberOfJobsPerProcess: 2
inferPrivatePropertyTypeFromConstructor: true inferPrivatePropertyTypeFromConstructor: true
treatPhpDocTypesAsCertain: true treatPhpDocTypesAsCertain: true
reportUnmatchedIgnoredErrors: false reportUnmatchedIgnoredErrors: false