xref: /PHP-8.2/ext/opcache/tests/bug76281.phpt (revision e9f783fc)
1--TEST--
2Bug #76281: Opcache causes incorrect "undefined variable" errors
3--EXTENSIONS--
4opcache
5--FILE--
6<?php
7
8function test($r, $action) {
9    $user_sub_resource = in_array($action, array('get_securityquestions', 'get_status', 'get_groupstats'));
10
11    $user_id = null;
12    if ($user_sub_resource && isset($r['user_id'])) {
13        $user_id = $r['user_id'];
14    }
15    else if (isset($r['id']))  {
16        $user_id = $r['id'];
17    }
18
19    if ($user_sub_resource) {
20        return 'foo';
21    }
22
23    return 'bar';
24}
25
26var_dump(test(['user_id' => 1, 'id' => 2], 'foo'));
27
28?>
29--EXPECT--
30string(3) "bar"
31