Don't ignore array[0], E_STRICT instead

This commit is contained in:
Xinchen Hui
2013-06-25 14:18:51 +08:00
parent 7e3623a956
commit a91e08303f
4 changed files with 15 additions and 5 deletions

5
lua.c
View File

@@ -454,9 +454,8 @@ int php_lua_send_zval_to_lua(lua_State *L, zval *val TSRMLS_DC) {
break;
case HASH_KEY_IS_LONG:
if (idx == 0) {
php_error_docref(NULL TSRMLS_CC, E_NOTICE
, "attempt to pass an array index begin with 0 to lua, the index 0 will be discarded");
continue;
php_error_docref(NULL TSRMLS_CC, E_STRICT,
"attempt to pass an array index begin with 0 to lua");
}
MAKE_STD_ZVAL(zkey);
ZVAL_LONG(zkey, idx);

View File

@@ -13,4 +13,4 @@ $l->eval("invalid code");
--EXPECTF--
12
-0.53657291800043
Warning: Lua::eval(): lua error: [string "line"]:1: '=' expected near 'code' in %s on line %d
Warning: Lua::eval(): lua error: [string "line"]:1: %s near 'code' in %s on line %d

View File

@@ -28,7 +28,7 @@ Testing fine
Hello PHP
Testing broken
Warning: Lua::include(): lua error: %s '=' expected near 'fdrg' in %s on line %d
Warning: Lua::include(): lua error: %s near 'fdrg' in %s on line %d
Testing return
Array

11
tests/012.phpt Normal file
View File

@@ -0,0 +1,11 @@
--TEST--
Check for index 0
--SKIPIF--
<?php if (!extension_loaded("lua")) print "skip"; ?>
--FILE--
<?php
$l = new lua();
$l->assign("b", range(1, 0));
?>
--EXPECTF--
Strict Standards: Lua::assign(): attempt to pass an array index begin with 0 to lua in %s012.php on line %d