Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@alongosz
Copy link
Member

@alongosz alongosz commented Oct 23, 2025

šŸŽ« Issue n/a

Related PRs:

Description:

As it seems, while parallel run has been available since Ibexa Code Style v2.1.0 (via PHP CS Fixer v3.75+), it was somewhat difficult to configure it, because it's exposed on another interface:

use Ibexa\CodeStyle\PhpCsFixer\InternalConfigFactory;
use PhpCsFixer\ParallelAwareConfigInterface;
use PhpCsFixer\Runner\Parallel\ParallelConfigFactory;

$factory = new InternalConfigFactory();
$factory->withRules([
    'declare_strict_types' => false,
]);

$config = $factory->buildConfig()
    ->setFinder(
        PhpCsFixer\Finder::create()
            ->in([
                __DIR__ . '/src',
                __DIR__ . '/tests',
            ])
            ->files()->name('*.php')
    );

if ($config instanceof ParallelAwareConfigInterface){
    $config->setParallelConfig(ParallelConfigFactory::detect());
}

return $config;

This PR adds syntax sugar for the InternalConfigFactory:

use Ibexa\CodeStyle\PhpCsFixer\InternalConfigFactory;

$factory = new InternalConfigFactory();
$factory->withRules([
    'declare_strict_types' => false,
]);

return $factory->runInParallel()->buildConfig()
    ->setFinder(
        PhpCsFixer\Finder::create()
            ->in([
                __DIR__ . '/src',
                __DIR__ . '/tests',
            ])
            ->files()->name('*.php')
    );

or alternatively, following bundle-generator-shipped config:

return \Ibexa\CodeStyle\PhpCsFixer\InternalConfigFactory::build(runInParallel: true)->setFinder(
    PhpCsFixer\Finder::create()
        ->in(__DIR__ . '/src')
        ->in(__DIR__ . '/tests')
        ->files()->name('*.php')
);

I don't see a more friendly way of configuring it in case of the static build factory method, so recommending here using named parameters. Other suggestions welcomed.

Base automatically changed from bump-php-cs-fixer-to-v3.89.0 to main October 29, 2025 10:32
@alongosz alongosz force-pushed the enable-parallel-config branch from 8a2d8ed to 08bb1e7 Compare October 29, 2025 10:34
@alongosz alongosz force-pushed the enable-parallel-config branch from 08bb1e7 to d53be97 Compare October 29, 2025 11:15
@sonarqubecloud
Copy link

@alongosz
Copy link
Member Author

Update: added also runInParallel argument to the static build factory method used by newer packages.

@konradoboza konradoboza requested a review from a team October 29, 2025 11:21
@alongosz alongosz marked this pull request as ready for review October 29, 2025 11:22
@alongosz alongosz merged commit 507cfcf into main Oct 29, 2025
5 checks passed
@alongosz alongosz deleted the enable-parallel-config branch October 29, 2025 12:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants