xref: /PHP-8.0/ext/opcache/tests/opt/coalesce.phpt (revision 0684b9fc)
1--TEST--
2COALESCE optimization
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
12
13function a() {
14    $test = $test ?? true;
15    return $test;
16}
17
18function b() {
19    $test ??= true;
20    return $test;
21}
22
23?>
24--EXPECTF--
25$_main:
26     ; (lines=1, args=0, vars=0, tmps=0)
27     ; (after optimizer)
28     ; %s
290000 RETURN int(1)
30
31a:
32     ; (lines=2, args=0, vars=1, tmps=1)
33     ; (after optimizer)
34     ; %s
350000 T1 = COALESCE CV0($test) 0001
360001 RETURN bool(true)
37
38b:
39     ; (lines=2, args=0, vars=1, tmps=1)
40     ; (after optimizer)
41     ; %s
420000 T1 = COALESCE CV0($test) 0001
430001 RETURN bool(true)
44