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

keradus / PHP-CS-Fixer / 17328452173

29 Aug 2025 03:54PM UTC coverage: 94.693% (+0.01%) from 94.683%
17328452173

push

github

keradus
Merge branch 'test' of github.com:keradus/PHP-CS-Fixer into test

19 of 32 new or added lines in 6 files covered. (59.38%)

33 existing lines in 4 files now uncovered.

28318 of 29905 relevant lines covered (94.69%)

45.61 hits per line

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

69.57
/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
        try {
50
            /**
51
             * @var list<array{
52
             *     name: string,
53
             *     zipball_url: string,
54
             *     tarball_url: string,
55
             *     commit: array{sha: string, url: string},
56
             * }>
57
             */
58
            $result = json_decode($result, true, 512, \JSON_THROW_ON_ERROR);
1✔
NEW
59
        } catch (\JsonException $e) {
×
60
            throw new \RuntimeException(\sprintf(
×
61
                'Failed to read response from "%s" as JSON: %s.',
×
62
                $this->url,
×
NEW
63
                $e->getMessage(),
×
64
            ));
×
65
        }
66

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