xref: /PHP-8.2/ext/opcache/tests/bug69038.phpt (revision e9f783fc)
1--TEST--
2Bug #69038 (switch(SOMECONSTANT) misbehaves)
3--INI--
4opcache.enable=1
5opcache.enable_cli=1
6opcache.optimization_level=-1
7--EXTENSIONS--
8opcache
9--FILE--
10<?php
11function a($a = "bad") {
12
13    switch (PHP_OS) {
14    case "LALALALA" : return "LALALAL";
15    case PHP_OS: return "okey";
16    default:   break;
17    }
18
19    return $a;
20}
21
22var_dump(a());
23
24
25function b($b = "bad") {
26    switch (PHP_OS) {
27    case "LALALAL": return "bad";
28    case PHP_OS:
29        switch (PHP_OS) {
30        case "FOO": break;
31        case PHP_OS: return "okey";
32        default :
33            break;
34        }
35        break;
36    default:
37        break;
38    }
39    return $b;
40}
41var_dump(b());
42
43function c($b = "bad") {
44    switch (extension_loaded("standard")) {
45    case 0 : return "LALALAL";
46    case 1 : return "okey";
47    default : return "bad";
48    }
49}
50var_dump(c());
51
52function d() {
53    switch (PHP_OS) {
54        default: return "bad";
55        case PHP_OS: return "okey";
56    }
57}
58
59var_dump(d());
60?>
61--EXPECT--
62string(4) "okey"
63string(4) "okey"
64string(4) "okey"
65string(4) "okey"
66