xref: /PHP-8.3/ext/opcache/tests/jit/cmp_006.phpt (revision 95e0cc06)
1--TEST--
2JIT CMP: 006 Undefined variable checks
3--INI--
4opcache.enable=1
5opcache.enable_cli=1
6opcache.file_update_protection=0
7opcache.jit_buffer_size=1M
8opcache.protect_memory=1
9--FILE--
10<?php
11function test1($c) {
12    if ($c) {
13        $x = 1;
14    }
15    var_dump($x == 1);
16}
17function test2($c) {
18    if ($c) {
19        $x = 1.0;
20    }
21    var_dump($x == 1.0);
22}
23function test3($c) {
24    if (!$c) {
25        $x = 1;
26    }
27    if ($c) {
28        $y = 1;
29    }
30    var_dump($x == $y);
31}
32function test4($c) {
33    if (!$c) {
34        $x = 1.0;
35    }
36    if ($c) {
37        $y = 1.0;
38    }
39    var_dump($x == $y);
40}
41test1(false);
42test2(false);
43test3(false);
44test4(false);
45?>
46--EXPECTF--
47Warning: Undefined variable $x in %s on line %d
48bool(false)
49
50Warning: Undefined variable $x in %s on line %d
51bool(false)
52
53Warning: Undefined variable $y in %s on line %d
54bool(false)
55
56Warning: Undefined variable $y in %s on line %d
57bool(false)
58