xref: /php-src/ext/opcache/tests/opt/gh14873.phpt (revision 1a07bb92)
1--TEST--
2GH-14873 (PHP 8.4 min function fails on typed integer)
3--EXTENSIONS--
4opcache
5--INI--
6opcache.enable=1
7opcache.enable_cli=1
8opcache.optimization_level=0x7FFEBFFF
9opcache.opt_debug_level=0x20000
10--FILE--
11<?php
12
13function testTrim1(string $value): string {
14	$value = trim($value);
15	return $value;
16}
17
18function testMin2First(int $value): int {
19	$value = min($value, 100);
20	return $value;
21}
22
23function testMin2Second(int $value): int {
24	$value = min(100, $value);
25	return $value;
26}
27
28function testMin2_TMP(int $value): int {
29	$value = min($value + 1, 100);
30	return $value;
31}
32
33function testStrstr3First(string $value): string {
34	$value = strstr($value, "needle", false);
35	return $value;
36}
37
38function testStrstr3Second(string $value): string {
39	$value = strstr("needles", $value, false);
40	return $value;
41}
42
43function testStrstr3Third(bool $value): string {
44	$value = strstr("needles", "needle", $value);
45	return $value;
46}
47
48var_dump(testTrim1(" boo "));
49var_dump(testMin2First(5));
50var_dump(testMin2Second(5));
51var_dump(testMin2_TMP(5));
52var_dump(testStrstr3First("needles"));
53var_dump(testStrstr3Second("needle"));
54var_dump(testStrstr3Third(false));
55
56?>
57--EXPECTF--
58$_main:
59     ; (lines=43, args=0, vars=0, tmps=%d)
60     ; (after optimizer)
61     ; %s
620000 INIT_FCALL 1 %d string("var_dump")
630001 INIT_FCALL 1 %d string("testtrim1")
640002 SEND_VAL string(" boo ") 1
650003 V0 = DO_UCALL
660004 SEND_VAR V0 1
670005 DO_ICALL
680006 INIT_FCALL 1 %d string("var_dump")
690007 INIT_FCALL 1 %d string("testmin2first")
700008 SEND_VAL int(5) 1
710009 V0 = DO_UCALL
720010 SEND_VAR V0 1
730011 DO_ICALL
740012 INIT_FCALL 1 %d string("var_dump")
750013 INIT_FCALL 1 %d string("testmin2second")
760014 SEND_VAL int(5) 1
770015 V0 = DO_UCALL
780016 SEND_VAR V0 1
790017 DO_ICALL
800018 INIT_FCALL 1 %d string("var_dump")
810019 INIT_FCALL 1 %d string("testmin2_tmp")
820020 SEND_VAL int(5) 1
830021 V0 = DO_UCALL
840022 SEND_VAR V0 1
850023 DO_ICALL
860024 INIT_FCALL 1 %d string("var_dump")
870025 INIT_FCALL 1 %d string("teststrstr3first")
880026 SEND_VAL string("needles") 1
890027 V0 = DO_UCALL
900028 SEND_VAR V0 1
910029 DO_ICALL
920030 INIT_FCALL 1 %d string("var_dump")
930031 INIT_FCALL 1 %d string("teststrstr3second")
940032 SEND_VAL string("needle") 1
950033 V0 = DO_UCALL
960034 SEND_VAR V0 1
970035 DO_ICALL
980036 INIT_FCALL 1 %d string("var_dump")
990037 INIT_FCALL 1 %d string("teststrstr3third")
1000038 SEND_VAL bool(false) 1
1010039 V0 = DO_UCALL
1020040 SEND_VAR V0 1
1030041 DO_ICALL
1040042 RETURN int(1)
105
106testTrim1:
107     ; (lines=4, args=1, vars=1, tmps=%d)
108     ; (after optimizer)
109     ; %s
1100000 CV0($value) = RECV 1
1110001 T1 = FRAMELESS_ICALL_1(trim) CV0($value)
1120002 ASSIGN CV0($value) T1
1130003 RETURN CV0($value)
114
115testMin2First:
116     ; (lines=5, args=1, vars=1, tmps=%d)
117     ; (after optimizer)
118     ; %s
1190000 CV0($value) = RECV 1
1200001 T1 = FRAMELESS_ICALL_2(min) CV0($value) int(100)
1210002 CV0($value) = QM_ASSIGN T1
1220003 VERIFY_RETURN_TYPE CV0($value)
1230004 RETURN CV0($value)
124
125testMin2Second:
126     ; (lines=5, args=1, vars=1, tmps=%d)
127     ; (after optimizer)
128     ; %s
1290000 CV0($value) = RECV 1
1300001 T1 = FRAMELESS_ICALL_2(min) int(100) CV0($value)
1310002 CV0($value) = QM_ASSIGN T1
1320003 VERIFY_RETURN_TYPE CV0($value)
1330004 RETURN CV0($value)
134
135testMin2_TMP:
136     ; (lines=5, args=1, vars=1, tmps=%d)
137     ; (after optimizer)
138     ; %s
1390000 CV0($value) = RECV 1
1400001 T1 = ADD CV0($value) int(1)
1410002 CV0($value) = FRAMELESS_ICALL_2(min) T1 int(100)
1420003 VERIFY_RETURN_TYPE CV0($value)
1430004 RETURN CV0($value)
144
145testStrstr3First:
146     ; (lines=6, args=1, vars=1, tmps=%d)
147     ; (after optimizer)
148     ; %s
1490000 CV0($value) = RECV 1
1500001 T1 = FRAMELESS_ICALL_3(strstr) CV0($value) string("needle")
1510002 OP_DATA bool(false)
1520003 ASSIGN CV0($value) T1
1530004 VERIFY_RETURN_TYPE CV0($value)
1540005 RETURN CV0($value)
155LIVE RANGES:
156     1: 0002 - 0003 (tmp/var)
157
158testStrstr3Second:
159     ; (lines=6, args=1, vars=1, tmps=%d)
160     ; (after optimizer)
161     ; %s
1620000 CV0($value) = RECV 1
1630001 T1 = FRAMELESS_ICALL_3(strstr) string("needles") CV0($value)
1640002 OP_DATA bool(false)
1650003 ASSIGN CV0($value) T1
1660004 VERIFY_RETURN_TYPE CV0($value)
1670005 RETURN CV0($value)
168LIVE RANGES:
169     1: 0002 - 0003 (tmp/var)
170
171testStrstr3Third:
172     ; (lines=6, args=1, vars=1, tmps=%d)
173     ; (after optimizer)
174     ; %s
1750000 CV0($value) = RECV 1
1760001 T1 = FRAMELESS_ICALL_3(strstr) string("needles") string("needle")
1770002 OP_DATA CV0($value)
1780003 CV0($value) = QM_ASSIGN T1
1790004 VERIFY_RETURN_TYPE CV0($value)
1800005 RETURN CV0($value)
181LIVE RANGES:
182     1: 0002 - 0003 (tmp/var)
183string(3) "boo"
184int(5)
185int(5)
186int(6)
187string(7) "needles"
188string(7) "needles"
189string(7) "needles"
190