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

keradus / PHP-CS-Fixer / 17409000363

02 Sep 2025 03:52PM UTC coverage: 94.698% (+0.006%) from 94.692%
17409000363

push

github

keradus
move triggerDeprecation

22 of 28 new or added lines in 12 files covered. (78.57%)

4 existing lines in 2 files now uncovered.

28419 of 30010 relevant lines covered (94.7%)

45.51 hits per line

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

94.74
/src/Future.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;
16

17
/**
18
 * @author Dariusz Rumiński <dariusz.ruminski@gmail.com>
19
 *
20
 * @internal
21
 *
22
 * @no-named-arguments Parameter names are not covered by the backward compatibility promise.
23
 */
24
final class Future
25
{
26
    /**
27
     * @var array<string, true>
28
     */
29
    private static array $deprecations = [];
30

31
    private function __construct()
32
    {
33
        // cannot create instance
UNCOV
34
    }
×
35

36
    /**
37
     * @template T
38
     *
39
     * @param T $new
40
     * @param T $old
41
     *
42
     * @return T
43
     *
44
     * @TODO v4.0: remove this method, ensure code compiles, create getV5OrV4. While removing, ensure to document in `UPGRADE-vX.md` file.
45
     */
46
    public static function getV4OrV3($new, $old)
47
    {
48
        return self::getNewOrOld($new, $old);
2✔
49
    }
50

51
    public static function isFutureModeEnabled(): bool
52
    {
53
        return filter_var(
4✔
54
            getenv('PHP_CS_FIXER_FUTURE_MODE'),
4✔
55
            \FILTER_VALIDATE_BOOL
4✔
56
        );
4✔
57
    }
58

59
    public static function triggerDeprecation(\Exception $futureException): void
60
    {
61
        if (self::isFutureModeEnabled()) {
2✔
62
            throw new \RuntimeException(
1✔
63
                'Your are using something deprecated, see previous exception. Aborting execution because `PHP_CS_FIXER_FUTURE_MODE` environment variable is set.',
1✔
64
                0,
1✔
65
                $futureException
1✔
66
            );
1✔
67
        }
68

69
        $message = $futureException->getMessage();
1✔
70

71
        self::$deprecations[$message] = true;
1✔
72
        @trigger_error($message, \E_USER_DEPRECATED);
1✔
73
    }
74

75
    /**
76
     * @return list<string>
77
     */
78
    public static function getTriggeredDeprecations(): array
79
    {
80
        $triggeredDeprecations = array_keys(self::$deprecations);
2✔
81
        sort($triggeredDeprecations);
2✔
82

83
        return $triggeredDeprecations;
2✔
84
    }
85

86
    /**
87
     * @template T
88
     *
89
     * @param T $new
90
     * @param T $old
91
     *
92
     * @return T
93
     */
94
    private static function getNewOrOld($new, $old)
95
    {
96
        return self::isFutureModeEnabled() ? $new : $old;
2✔
97
    }
98
}
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