mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
Move more low-hanging fruit, creating new directories for the tests for: * comparisons * dynamic calls * error messages * `error_reporting()` * exceptions * `foreach()` * garbage collection * group `use` statements * heredoc and nowdoc * `goto` jumps * late static binding * magic methods * namespaces * numeric literal separators * objects * `settype()` * cleaning of temporary values * `unset()` Additionally, move some tests into the existing subdirectory for `list()` tests. Drive-by fixes of some test numbers in the names of the `goto` tests. Work towards GH-15631
114 lines
1.8 KiB
PHP
114 lines
1.8 KiB
PHP
--TEST--
|
|
Unset on non-array
|
|
--FILE--
|
|
<?php
|
|
|
|
unset($x[0]);
|
|
|
|
$x = null;
|
|
unset($x[0]);
|
|
|
|
$x = false;
|
|
unset($x[0]);
|
|
|
|
$x = true;
|
|
try {
|
|
unset($x[0]);
|
|
} catch (Error $e) {
|
|
echo $e->getMessage(), "\n";
|
|
}
|
|
|
|
$x = 1;
|
|
try {
|
|
unset($x[0]);
|
|
} catch (Error $e) {
|
|
echo $e->getMessage(), "\n";
|
|
}
|
|
|
|
$x = 3.14;
|
|
try {
|
|
unset($x[0]);
|
|
} catch (Error $e) {
|
|
echo $e->getMessage(), "\n";
|
|
}
|
|
|
|
$x = "str";
|
|
try {
|
|
unset($x[0]);
|
|
} catch (Error $e) {
|
|
echo $e->getMessage(), "\n";
|
|
}
|
|
|
|
$x = new stdClass;
|
|
try {
|
|
unset($x[0]);
|
|
} catch (Error $e) {
|
|
echo $e->getMessage(), "\n";
|
|
}
|
|
|
|
// And now repeat the same with a nested offset.
|
|
unset($x);
|
|
|
|
unset($x[0][0]);
|
|
|
|
$x = null;
|
|
unset($x[0][0]);
|
|
|
|
$x = false;
|
|
unset($x[0][0]);
|
|
|
|
$x = true;
|
|
try {
|
|
unset($x[0][0]);
|
|
} catch (Error $e) {
|
|
echo $e->getMessage(), "\n";
|
|
}
|
|
|
|
$x = 1;
|
|
try {
|
|
unset($x[0][0]);
|
|
} catch (Error $e) {
|
|
echo $e->getMessage(), "\n";
|
|
}
|
|
|
|
$x = 3.14;
|
|
try {
|
|
unset($x[0][0]);
|
|
} catch (Error $e) {
|
|
echo $e->getMessage(), "\n";
|
|
}
|
|
|
|
$x = "str";
|
|
try {
|
|
unset($x[0][0]);
|
|
} catch (Error $e) {
|
|
echo $e->getMessage(), "\n";
|
|
}
|
|
|
|
$x = new stdClass;
|
|
try {
|
|
unset($x[0][0]);
|
|
} catch (Error $e) {
|
|
echo $e->getMessage(), "\n";
|
|
}
|
|
|
|
?>
|
|
--EXPECTF--
|
|
Warning: Undefined variable $x in %s on line %d
|
|
|
|
Deprecated: Automatic conversion of false to array is deprecated in %s
|
|
Cannot unset offset in a non-array variable
|
|
Cannot unset offset in a non-array variable
|
|
Cannot unset offset in a non-array variable
|
|
Cannot unset string offsets
|
|
Cannot use object of type stdClass as array
|
|
|
|
Warning: Undefined variable $x in %s on line %d
|
|
|
|
Deprecated: Automatic conversion of false to array is deprecated in %s
|
|
Cannot unset offset in a non-array variable
|
|
Cannot unset offset in a non-array variable
|
|
Cannot unset offset in a non-array variable
|
|
Cannot use string offset as an array
|
|
Cannot use object of type stdClass as array
|