mirror of
https://github.com/php/php-src.git
synced 2024-09-22 02:17:32 +00:00
Add tests for constant expression arrays
Adding one failing (!) test for now about circular constant references embedded in a constant AST, must be fixed before PHP 5.6 release.
This commit is contained in:
parent
05cc46a96b
commit
09d1a8aaab
35
Zend/tests/constant_expressions_arrays.phpt
Normal file
35
Zend/tests/constant_expressions_arrays.phpt
Normal file
@ -0,0 +1,35 @@
|
||||
---TEST---
|
||||
Constant expressions with arrays
|
||||
---FILE---
|
||||
<?php
|
||||
const a = [1,2,[3,[4]]];
|
||||
const b = a[0];
|
||||
const c = a[2][0];
|
||||
const d = a[2];
|
||||
const e = ["string" => [1]]["string"][0];
|
||||
|
||||
var_dump(b, c, e);
|
||||
|
||||
function test ($a = d[1][0]) {
|
||||
var_dump($a);
|
||||
}
|
||||
|
||||
test();
|
||||
|
||||
class foo {
|
||||
const bar = [1][0];
|
||||
}
|
||||
|
||||
var_dump(foo::bar);
|
||||
|
||||
var_dump(a); // Eventually allow that later with array dereferencing of constants
|
||||
|
||||
?>
|
||||
---EXPECTF---
|
||||
int(1)
|
||||
int(3)
|
||||
int(1)
|
||||
int(4)
|
||||
int(1)
|
||||
|
||||
Fatal error: Arrays are not allowed in constants at run-time in %s on line %d
|
13
Zend/tests/constant_expressions_self_referencing_array.phpt
Normal file
13
Zend/tests/constant_expressions_self_referencing_array.phpt
Normal file
@ -0,0 +1,13 @@
|
||||
---TEST---
|
||||
Self-referencing constant expression (part of a constant AST)
|
||||
---FILE---
|
||||
<?php
|
||||
class A {
|
||||
const FOO = [self::BAR];
|
||||
const BAR = [self::FOO];
|
||||
}
|
||||
var_dump(A::FOO);
|
||||
?>
|
||||
---EXPECTF---
|
||||
Fatal error: Cannot declare self-referencing constant 'self::FOO' in %s on line %d
|
||||
|
Loading…
Reference in New Issue
Block a user