Skip to content

Commit 1b549b9

Browse files
phpstan-botclaude
andcommitted
Add exact original issue code as regression test
Adds the HelloWorld class from phpstan/phpstan#13705 to ensure the exact code from the bug report no longer produces a false positive. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 9e186b6 commit 1b549b9

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

tests/PHPStan/Analyser/nsrt/bug-13705.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,3 +127,32 @@ function whileLoopOriginal(int $length, int $quantity): void
127127
}
128128
}
129129
}
130+
131+
class HelloWorld
132+
{
133+
private const MIN_LENGTH = 8;
134+
135+
/**
136+
* @return list<non-empty-string>
137+
*/
138+
public function generatePlainRecoveryCodes(int $length = 8, int $quantity = 8): array
139+
{
140+
if ($length < self::MIN_LENGTH) {
141+
throw new \InvalidArgumentException(
142+
$length . ' is not allowed as length for recovery codes. Must be at least ' . self::MIN_LENGTH,
143+
1613666803
144+
);
145+
}
146+
$codes = [];
147+
while ($quantity >= 1 && count($codes) < $quantity) {
148+
$code = '';
149+
for ($i = 0; $i < $length; $i++) {
150+
$code .= 'x';
151+
}
152+
if (!in_array($code, $codes, true)) {
153+
$codes[] = $code;
154+
}
155+
}
156+
return $codes;
157+
}
158+
}

0 commit comments

Comments
 (0)