Skip to content

Commit c2e4e1a

Browse files
committed
Fix PHPStan notice on PHPStan 2.1.23
1 parent ed8e4d3 commit c2e4e1a

5 files changed

Lines changed: 13 additions & 3 deletions

File tree

rules/CodingStyle/Rector/Stmt/NewlineAfterStatementRector.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,9 @@ private function processAddNewLine(
129129
continue;
130130
}
131131

132+
/** @var Stmt $stmt */
132133
$endLine = $stmt->getEndLine();
134+
/** @var Stmt $nextStmt */
133135
$line = $nextStmt->getStartLine();
134136
$rangeLine = $line - $endLine;
135137

rules/Php70/EregToPcreTransformer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ private function processBracket(string $content, int $i, int $l, array &$r, int
215215
} else {
216216
$position = $i + 1;
217217
[$t, $ii] = $this->_ere2pcre($content, $position);
218-
if ($ii >= $l || $content[$ii] !== ')') {
218+
if ($ii >= $l || ! isset($content[$ii]) || $content[$ii] !== ')') {
219219
throw new InvalidEregException('"(" does not have a matching ")"');
220220
}
221221

@@ -265,7 +265,7 @@ private function processSquareBracket(string $s, int $i, int $l, string $cls, bo
265265
}
266266

267267
$start = false;
268-
} while ($i < $l && $s[$i] !== ']');
268+
} while ($i < $l && isset($s[$i]) && $s[$i] !== ']');
269269

270270
return [$cls, $i];
271271
}

rules/Php70/Rector/FuncCall/CallUserMethodRector.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ public function refactor(Node $node): ?Node
6767
return null;
6868
}
6969

70+
if (! isset(self::OLD_TO_NEW_FUNCTIONS[$this->getName($node)])) {
71+
return null;
72+
}
73+
7074
$newName = self::OLD_TO_NEW_FUNCTIONS[$this->getName($node)];
7175
$node->name = new Name($newName);
7276

rules/Php73/Rector/FuncCall/ArrayKeyFirstLastRector.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,10 @@ private function processArrayKeyFirstLast(
147147
continue;
148148
}
149149

150+
if (! isset(self::PREVIOUS_TO_NEW_FUNCTIONS[$this->getName($stmt->expr)])) {
151+
continue;
152+
}
153+
150154
$newName = self::PREVIOUS_TO_NEW_FUNCTIONS[$this->getName($stmt->expr)];
151155
$keyFuncCall->name = new Name($newName);
152156

rules/Php81/Rector/FuncCall/NullToStrictStringFuncCallArgRector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public function provideMinPhpVersion(): int
142142
private function resolveNamedPositions(FuncCall $funcCall, array $args): array
143143
{
144144
$functionName = $this->getName($funcCall);
145-
$argNames = NameNullToStrictNullFunctionMap::FUNCTION_TO_PARAM_NAMES[$functionName];
145+
$argNames = NameNullToStrictNullFunctionMap::FUNCTION_TO_PARAM_NAMES[$functionName] ?? [];
146146
$positions = [];
147147

148148
foreach ($args as $position => $arg) {

0 commit comments

Comments
 (0)