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

keradus / PHP-CS-Fixer / 17252691116

26 Aug 2025 11:09PM UTC coverage: 94.743% (-0.01%) from 94.755%
17252691116

push

github

keradus
chore: apply phpdoc_tag_no_named_arguments

28313 of 29884 relevant lines covered (94.74%)

45.64 hits per line

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

92.11
/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
    private InputInterface $input;
34

35
    public function __construct(InputInterface $input)
36
    {
37
        $this->input = $input;
10✔
38
    }
39

40
    public function create(
41
        LoopInterface $loop,
42
        RunnerConfig $runnerConfig,
43
        ProcessIdentifier $identifier,
44
        int $serverPort
45
    ): Process {
46
        $commandArgs = $this->getCommandArgs($serverPort, $identifier, $runnerConfig);
10✔
47

48
        return new Process(
10✔
49
            implode(' ', $commandArgs),
10✔
50
            $loop,
10✔
51
            $runnerConfig->getParallelConfig()->getProcessTimeout()
10✔
52
        );
10✔
53
    }
54

55
    /**
56
     * @private
57
     *
58
     * @return non-empty-list<string>
59
     */
60
    public function getCommandArgs(int $serverPort, ProcessIdentifier $identifier, RunnerConfig $runnerConfig): array
61
    {
62
        $phpBinary = (new PhpExecutableFinder())->find(false);
10✔
63

64
        if (false === $phpBinary) {
10✔
65
            throw new ParallelisationException('Cannot find PHP executable.');
×
66
        }
67

68
        $mainScript = realpath(__DIR__.'/../../../php-cs-fixer');
10✔
69
        if (false === $mainScript
10✔
70
            && isset($_SERVER['argv'][0])
10✔
71
            && str_contains($_SERVER['argv'][0], 'php-cs-fixer')
10✔
72
        ) {
73
            $mainScript = $_SERVER['argv'][0];
×
74
        }
75

76
        if (!is_file($mainScript)) {
10✔
77
            throw new ParallelisationException('Cannot determine Fixer executable.');
×
78
        }
79

80
        $commandArgs = [
10✔
81
            escapeshellarg($phpBinary),
10✔
82
            escapeshellarg($mainScript),
10✔
83
            'worker',
10✔
84
            '--port',
10✔
85
            (string) $serverPort,
10✔
86
            '--identifier',
10✔
87
            escapeshellarg($identifier->toString()),
10✔
88
        ];
10✔
89

90
        if ($runnerConfig->isDryRun()) {
10✔
91
            $commandArgs[] = '--dry-run';
2✔
92
        }
93

94
        if (filter_var($this->input->getOption('diff'), \FILTER_VALIDATE_BOOLEAN)) {
10✔
95
            $commandArgs[] = '--diff';
2✔
96
        }
97

98
        if (filter_var($this->input->getOption('stop-on-violation'), \FILTER_VALIDATE_BOOLEAN)) {
10✔
99
            $commandArgs[] = '--stop-on-violation';
2✔
100
        }
101

102
        foreach (['allow-risky', 'config', 'rules', 'using-cache', 'cache-file'] as $option) {
10✔
103
            $optionValue = $this->input->getOption($option);
10✔
104

105
            if (null !== $optionValue) {
10✔
106
                $commandArgs[] = "--{$option}";
6✔
107
                $commandArgs[] = escapeshellarg($optionValue);
6✔
108
            }
109
        }
110

111
        return $commandArgs;
10✔
112
    }
113
}
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