xref: /PHP-8.1/ext/opcache/tests/opt/sccp_012.phpt (revision e9f783fc)
1--TEST--
2SCCP 012: 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--EXTENSIONS--
10opcache
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    $o->foo += 2;
24    $o->foo++;
25    echo $o->foo;
26}
27?>
28--EXPECTF--
29$_main:
30     ; (lines=1, args=0, vars=0, tmps=0)
31     ; (after optimizer)
32     ; %ssccp_012.php:1-17
330000 RETURN int(1)
34
35foo:
36     ; (lines=3, args=0, vars=0, tmps=0)
37     ; (after optimizer)
38     ; %ssccp_012.php:2-15
390000 ECHO string("1")
400001 ECHO string("4")
410002 RETURN null
42