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

keradus / PHP-CS-Fixer / 17855924389

19 Sep 2025 10:31AM UTC coverage: 94.55%. Remained the same
17855924389

push

github

web-flow
deps: bump phpstan/phpstan from 2.1.25 to 2.1.28 in /dev-tools in the phpstan group (#9072)

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

28418 of 30056 relevant lines covered (94.55%)

45.5 hits per line

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

75.0
/src/Tokenizer/Analyzer/Analysis/NamespaceUseAnalysis.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\Tokenizer\Analyzer\Analysis;
16

17
/**
18
 * @readonly
19
 *
20
 * @internal
21
 *
22
 * @phpstan-type _ImportType 'class'|'constant'|'function'
23
 *
24
 * @author VeeWee <toonverwerft@gmail.com>
25
 * @author Greg Korba <greg@codito.dev>
26
 *
27
 * @no-named-arguments Parameter names are not covered by the backward compatibility promise.
28
 */
29
final class NamespaceUseAnalysis
30
{
31
    public const TYPE_CLASS = 1; // "classy" could be class, interface or trait
32
    public const TYPE_FUNCTION = 2;
33
    public const TYPE_CONSTANT = 3;
34

35
    /**
36
     * The fully qualified use namespace.
37
     *
38
     * @var non-empty-string
39
     */
40
    private string $fullName;
41

42
    /**
43
     * The short version of use namespace or the alias name in case of aliased use statements.
44
     *
45
     * @var non-empty-string
46
     */
47
    private string $shortName;
48

49
    /**
50
     * Is the use statement part of multi-use (`use A, B, C;`, `use A\{B, C};`)?
51
     */
52
    private bool $isInMulti;
53

54
    /**
55
     * Is the use statement being aliased?
56
     */
57
    private bool $isAliased;
58

59
    /**
60
     * The start index of the namespace declaration in the analyzed Tokens.
61
     */
62
    private int $startIndex;
63

64
    /**
65
     * The end index of the namespace declaration in the analyzed Tokens.
66
     */
67
    private int $endIndex;
68

69
    /**
70
     * The start index of the single import in the multi-use statement.
71
     */
72
    private ?int $chunkStartIndex;
73

74
    /**
75
     * The end index of the single import in the multi-use statement.
76
     */
77
    private ?int $chunkEndIndex;
78

79
    /**
80
     * The type of import: class, function or constant.
81
     *
82
     * @var self::TYPE_*
83
     */
84
    private int $type;
85

86
    /**
87
     * @param self::TYPE_*     $type
88
     * @param non-empty-string $fullName
89
     * @param non-empty-string $shortName
90
     */
91
    public function __construct(
92
        int $type,
93
        string $fullName,
94
        string $shortName,
95
        bool $isAliased,
96
        bool $isInMulti,
97
        int $startIndex,
98
        int $endIndex,
99
        ?int $chunkStartIndex = null,
100
        ?int $chunkEndIndex = null
101
    ) {
102
        if (true === $isInMulti && (null === $chunkStartIndex || null === $chunkEndIndex)) {
8✔
103
            throw new \LogicException('Chunk start and end index must be set when the import is part of a multi-use statement.');
1✔
104
        }
105

106
        $this->type = $type;
7✔
107
        $this->fullName = $fullName;
7✔
108
        $this->shortName = $shortName;
7✔
109
        $this->isAliased = $isAliased;
7✔
110
        $this->isInMulti = $isInMulti;
7✔
111
        $this->startIndex = $startIndex;
7✔
112
        $this->endIndex = $endIndex;
7✔
113
        $this->chunkStartIndex = $chunkStartIndex;
7✔
114
        $this->chunkEndIndex = $chunkEndIndex;
7✔
115
    }
116

117
    /**
118
     * @return non-empty-string
119
     */
120
    public function getFullName(): string
121
    {
122
        return $this->fullName;
1✔
123
    }
124

125
    /**
126
     * @return non-empty-string
127
     */
128
    public function getShortName(): string
129
    {
130
        return $this->shortName;
1✔
131
    }
132

133
    public function isAliased(): bool
134
    {
135
        return $this->isAliased;
1✔
136
    }
137

138
    public function isInMulti(): bool
139
    {
140
        return $this->isInMulti;
1✔
141
    }
142

143
    public function getStartIndex(): int
144
    {
145
        return $this->startIndex;
1✔
146
    }
147

148
    public function getEndIndex(): int
149
    {
150
        return $this->endIndex;
1✔
151
    }
152

153
    public function getChunkStartIndex(): ?int
154
    {
155
        return $this->chunkStartIndex;
×
156
    }
157

158
    public function getChunkEndIndex(): ?int
159
    {
160
        return $this->chunkEndIndex;
×
161
    }
162

163
    /**
164
     * @return self::TYPE_*
165
     */
166
    public function getType(): int
167
    {
168
        return $this->type;
1✔
169
    }
170

171
    /**
172
     * @return _ImportType
173
     */
174
    public function getHumanFriendlyType(): string
175
    {
176
        return [
×
177
            self::TYPE_CLASS => 'class',
×
178
            self::TYPE_FUNCTION => 'function',
×
179
            self::TYPE_CONSTANT => 'constant',
×
180
        ][$this->type];
×
181
    }
182

183
    public function isClass(): bool
184
    {
185
        return self::TYPE_CLASS === $this->type;
1✔
186
    }
187

188
    public function isFunction(): bool
189
    {
190
        return self::TYPE_FUNCTION === $this->type;
1✔
191
    }
192

193
    public function isConstant(): bool
194
    {
195
        return self::TYPE_CONSTANT === $this->type;
1✔
196
    }
197
}
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