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

eliashaeussler / version-bumper / 26184546461

20 May 2026 07:18PM UTC coverage: 85.077% (-3.5%) from 88.618%
26184546461

Pull #144

github

eliashaeussler
[FEATURE] Introduce `next-version` command
Pull Request #144: [FEATURE] Introduce `next-version` command

122 of 183 new or added lines in 6 files covered. (66.67%)

1 existing line in 1 file now uncovered.

1220 of 1434 relevant lines covered (85.08%)

5.02 hits per line

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

94.74
/src/Error/DeprecationHandler.php
1
<?php
2

3
declare(strict_types=1);
4

5
/*
6
 * This file is part of the Composer package "eliashaeussler/version-bumper".
7
 *
8
 * Copyright (C) 2024-2026 Elias Häußler <elias@haeussler.dev>
9
 *
10
 * This program is free software: you can redistribute it and/or modify
11
 * it under the terms of the GNU General Public License as published by
12
 * the Free Software Foundation, either version 3 of the License, or
13
 * (at your option) any later version.
14
 *
15
 * This program is distributed in the hope that it will be useful,
16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
 * GNU General Public License for more details.
19
 *
20
 * You should have received a copy of the GNU General Public License
21
 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22
 */
23

24
namespace EliasHaeussler\VersionBumper\Error;
25

26
use EliasHaeussler\VersionBumper\Config;
27
use Symfony\Component\Console;
28

29
use function restore_error_handler;
30
use function set_error_handler;
31

32
/**
33
 * DeprecationHandler.
34
 *
35
 * @author Elias Häußler <elias@haeussler.dev>
36
 * @license GPL-3.0-or-later
37
 *
38
 * @internal
39
 */
40
final class DeprecationHandler
41
{
42
    private static ?self $instance = null;
43

44
    /**
45
     * @var list<DeprecationMessage>
46
     */
47
    private array $deprecations = [];
48
    private bool $active = false;
49

NEW
50
    private function __construct() {}
×
51

52
    public static function new(): self
5✔
53
    {
54
        return self::$instance ??= new self();
5✔
55
    }
56

57
    public function enable(): void
3✔
58
    {
59
        if (!$this->active) {
3✔
60
            set_error_handler($this->registerDeprecation(...), E_USER_DEPRECATED);
3✔
61
        }
62

63
        $this->active = true;
3✔
64
    }
65

66
    public function disable(): void
5✔
67
    {
68
        if ($this->active) {
5✔
69
            restore_error_handler();
3✔
70
        }
71

72
        $this->active = false;
5✔
73
        $this->deprecations = [];
5✔
74
    }
75

76
    public function decorate(Console\Style\StyleInterface $io): void
2✔
77
    {
78
        if ([] === $this->deprecations) {
2✔
79
            return;
1✔
80
        }
81

82
        $io->warning('Your config file contains deprecated options.');
1✔
83

84
        $io->listing(
1✔
85
            array_map(
1✔
86
                static fn (DeprecationMessage $deprecation) => implode('', [
1✔
87
                    $deprecation->origin() instanceof Config\Preset\Preset
1✔
NEW
88
                        ? sprintf('<fg=yellow>%s</>: ', $deprecation->origin()::getIdentifier())
×
89
                        : '',
1✔
90
                    $deprecation->message(),
1✔
91
                    null !== $deprecation->since()
1✔
92
                        ? sprintf(' <fg=yellow>(deprecated since v%s)</>', $deprecation->since())
1✔
93
                        : '',
1✔
94
                ]),
1✔
95
                $this->deprecations,
1✔
96
            ),
1✔
97
        );
1✔
98
    }
99

100
    /**
101
     * @return list<DeprecationMessage>
102
     */
103
    public function deprecations(): array
2✔
104
    {
105
        return $this->deprecations;
2✔
106
    }
107

108
    private function registerDeprecation(int $errno, string $errstr): bool
3✔
109
    {
110
        $deprecationMessage = DeprecationMessage::fromTraceOrMessage($errstr);
3✔
111
        $collected = null !== $deprecationMessage;
3✔
112

113
        if ($collected) {
3✔
114
            $this->deprecations[] = $deprecationMessage;
3✔
115
        }
116

117
        return $collected;
3✔
118
    }
119
}
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