xref: /php-src/Zend/tests/bug50816.phpt (revision 7aacc705)
1--TEST--
2Bug #50816 (Using class constants in array definition fails)
3--FILE--
4<?php
5define("ONE", 1);
6define("TWO", 1);
7
8class Foo {
9  const ONE = 1;
10  const TWO = 1;
11
12  public static $mapWithConst = array(self::ONE => 'one', self::TWO => 'two',);
13
14  public static $mapWithConst1 = array(1 => 'one', self::TWO => 'two',);
15  public static $mapWithConst2 = array(self::ONE => 'one', 1 => 'two',);
16
17  public static $mapWithoutConst = array(1 => 'one', 1 => 'two',);
18}
19
20$mapWithConst = array(1 => 'one', 1 => 'two',);
21
22$mapWithoutConst = array(Foo::ONE => 'one', Foo::TWO => 'two',);
23$mapWithoutConst0 = array(1 => 'one', 1 => 'two',);
24$mapWithoutConst1 = array(ONE => 'one', 1 => 'two',);
25$mapWithoutConst2 = array(1 => 'one', TWO => 'two',);
26$mapWithoutConst3 = array(ONE => 'one', TWO => 'two',);
27
28var_dump(Foo::$mapWithConst[1]);
29var_dump(Foo::$mapWithConst1[1]);
30var_dump(Foo::$mapWithConst2[1]);
31var_dump(Foo::$mapWithoutConst[1]);
32var_dump($mapWithConst[1]);
33var_dump($mapWithoutConst[1]);
34var_dump($mapWithoutConst0[1]);
35var_dump($mapWithoutConst1[1]);
36var_dump($mapWithoutConst2[1]);
37var_dump($mapWithoutConst3[1]);
38?>
39--EXPECT--
40string(3) "two"
41string(3) "two"
42string(3) "two"
43string(3) "two"
44string(3) "two"
45string(3) "two"
46string(3) "two"
47string(3) "two"
48string(3) "two"
49string(3) "two"
50