xref: /PHP-7.4/ext/opcache/tests/opt/sccp_004.phpt (revision 12edc453)
1--TEST--
2SCCP 004: 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	$a = [1,2,3];
15	$a[2] = $x;
16	$i = 1;
17	$c = $i < 2;
18	if ($c) {
19		$k = 2 * $i;
20		$a[$k] = $i;
21//		$a[$k]++;
22		echo isset($a[$k]);
23//		$a[$k] += 5;
24	}
25	echo $a[2];
26}
27?>
28--EXPECTF--
29$_main: ; (lines=1, args=0, vars=0, tmps=0)
30    ; (after optimizer)
31    ; %ssccp_004.php:1-17
32L0 (17):    RETURN int(1)
33
34foo: ; (lines=4, args=1, vars=1, tmps=0)
35    ; (after optimizer)
36    ; %ssccp_004.php:2-15
37L0 (2):     CV0($x) = RECV 1
38L1 (11):    ECHO bool(true)
39L2 (14):    ECHO int(1)
40L3 (15):    RETURN null
41