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

eliashaeussler / version-bumper / 24529564441

16 Apr 2026 07:24PM UTC coverage: 86.011% (-2.1%) from 88.084%
24529564441

Pull #128

github

eliashaeussler
[TASK] Collect and display deprecated config options
Pull Request #128: [TASK] Collect and display deprecated config options

25 of 59 new or added lines in 2 files covered. (42.37%)

7 existing lines in 1 file now uncovered.

1119 of 1301 relevant lines covered (86.01%)

4.97 hits per line

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

0.0
/src/Error/DeprecationMessage.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 function debug_backtrace;
27
use function explode;
28
use function is_object;
29
use function is_string;
30
use function str_starts_with;
31
use function substr;
32
use function trim;
33

34
/**
35
 * DeprecationMessage.
36
 *
37
 * @author Elias Häußler <elias@haeussler.dev>
38
 * @license GPL-3.0-or-later
39
 */
40
final readonly class DeprecationMessage
41
{
NEW
42
    public function __construct(
×
43
        private string $message,
44
        private string $since,
45
        private ?object $origin = null,
NEW
46
    ) {}
×
47

48
    /**
49
     * @param array{function: string, args: list<mixed>} $trace
50
     */
NEW
51
    public static function fromTrace(array $trace): ?self
×
52
    {
NEW
53
        if ('trigger_deprecation' !== $trace['function']) {
×
NEW
54
            return null;
×
55
        }
56

NEW
57
        [$packageName, $since, $message] = $trace['args'];
×
58

NEW
59
        if ('eliashaeussler/version-bumper' !== $packageName || !is_string($since) || !is_string($message)) {
×
NEW
60
            return null;
×
61
        }
62

NEW
63
        return new self($message, $since);
×
64
    }
65

NEW
66
    public static function fromMessage(string $message): ?self
×
67
    {
NEW
68
        $initialPhrase = 'Since eliashaeussler/version-bumper';
×
69

NEW
70
        if (!str_starts_with($message, $initialPhrase)) {
×
NEW
71
            return null;
×
72
        }
73

NEW
74
        [$since, $message] = explode(':', substr($message, strlen($initialPhrase)), 2);
×
75

NEW
76
        return new self(trim($message), trim($since));
×
77
    }
78

NEW
79
    public static function fromTraceOrMessage(string $message): ?self
×
80
    {
NEW
81
        $trace = debug_backtrace();
×
NEW
82
        $deprecation = null;
×
83

NEW
84
        foreach ($trace as $entry) {
×
NEW
85
            if (null === $deprecation) {
×
NEW
86
                if ('trigger_deprecation' === $entry['function'] && !isset($entry['class']) && isset($entry['args'])) {
×
NEW
87
                    $deprecation = self::fromTrace($entry) ?? self::fromMessage($message);
×
88
                }
NEW
89
            } elseif (is_object($entry['object'] ?? null) && str_starts_with($entry['class'] ?? '', 'EliasHaeussler\\VersionBumper\\')) {
×
NEW
90
                return $deprecation->withOrigin($entry['object']);
×
91
            }
92
        }
93

NEW
94
        return $deprecation ?? self::fromMessage($message);
×
95
    }
96

NEW
97
    public function message(): string
×
98
    {
NEW
99
        return $this->message;
×
100
    }
101

NEW
102
    public function since(): string
×
103
    {
NEW
104
        return $this->since;
×
105
    }
106

NEW
107
    public function origin(): ?object
×
108
    {
NEW
109
        return $this->origin;
×
110
    }
111

NEW
112
    public function withOrigin(object $origin): self
×
113
    {
NEW
114
        return new self($this->message, $this->since, $origin);
×
115
    }
116
}
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