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

eliashaeussler / version-bumper / 26179712348

20 May 2026 05:44PM UTC coverage: 78.161% (-10.5%) from 88.618%
26179712348

Pull #144

github

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

7 of 176 new or added lines in 5 files covered. (3.98%)

12 existing lines in 2 files now uncovered.

1156 of 1479 relevant lines covered (78.16%)

4.69 hits per line

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

0.0
/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
final class DeprecationHandler
39
{
40
    private static ?self $instance = null;
41

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

NEW
48
    private function __construct() {}
×
49

NEW
50
    public static function new(): self
×
51
    {
NEW
52
        return self::$instance ??= new self();
×
53
    }
54

NEW
55
    public function enable(): void
×
56
    {
NEW
57
        if (!$this->active) {
×
NEW
58
            set_error_handler($this->registerDeprecation(...), E_USER_DEPRECATED);
×
59
        }
60

NEW
61
        $this->active = true;
×
62
    }
63

NEW
64
    public function disable(): void
×
65
    {
NEW
66
        if ($this->active) {
×
NEW
67
            restore_error_handler();
×
68
        }
69

NEW
70
        $this->active = false;
×
71
    }
72

NEW
73
    public function decorate(Console\Style\StyleInterface $io): void
×
74
    {
NEW
75
        if ([] === $this->deprecations) {
×
NEW
76
            return;
×
77
        }
78

NEW
79
        $io->warning('Your config file contains deprecated options.');
×
80

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

NEW
96
        $this->deprecations = [];
×
97
    }
98

NEW
99
    private function registerDeprecation(int $errno, string $errstr): bool
×
100
    {
NEW
101
        $deprecationMessage = DeprecationMessage::fromTraceOrMessage($errstr);
×
NEW
102
        $collected = null !== $deprecationMessage;
×
103

NEW
104
        if ($collected) {
×
NEW
105
            $this->deprecations[] = $deprecationMessage;
×
106
        }
107

NEW
108
        return $collected;
×
109
    }
110
}
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