xref: /PHP-8.4/Zend/tests/bug69017.phpt (revision f8d79582)
1--TEST--
2#69017 (Fail to push to the empty array with the constant value defined in class scope)
3--FILE--
4<?php
5
6class c1
7{
8    const ZERO = 0;
9    const ONE = 1;
10    const MAX = PHP_INT_MAX;
11    public static $a1 = array(self::ONE => 'one');
12    public static $a2 = array(self::ZERO => 'zero');
13    public static $a3 = array(self::MAX => 'zero');
14}
15
16
17c1::$a1[] = 1;
18c1::$a2[] = 1;
19try {
20    c1::$a3[] = 1;
21} catch (Error $e) {
22    echo $e->getMessage(), "\n";
23}
24
25var_dump(c1::$a1);
26var_dump(c1::$a2);
27var_dump(c1::$a3);
28?>
29--EXPECTF--
30Cannot add element to the array as the next element is already occupied
31array(2) {
32  [1]=>
33  string(3) "one"
34  [2]=>
35  int(1)
36}
37array(2) {
38  [0]=>
39  string(4) "zero"
40  [1]=>
41  int(1)
42}
43array(1) {
44  [%d]=>
45  string(4) "zero"
46}
47