xref: /PHP-8.0/ext/opcache/tests/opt/sccp_011.phpt (revision 0684b9fc)
1--TEST--
2SCCP 011: 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(int $x) {
14    $o = new stdClass;
15    if ($x) {
16        $o->foo = 0;
17        $o->bar = 1;
18    } else {
19        $o->foo = 0;
20        $o->bar = 2;
21    }
22    echo $o->foo;
23}
24?>
25--EXPECTF--
26$_main:
27     ; (lines=1, args=0, vars=0, tmps=0)
28     ; (after optimizer)
29     ; %ssccp_011.php:1-14
300000 RETURN int(1)
31
32foo:
33     ; (lines=3, args=1, vars=1, tmps=0)
34     ; (after optimizer)
35     ; %ssccp_011.php:2-12
360000 CV0($x) = RECV 1
370001 ECHO string("0")
380002 RETURN null
39