mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00

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
39 lines
805 B
PHP
39 lines
805 B
PHP
--TEST--
|
|
ArrayObject illegal offset
|
|
--FILE--
|
|
<?php
|
|
|
|
$ao = new ArrayObject([1, 2, 3]);
|
|
try {
|
|
var_dump($ao[[]]);
|
|
} catch (TypeError $e) {
|
|
echo $e->getMessage(), "\n";
|
|
}
|
|
try {
|
|
$ao[[]] = new stdClass;
|
|
} catch (TypeError $e) {
|
|
echo $e->getMessage(), "\n";
|
|
}
|
|
try {
|
|
$ref =& $ao[[]];
|
|
} catch (TypeError $e) {
|
|
echo $e->getMessage(), "\n";
|
|
}
|
|
try {
|
|
var_dump(isset($ao[[]]));
|
|
} catch (TypeError $e) {
|
|
echo $e->getMessage(), "\n";
|
|
}
|
|
try {
|
|
unset($ao[[]]);
|
|
} catch (TypeError $e) {
|
|
echo $e->getMessage(), "\n";
|
|
}
|
|
|
|
?>
|
|
--EXPECT--
|
|
Cannot access offset of type array on ArrayObject
|
|
Cannot access offset of type array on ArrayObject
|
|
Cannot access offset of type array on ArrayObject
|
|
Cannot access offset of type array in isset or empty
|
|
Cannot unset offset of type array on ArrayObject
|