forked from phpstan/phpstan-src
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbug-13705.php
More file actions
35 lines (31 loc) · 694 Bytes
/
bug-13705.php
File metadata and controls
35 lines (31 loc) · 694 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php declare(strict_types = 1);
namespace Bug13705;
use function PHPStan\Testing\assertType;
function whileLoop(): void
{
$quantity = random_int(1, 42);
$codes = [];
while (count($codes) < $quantity) {
assertType('list<non-empty-string>', $codes);
$code = random_bytes(16);
if (!in_array($code, $codes, true)) {
$codes[] = $code;
}
}
}
function whileLoopOriginal(int $length, int $quantity): void
{
if ($length < 8) {
throw new \InvalidArgumentException();
}
$codes = [];
while ($quantity >= 1 && count($codes) < $quantity) {
$code = '';
for ($i = 0; $i < $length; $i++) {
$code .= 'x';
}
if (!in_array($code, $codes, true)) {
$codes[] = $code;
}
}
}