xref: /PHP-7.4/ext/opcache/tests/opt/sccp_010.phpt (revision 12edc453)
1--TEST--
2SCCP 010: Conditional Constant Propagation of non-escaping object properties
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() {
14    $o = new stdClass();
15    $o->foo = 0;
16	$i = 1;
17	$c = $i < 2;
18	if ($c) {
19		$k = 2 * $i;
20		$o->foo = $i;
21		echo $o->foo;
22	}
23	echo $o->foo;
24}
25?>
26--EXPECTF--
27$_main: ; (lines=1, args=0, vars=0, tmps=0)
28    ; (after optimizer)
29    ; %ssccp_010.php:1-15
30L0 (15):    RETURN int(1)
31
32foo: ; (lines=3, args=0, vars=0, tmps=0)
33    ; (after optimizer)
34    ; %ssccp_010.php:2-13
35L0 (10):    ECHO int(1)
36L1 (12):    ECHO int(1)
37L2 (13):    RETURN null
38