• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

keradus / PHP-CS-Fixer / 17678835382

12 Sep 2025 03:24PM UTC coverage: 94.69% (-0.06%) from 94.75%
17678835382

push

github

keradus
fix typo

1 of 1 new or added line in 1 file covered. (100.0%)

1042 existing lines in 177 files now uncovered.

28424 of 30018 relevant lines covered (94.69%)

45.5 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

91.89
/src/Runner/Parallel/ProcessFactory.php
1
<?php
2

3
declare(strict_types=1);
4

5
/*
6
 * This file is part of PHP CS Fixer.
7
 *
8
 * (c) Fabien Potencier <fabien@symfony.com>
9
 *     Dariusz RumiƄski <dariusz.ruminski@gmail.com>
10
 *
11
 * This source file is subject to the MIT license that is bundled
12
 * with this source code in the file LICENSE.
13
 */
14

15
namespace PhpCsFixer\Runner\Parallel;
16

17
use PhpCsFixer\Runner\RunnerConfig;
18
use React\EventLoop\LoopInterface;
19
use Symfony\Component\Console\Input\InputInterface;
20
use Symfony\Component\Process\PhpExecutableFinder;
21

22
/**
23
 * @author Greg Korba <greg@codito.dev>
24
 *
25
 * @readonly
26
 *
27
 * @internal
28
 *
29
 * @no-named-arguments Parameter names are not covered by the backward compatibility promise.
30
 */
31
final class ProcessFactory
32
{
33
    public function create(
34
        LoopInterface $loop,
35
        InputInterface $input,
36
        RunnerConfig $runnerConfig,
37
        ProcessIdentifier $identifier,
38
        int $serverPort
39
    ): Process {
40
        $commandArgs = $this->getCommandArgs($serverPort, $identifier, $input, $runnerConfig);
1✔
41

42
        return new Process(
1✔
43
            implode(' ', $commandArgs),
1✔
44
            $loop,
1✔
45
            $runnerConfig->getParallelConfig()->getProcessTimeout()
1✔
46
        );
1✔
47
    }
48

49
    /**
50
     * @private
51
     *
52
     * @return non-empty-list<string>
53
     */
54
    public function getCommandArgs(int $serverPort, ProcessIdentifier $identifier, InputInterface $input, RunnerConfig $runnerConfig): array
55
    {
56
        $phpBinary = (new PhpExecutableFinder())->find(false);
12✔
57

58
        if (false === $phpBinary) {
12✔
UNCOV
59
            throw new ParallelisationException('Cannot find PHP executable.');
×
60
        }
61

62
        $mainScript = realpath(__DIR__.'/../../../php-cs-fixer');
12✔
63
        if (false === $mainScript
12✔
64
            && isset($_SERVER['argv'][0])
12✔
65
            && str_contains($_SERVER['argv'][0], 'php-cs-fixer')
12✔
66
        ) {
UNCOV
67
            $mainScript = $_SERVER['argv'][0];
×
68
        }
69

70
        if (!is_file($mainScript)) {
12✔
71
            throw new ParallelisationException('Cannot determine Fixer executable.');
×
72
        }
73

74
        $commandArgs = [
12✔
75
            ProcessUtils::escapeArgument($phpBinary),
12✔
76
            ProcessUtils::escapeArgument($mainScript),
12✔
77
            'worker',
12✔
78
            '--port',
12✔
79
            (string) $serverPort,
12✔
80
            '--identifier',
12✔
81
            ProcessUtils::escapeArgument($identifier->toString()),
12✔
82
        ];
12✔
83

84
        if ($runnerConfig->isDryRun()) {
12✔
85
            $commandArgs[] = '--dry-run';
3✔
86
        }
87

88
        if (filter_var($input->getOption('diff'), \FILTER_VALIDATE_BOOLEAN)) {
12✔
89
            $commandArgs[] = '--diff';
3✔
90
        }
91

92
        if (filter_var($input->getOption('stop-on-violation'), \FILTER_VALIDATE_BOOLEAN)) {
12✔
93
            $commandArgs[] = '--stop-on-violation';
3✔
94
        }
95

96
        foreach (['allow-risky', 'config', 'rules', 'using-cache', 'cache-file'] as $option) {
12✔
97
            $optionValue = $input->getOption($option);
12✔
98

99
            if (null !== $optionValue) {
12✔
100
                $commandArgs[] = "--{$option}";
8✔
101
                $commandArgs[] = ProcessUtils::escapeArgument($optionValue);
8✔
102
            }
103
        }
104

105
        return $commandArgs;
12✔
106
    }
107
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc