diff options
author | Nikita Popov <nikic@php.net> | 2016-09-28 23:11:02 +0200 |
---|---|---|
committer | Nikita Popov <nikic@php.net> | 2016-09-28 23:11:02 +0200 |
commit | 1f5412982cd65800b061cef4877d0fd87662568b (patch) | |
tree | 7f7c1969c1e79d9467e269026fdc8fb41bbd68eb /Zend | |
parent | 40b8105cca1fa3cc4b696b059308b6d0f2827fa8 (diff) | |
download | php-git-1f5412982cd65800b061cef4877d0fd87662568b.tar.gz |
Handle resource keys in constexpr arrays
Diffstat (limited to 'Zend')
-rw-r--r-- | Zend/tests/const_array_with_resource_key.phpt | 15 | ||||
-rw-r--r-- | Zend/zend_compile.c | 3 |
2 files changed, 18 insertions, 0 deletions
diff --git a/Zend/tests/const_array_with_resource_key.phpt b/Zend/tests/const_array_with_resource_key.phpt new file mode 100644 index 0000000000..2533b787e6 --- /dev/null +++ b/Zend/tests/const_array_with_resource_key.phpt @@ -0,0 +1,15 @@ +--TEST-- +Constexpr arrays should be able to handle resource keys +--FILE-- +<?php + +const FOO = [STDIN => 42]; +var_dump(FOO); + +?> +--EXPECTF-- +Strict Standards: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d +array(1) { + [%d]=> + int(42) +} diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index d3bec3714e..f91f029e48 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -5940,6 +5940,9 @@ void zend_do_add_static_array_element(zval *result, zval *offset, zval *expr) /* case IS_NULL: zend_symtable_update(Z_ARRVAL_P(result), "", 1, &expr, sizeof(zval *), NULL); break; + case IS_RESOURCE: + zend_error(E_STRICT, "Resource ID#%ld used as offset, casting to integer (%ld)", Z_LVAL_P(offset), Z_LVAL_P(offset)); + /* break missing intentionally */ case IS_LONG: case IS_BOOL: zend_hash_index_update(Z_ARRVAL_P(result), Z_LVAL_P(offset), &expr, sizeof(zval *), NULL); |