xref: /PHP-8.4/ext/opcache/tests/opt/coalesce.phpt (revision e48a5c14)
1--TEST--
2COALESCE optimization
3--INI--
4opcache.enable=1
5opcache.enable_cli=1
6opcache.optimization_level=-1
7opcache.opt_debug_level=0x20000
8zend_test.observer.enabled=0
9--EXTENSIONS--
10opcache
11--FILE--
12<?php
13
14function a() {
15    $test = $test ?? true;
16    return $test;
17}
18
19function b() {
20    $test ??= true;
21    return $test;
22}
23
24?>
25--EXPECTF--
26$_main:
27     ; (lines=1, args=0, vars=0, tmps=0)
28     ; (after optimizer)
29     ; %s
300000 RETURN int(1)
31
32a:
33     ; (lines=2, args=0, vars=1, tmps=1)
34     ; (after optimizer)
35     ; %s
360000 T1 = COALESCE CV0($test) 0001
370001 RETURN bool(true)
38
39b:
40     ; (lines=2, args=0, vars=1, tmps=1)
41     ; (after optimizer)
42     ; %s
430000 T1 = COALESCE CV0($test) 0001
440001 RETURN bool(true)
45