mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +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
50 lines
918 B
PHP
50 lines
918 B
PHP
--TEST--
|
|
Using isset() with arrays
|
|
--FILE--
|
|
<?php
|
|
|
|
$array = [
|
|
0 => true,
|
|
"a" => true,
|
|
];
|
|
|
|
var_dump(isset($array[0]));
|
|
|
|
var_dump(isset($array["a"]));
|
|
|
|
var_dump(isset($array[false]));
|
|
|
|
var_dump(isset($array[0.6]));
|
|
|
|
var_dump(isset($array[true]));
|
|
|
|
var_dump(isset($array[null]));
|
|
|
|
var_dump(isset($array[STDIN]));
|
|
|
|
try {
|
|
isset($array[[]]);
|
|
} catch (TypeError $exception) {
|
|
echo $exception->getMessage() . "\n";
|
|
}
|
|
|
|
try {
|
|
isset($array[new stdClass()]);
|
|
} catch (TypeError $exception) {
|
|
echo $exception->getMessage() . "\n";
|
|
}
|
|
?>
|
|
--EXPECTF--
|
|
bool(true)
|
|
bool(true)
|
|
bool(true)
|
|
|
|
Deprecated: Implicit conversion from float 0.6 to int loses precision in %s on line %d
|
|
bool(true)
|
|
bool(false)
|
|
bool(false)
|
|
|
|
Warning: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d
|
|
bool(false)
|
|
Cannot access offset of type array in isset or empty
|
|
Cannot access offset of type stdClass in isset or empty
|