• 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

73.91
/src/Console/SelfUpdate/GithubClient.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\SelfUpdate;
16

17
/**
18
 * @readonly
19
 *
20
 * @internal
21
 *
22
 * @no-named-arguments Parameter names are not covered by the backward compatibility promise.
23
 */
24
final class GithubClient implements GithubClientInterface
25
{
26
    private string $url;
27

28
    public function __construct(string $url = 'https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/tags')
29
    {
30
        $this->url = $url;
1✔
31
    }
32

33
    public function getTags(): array
34
    {
35
        $result = @file_get_contents(
1✔
36
            $this->url,
1✔
37
            false,
1✔
38
            stream_context_create([
1✔
39
                'http' => [
1✔
40
                    'header' => 'User-Agent: PHP-CS-Fixer/PHP-CS-Fixer',
1✔
41
                ],
1✔
42
            ])
1✔
43
        );
1✔
44

45
        if (false === $result) {
1✔
46
            throw new \RuntimeException(\sprintf('Failed to load tags at "%s".', $this->url));
×
47
        }
48

49
        /**
50
         * @var list<array{
51
         *     name: string,
52
         *     zipball_url: string,
53
         *     tarball_url: string,
54
         *     commit: array{sha: string, url: string},
55
         * }>
56
         */
57
        $result = json_decode($result, true);
1✔
58
        if (\JSON_ERROR_NONE !== json_last_error()) {
1✔
59
            throw new \RuntimeException(\sprintf(
×
60
                'Failed to read response from "%s" as JSON: %s.',
×
61
                $this->url,
×
62
                json_last_error_msg()
×
63
            ));
×
64
        }
65

66
        return array_map(
1✔
67
            static fn (array $tagData): string => $tagData['name'],
1✔
68
            $result
1✔
69
        );
1✔
70
    }
71
}
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