php-src/Zend/tests/bug24773.phpt
George Peter Banyard 99fa740acb
Use common function for TypeError on illegal offset access (#10544)
This merges all usages of emitting an offset TypeError into a new ZEND_API function
zend_illegal_container_offset(const zend_string* container, const zval *offset, int type);

Where the container should represent the type on which the access is attempted (e.g. string, array)
The offset zval that is used, where the error message will display its type
The type of access, which should be a BP_VAR_* constant, to get special message for isset/empty/unset
2023-06-06 11:28:19 +01:00

13 lines
281 B
PHP

--TEST--
Bug #24773 (unset() of integers treated as arrays causes a crash)
--FILE--
<?php
$array = 'test';
unset($array["lvl1"]["lvl2"]["b"]);
?>
--EXPECTF--
Fatal error: Uncaught Error: Cannot unset string offsets in %s:%d
Stack trace:
#0 {main}
thrown in %s on line %d