Skip to content

Commit

Permalink
Support parallel for cs-fixer and phpstan.
Browse files Browse the repository at this point in the history
  • Loading branch information
limingxinleo committed May 20, 2024
1 parent 012ff0a commit 45dca29
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
26 changes: 20 additions & 6 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
<?php

declare(strict_types=1);
/**
* This file is part of Hyperf.
*
* @link https://www.hyperf.io
* @document https://hyperf.wiki
* @contact [email protected]
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
*/
use PhpCsFixer\Config;
use PhpCsFixer\Finder;
use PhpCsFixer\Runner\Parallel\ParallelConfig;

$header = <<<'EOF'
This file is part of Hyperf.
Expand All @@ -9,7 +22,8 @@
@license https://github.com/hyperf/hyperf/blob/master/LICENSE
EOF;

return (new PhpCsFixer\Config())
return (new Config())
->setParallelConfig(new ParallelConfig(swoole_cpu_num(), 20))
->setRiskyAllowed(true)
->setRules([
'@PSR2' => true,
Expand All @@ -23,13 +37,13 @@
'location' => 'after_declare_strict',
],
'array_syntax' => [
'syntax' => 'short'
'syntax' => 'short',
],
'list_syntax' => [
'syntax' => 'short'
'syntax' => 'short',
],
'concat_space' => [
'spacing' => 'one'
'spacing' => 'one',
],
'blank_line_before_statement' => [
'statements' => [
Expand All @@ -38,7 +52,7 @@
],
'general_phpdoc_annotation_remove' => [
'annotations' => [
'author'
'author',
],
],
'ordered_imports' => [
Expand Down Expand Up @@ -89,7 +103,7 @@
'single_line_empty_body' => false,
])
->setFinder(
PhpCsFixer\Finder::create()
Finder::create()
->exclude('public')
->exclude('runtime')
->exclude('vendor')
Expand Down
4 changes: 4 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ parameters:
- app
- config
reportUnmatchedIgnoredErrors: false
parallel:
jobSize: 20
maximumNumberOfProcesses: 32
minimumNumberOfJobsPerProcess: 2
ignoreErrors:
- '#Static call to instance method Hyperf\\HttpServer\\Router\\Router::[a-zA-Z0-9\\_]+\(\)#'
- '#Static call to instance method Hyperf\\DbConnection\\Db::[a-zA-Z0-9\\_]+\(\)#'
Expand Down

0 comments on commit 45dca29

Please sign in to comment.