Skip to content

Commit 32cfae1

Browse files
clxmstaabondrejmirtes
authored andcommitted
simpler test
1 parent 3d069e0 commit 32cfae1

File tree

1 file changed

+17
-24
lines changed

1 file changed

+17
-24
lines changed

tests/PHPStan/Analyser/data/bug-6439.php

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -33,30 +33,23 @@ public function unionOnRight(string $name, ?int $gesperrt = null, ?int $adaid =
3333
assertType("'branch-a general'|'branch-b branch-a general'|'branch-b general'|'general'", $string);
3434
}
3535

36-
public function testLimit() {
37-
$string = '0';
38-
39-
if (rand(0,1)) {
40-
$string .= 'a';
41-
}
42-
if (rand(0,1)) {
43-
$string .= 'b';
44-
}
45-
if (rand(0,1)) {
46-
$string .= 'c';
47-
}
48-
if (rand(0,1)) {
49-
$string .= 'd';
50-
}
36+
/**
37+
* @param '1'|'2'|'3'|'4'|'5'|'6'|'7'|'8'|'9'|'10'|'11'|'12'|'13'|'14'|'15' $s15
38+
* @param '1'|'2'|'3'|'4'|'5'|'6'|'7'|'8'|'9'|'10'|'11'|'12'|'13'|'14'|'15'|'16' $s16
39+
* @param '1'|'2'|'3'|'4'|'5'|'6'|'7'|'8'|'9'|'10'|'11'|'12'|'13'|'14'|'15'|'16'|'17' $s17
40+
*/
41+
public function testLimit(string $s15, string $s16, string $s17) {
5142
if (rand(0,1)) {
52-
$string .= 'e';
53-
54-
// union should contain 32 elements
55-
assertType("'0'|'0a'|'0ab'|'0abc'|'0abcd'|'0abcde'|'0abce'|'0abd'|'0abde'|'0abe'|'0ac'|'0acd'|'0acde'|'0ace'|'0ad'|'0ade'|'0ae'|'0b'|'0bc'|'0bcd'|'0bcde'|'0bce'|'0bd'|'0bde'|'0be'|'0c'|'0cd'|'0cde'|'0ce'|'0d'|'0de'|'0e'", $string);
56-
57-
// adding more elements should fallback to the more general form
58-
$string .= 'too-long';
59-
assertType("literal-string&non-empty-string", $string);
60-
}
43+
// doubles the number of elements
44+
$s15 .= 'a';
45+
$s16 .= 'a';
46+
$s17 .= 'a';
47+
}
48+
// union should contain 30 elements
49+
assertType("'1'|'10'|'10a'|'11'|'11a'|'12'|'12a'|'13'|'13a'|'14'|'14a'|'15'|'15a'|'1a'|'2'|'2a'|'3'|'3a'|'4'|'4a'|'5'|'5a'|'6'|'6a'|'7'|'7a'|'8'|'8a'|'9'|'9a'", $s15);
50+
// union should contain 32 elements
51+
assertType("'1'|'10'|'10a'|'11'|'11a'|'12'|'12a'|'13'|'13a'|'14'|'14a'|'15'|'15a'|'16'|'16a'|'1a'|'2'|'2a'|'3'|'3a'|'4'|'4a'|'5'|'5a'|'6'|'6a'|'7'|'7a'|'8'|'8a'|'9'|'9a'", $s16);
52+
// fallback to the more general form
53+
assertType("literal-string&non-empty-string", $s17);
6154
}
6255
}

0 commit comments

Comments
 (0)