xref: /PHP-8.3/ext/opcache/tests/bug81015.phpt (revision 178bbe34)
1--TEST--
2Bug #81015: Opcache optimization assumes wrong part of ternary operator in if-condition
3--FILE--
4<?php
5
6function ternary(bool $enabled, ?string $value): void
7{
8	// the "true" part is not as trivial in the real case
9	if ($enabled ? true : $value === null) {
10		echo ($value ?? 'NULL') . "\n";
11	} else {
12		echo "INVALID\n";
13	}
14}
15
16ternary(true, 'value');
17ternary(true, null);
18ternary(false, 'value');
19ternary(false, null);
20
21?>
22--EXPECT--
23value
24NULL
25INVALID
26NULL
27