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

keradus / PHP-CS-Fixer / 17279562118

27 Aug 2025 09:47PM UTC coverage: 94.693%. Remained the same
17279562118

push

github

keradus
CS

28316 of 29903 relevant lines covered (94.69%)

45.61 hits per line

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

83.33
/src/Console/Output/Progress/PercentageBarOutput.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\Console\Output\Progress;
16

17
use PhpCsFixer\Console\Output\OutputContext;
18
use PhpCsFixer\Runner\Event\FileProcessed;
19
use Symfony\Component\Console\Helper\ProgressBar;
20

21
/**
22
 * Output writer to show the progress of a FixCommand using progress bar (percentage).
23
 *
24
 * @readonly
25
 *
26
 * @internal
27
 *
28
 * @no-named-arguments Parameter names are not covered by the backward compatibility promise.
29
 */
30
final class PercentageBarOutput implements ProgressOutputInterface
31
{
32
    /** @readonly */
33
    private OutputContext $context;
34

35
    private ProgressBar $progressBar;
36

37
    public function __construct(OutputContext $context)
38
    {
39
        $this->context = $context;
1✔
40

41
        $this->progressBar = new ProgressBar($context->getOutput(), $this->context->getFilesCount());
1✔
42
        $this->progressBar->setBarCharacter('▓'); // dark shade character \u2593
1✔
43
        $this->progressBar->setEmptyBarCharacter('░'); // light shade character \u2591
1✔
44
        $this->progressBar->setProgressCharacter('');
1✔
45
        $this->progressBar->setFormat('normal');
1✔
46

47
        $this->progressBar->start();
1✔
48
    }
49

50
    /**
51
     * This class is not intended to be serialized,
52
     * and cannot be deserialized (see __wakeup method).
53
     */
54
    public function __sleep(): array
55
    {
56
        throw new \BadMethodCallException('Cannot serialize '.self::class);
×
57
    }
58

59
    /**
60
     * Disable the deserialization of the class to prevent attacker executing
61
     * code by leveraging the __destruct method.
62
     *
63
     * @see https://owasp.org/www-community/vulnerabilities/PHP_Object_Injection
64
     */
65
    public function __wakeup(): void
66
    {
67
        throw new \BadMethodCallException('Cannot unserialize '.self::class);
×
68
    }
69

70
    public function onFixerFileProcessed(FileProcessed $event): void
71
    {
72
        $this->progressBar->advance(1);
1✔
73

74
        if ($this->progressBar->getProgress() === $this->progressBar->getMaxSteps()) {
1✔
75
            $this->context->getOutput()->write("\n\n");
1✔
76
        }
77
    }
78

79
    public function printLegend(): void {}
80
}
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