Skip to content

Commit f35911f

Browse files
chore(deps): update phpstan packages to v2 (major) (#149)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
1 parent e98b1e6 commit f35911f

File tree

5 files changed

+14
-4
lines changed

5 files changed

+14
-4
lines changed

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
},
2222
"require-dev": {
2323
"phpstan/extension-installer": "^1.2",
24-
"phpstan/phpstan": "^1.0.0",
25-
"phpstan/phpstan-phpunit": "^1.0.0",
26-
"phpstan/phpstan-strict-rules": "^1.0.0",
24+
"phpstan/phpstan": "^2.0.0",
25+
"phpstan/phpstan-phpunit": "^2.0.0",
26+
"phpstan/phpstan-strict-rules": "^2.0.0",
2727
"phpunit/phpunit": "^11.0"
2828
},
2929
"config": {

src/Cdn77/Sniffs/NamingConventions/ValidConstantNameSniff.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ public function register(): array
5555
*/
5656
public function process(File $phpcsFile, $stackPtr): void
5757
{
58+
/** @var array<int, array{code: int|string, content: string}> $tokens */
5859
$tokens = $phpcsFile->getTokens();
5960

6061
if ($tokens[$stackPtr]['code'] === T_CONST) {

src/Cdn77/Sniffs/NamingConventions/ValidVariableNameSniff.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class ValidVariableNameSniff extends AbstractVariableSniff
4242
*/
4343
protected function processVariable(File $phpcsFile, $stackPtr): void
4444
{
45+
/** @var array<int, array{code: int|string, content: string}> $tokens */
4546
$tokens = $phpcsFile->getTokens();
4647
$varName = ltrim($tokens[$stackPtr]['content'], '$');
4748

@@ -105,6 +106,7 @@ protected function processVariable(File $phpcsFile, $stackPtr): void
105106
*/
106107
protected function processMemberVar(File $phpcsFile, $stackPtr): void
107108
{
109+
/** @var array<int, array{code: int|string, content: string}> $tokens */
108110
$tokens = $phpcsFile->getTokens();
109111

110112
$varName = ltrim($tokens[$stackPtr]['content'], '$');
@@ -137,6 +139,7 @@ protected function processMemberVar(File $phpcsFile, $stackPtr): void
137139
*/
138140
protected function processVariableInString(File $phpcsFile, $stackPtr): void
139141
{
142+
/** @var array<int, array{code: int|string, content: string}> $tokens */
140143
$tokens = $phpcsFile->getTokens();
141144

142145
if (

src/Cdn77/Sniffs/Ordering/AlphabeticallyOrderedConstantsSniff.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ private function fix(File $file, array $namesWithValues): void
139139
private function findConstantNamesWithValuesByVisibility(File $phpcsFile): array
140140
{
141141
$constantNamesWithValues = [];
142+
/** @var array<int, array{code: int|string, content: string}> $tokens */
142143
$tokens = $phpcsFile->getTokens();
143144

144145
foreach ($tokens as $stackPtr => $token) {
@@ -177,6 +178,7 @@ private function findConstantNamesWithValuesByVisibility(File $phpcsFile): array
177178

178179
private function getVisibility(File $phpcsFile, int $constStackPtr): string
179180
{
181+
/** @var array<int, array{code: int|string, content: string}> $tokens */
180182
$tokens = $phpcsFile->getTokens();
181183
$visibilityTokenPointer = $phpcsFile->findPrevious(
182184
types: Tokens::$emptyTokens,
@@ -186,13 +188,14 @@ private function getVisibility(File $phpcsFile, int $constStackPtr): string
186188
);
187189

188190
return in_array($tokens[$visibilityTokenPointer]['code'], [T_PUBLIC, T_PROTECTED, T_PRIVATE], true)
189-
? (string) $tokens[$visibilityTokenPointer]['content']
191+
? $tokens[$visibilityTokenPointer]['content']
190192
: 'public';
191193
}
192194

193195
/** @phpstan-return TypeNameShape|null */
194196
private function findTypeAndConstantName(File $phpcsFile, int $constStackPtr): array|null
195197
{
198+
/** @var array<int, array{code: int|string, content: string}> $tokens */
196199
$tokens = $phpcsFile->getTokens();
197200
$assignmentOperatorTokenPtr = $phpcsFile->findNext(
198201
types: [T_EQUAL, T_SEMICOLON],
@@ -241,6 +244,7 @@ private function findTypeAndConstantName(File $phpcsFile, int $constStackPtr): a
241244

242245
private function findEqualsPointer(File $phpcsFile, int $constNameStackPtr): int|null
243246
{
247+
/** @var array<int, array{code: int|string, content: string}> $tokens */
244248
$tokens = $phpcsFile->getTokens();
245249
$equalsTokenPointer = $phpcsFile->findNext(
246250
types: Tokens::$emptyTokens,
@@ -259,6 +263,7 @@ private function findEqualsPointer(File $phpcsFile, int $constNameStackPtr): int
259263
/** @phpstan-return ValueShape|null */
260264
private function findValue(File $phpcsFile, int $equalsTokenPointer): array|null
261265
{
266+
/** @var array<int, array{code: int|string, content: string}> $tokens */
262267
$tokens = $phpcsFile->getTokens();
263268
$startValueTokenPointer = $phpcsFile->findNext(
264269
types: Tokens::$emptyTokens,

tests/TestCase.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ protected static function checkFile(string $filePath, array $sniffProperties = [
8181

8282
private static function getSniffClassReflection(): ReflectionClass
8383
{
84+
/** @var array<string, ReflectionClass<object>> $reflections */
8485
static $reflections = [];
8586

8687
$className = static::getSniffClassName();

0 commit comments

Comments
 (0)