xref: /PHP-8.4/ext/opcache/tests/opt/sccp_007.phpt (revision e48a5c14)
1--TEST--
2SCCP 007: Conditional Constant Propagation of non-escaping array elements
3--INI--
4opcache.enable=1
5opcache.enable_cli=1
6opcache.optimization_level=-1
7opcache.opt_debug_level=0x20000
8opcache.preload=
9zend_test.observer.enabled=0
10--EXTENSIONS--
11opcache
12--FILE--
13<?php
14function foo(int $x) {
15    if ($x) {
16        $a = [0,1];
17    } else {
18        $a = [0,2];
19    }
20    echo $a[0];
21}
22?>
23--EXPECTF--
24$_main:
25     ; (lines=1, args=0, vars=0, tmps=0)
26     ; (after optimizer)
27     ; %ssccp_007.php:1-11
280000 RETURN int(1)
29
30foo:
31     ; (lines=3, args=1, vars=1, tmps=0)
32     ; (after optimizer)
33     ; %ssccp_007.php:2-9
340000 CV0($x) = RECV 1
350001 ECHO string("0")
360002 RETURN null
37