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