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

keradus / PHP-CS-Fixer / 17253245287

23 Aug 2025 07:51PM UTC coverage: 94.669% (-0.06%) from 94.728%
17253245287

push

github

keradus
phpstan

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

180 existing lines in 15 files now uncovered.

28255 of 29846 relevant lines covered (94.67%)

45.84 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
final class ProcessFactory
30
{
31
    public function create(
32
        LoopInterface $loop,
33
        InputInterface $input,
34
        RunnerConfig $runnerConfig,
35
        ProcessIdentifier $identifier,
36
        int $serverPort
37
    ): Process {
38
        $commandArgs = $this->getCommandArgs($serverPort, $identifier, $input, $runnerConfig);
1✔
39

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

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

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

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

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

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

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

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

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

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

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

103
        return $commandArgs;
12✔
104
    }
105
}
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