xref: /PHP-8.0/ext/opcache/tests/opt/sccp_007.phpt (revision 0684b9fc)
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=
9--SKIPIF--
10<?php require_once('skipif.inc'); ?>
11--FILE--
12<?php
13function foo(int $x) {
14    if ($x) {
15        $a = [0,1];
16    } else {
17        $a = [0,2];
18    }
19    echo $a[0];
20}
21?>
22--EXPECTF--
23$_main:
24     ; (lines=1, args=0, vars=0, tmps=0)
25     ; (after optimizer)
26     ; %ssccp_007.php:1-11
270000 RETURN int(1)
28
29foo:
30     ; (lines=3, args=1, vars=1, tmps=0)
31     ; (after optimizer)
32     ; %ssccp_007.php:2-9
330000 CV0($x) = RECV 1
340001 ECHO string("0")
350002 RETURN null
36