1--TEST--
2Dynamic Constant Expressions
3--FILE--
4<?php
5
6const C_0 = 0;
7const C_1 = 1;
8const C_foo = "0foo";
9const C_arr = [0 => 0, "foo" => "foo"];
10
11const T_1 = C_1 | 2;
12const T_2 = C_1 . "foo";
13const T_3 = C_1 > 1;
14const T_4 = C_1 >= 1;
15const T_5 = -C_1;
16const T_6 = +C_1;
17const T_7 = +C_foo;
18const T_8 = !C_1;
19const T_9 = C_0 || 0;
20const T_10 = C_1 || 0;
21const T_11 = C_0 && 1;
22const T_12 = C_1 && 1;
23const T_13 = C_0 ? "foo" : "bar";
24const T_14 = C_1 ? "foo" : "bar";
25const T_15 = C_0 ?: "bar";
26const T_16 = C_1 ?: "bar";
27const T_17 = C_arr[0];
28const T_18 = C_arr["foo"];
29const T_19 = [
30    C_0,
31    "foo" => "foo",
32    42 => 42,
33    3.14 => 3.14,
34    null => null,
35    false => false,
36    true => true,
37];
38eval("const T_20x = 'a';");
39const T_20 = null ?: (T_20x . 'bc');
40
41var_dump(
42    T_1, T_2, T_3, T_4, T_5, T_6, T_7, T_8, T_9, T_10,
43    T_11, T_12, T_13, T_14, T_15, T_16, T_17, T_18, T_19, T_20
44);
45
46?>
47--EXPECTF--
48Warning: A non-numeric value encountered in %s on line %d
49
50Deprecated: Implicit conversion from float 3.14 to int loses precision in %s on line %d
51int(3)
52string(4) "1foo"
53bool(false)
54bool(true)
55int(-1)
56int(1)
57int(0)
58bool(false)
59bool(false)
60bool(true)
61bool(false)
62bool(true)
63string(3) "bar"
64string(3) "foo"
65string(3) "bar"
66int(1)
67int(0)
68string(3) "foo"
69array(6) {
70  [0]=>
71  bool(false)
72  ["foo"]=>
73  string(3) "foo"
74  [42]=>
75  int(42)
76  [3]=>
77  float(3.14)
78  [""]=>
79  NULL
80  [1]=>
81  bool(true)
82}
83string(3) "abc"
84