xref: /PHP-8.1/ext/opcache/tests/bug80900.phpt (revision 7c6cf094)
1--TEST--
2Bug 80900: Switch constant with incorrect type
3--INI--
4opcache.enable=1
5opcache.enable_cli=1
6opcache.optimization_level=-1
7--EXTENSIONS--
8opcache
9--FILE--
10<?php
11function switchLong() {
12    $var = 'foo';
13    /* The number of case clauses needs to be greater than 5,
14     * otherwise it will not be compiled into SWITCH_LONG. */
15    switch ($var) {
16        case 1:
17            echo 'no1';
18            break;
19        case 2:
20            echo 'no2';
21            break;
22        case 3:
23            echo 'no3';
24            break;
25        case 4:
26            echo 'no4';
27            break;
28        case 5:
29            echo 'no5';
30            break;
31        default:
32            echo 'yes';
33            break;
34    }
35    echo PHP_EOL;
36}
37
38function switchString() {
39    $var = false;
40    switch ($var) {
41        case 'string':
42            echo 'no';
43            break;
44        default:
45            echo 'yes';
46            break;
47    }
48    echo PHP_EOL;
49}
50
51switchLong();
52switchString();
53?>
54--EXPECT--
55yes
56yes
57