• 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

91.3
/src/Linter/ProcessLintingResult.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\Linter;
16

17
use Symfony\Component\Process\Process;
18

19
/**
20
 * @author Dariusz Rumiński <dariusz.ruminski@gmail.com>
21
 *
22
 * @internal
23
 *
24
 * @no-named-arguments Parameter names are not covered by the backward compatibility promise.
25
 */
26
final class ProcessLintingResult implements LintingResultInterface
27
{
28
    private Process $process;
29

30
    private ?string $path;
31

32
    private ?bool $isSuccessful = null;
33

34
    public function __construct(Process $process, ?string $path = null)
35
    {
36
        $this->process = $process;
8✔
37
        $this->path = $path;
8✔
38
    }
39

40
    public function check(): void
41
    {
42
        if (!$this->isSuccessful()) {
8✔
43
            // on some systems stderr is used, but on others, it's not
44
            throw new LintingException($this->getProcessErrorMessage(), $this->process->getExitCode());
5✔
45
        }
46
    }
47

48
    private function getProcessErrorMessage(): string
49
    {
50
        $errorOutput = $this->process->getErrorOutput();
5✔
51
        $output = strtok(ltrim('' !== $errorOutput ? $errorOutput : $this->process->getOutput()), "\n");
5✔
52

53
        if (false === $output) {
5✔
54
            return 'Fatal error: Unable to lint file.';
×
55
        }
56

57
        if (null !== $this->path) {
5✔
58
            $needle = \sprintf('in %s ', $this->path);
5✔
59
            $pos = strrpos($output, $needle);
5✔
60

61
            if (false !== $pos) {
5✔
62
                $output = \sprintf('%s%s', substr($output, 0, $pos), substr($output, $pos + \strlen($needle)));
5✔
63
            }
64
        }
65

66
        $prefix = substr($output, 0, 18);
5✔
67

68
        if ('PHP Parse error:  ' === $prefix) {
5✔
69
            return \sprintf('Parse error: %s.', substr($output, 18));
4✔
70
        }
71

72
        if ('PHP Fatal error:  ' === $prefix) {
1✔
73
            return \sprintf('Fatal error: %s.', substr($output, 18));
1✔
74
        }
75

76
        return \sprintf('%s.', $output);
×
77
    }
78

79
    private function isSuccessful(): bool
80
    {
81
        if (null === $this->isSuccessful) {
8✔
82
            $this->process->wait();
8✔
83
            $this->isSuccessful = $this->process->isSuccessful();
8✔
84
        }
85

86
        return $this->isSuccessful;
8✔
87
    }
88
}
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