2008-07-27 02:00:18 +08:00
|
|
|
--TEST--
|
2018-08-10 10:19:55 +08:00
|
|
|
Bug #44660 (Indexed and reference assignment to property of non-object don't trigger warning)
|
2008-07-27 02:00:18 +08:00
|
|
|
--FILE--
|
|
|
|
<?php
|
|
|
|
$s = "hello";
|
|
|
|
$a = true;
|
|
|
|
|
|
|
|
echo "--> read access: ";
|
|
|
|
echo $a->p;
|
|
|
|
|
2019-09-26 18:22:48 +08:00
|
|
|
echo "\n--> direct assignment:\n";
|
|
|
|
try {
|
|
|
|
$a->p = $s;
|
|
|
|
} catch (Error $e) {
|
|
|
|
echo $e->getMessage(), "\n";
|
|
|
|
}
|
2008-07-27 02:00:18 +08:00
|
|
|
|
2019-09-26 18:22:48 +08:00
|
|
|
echo "\n--> increment:\n";
|
|
|
|
try {
|
|
|
|
$a->p++;
|
|
|
|
} catch (Error $e) {
|
|
|
|
echo $e->getMessage(), "\n";
|
|
|
|
}
|
2008-07-27 02:00:18 +08:00
|
|
|
|
2019-09-26 18:22:48 +08:00
|
|
|
echo "\n--> reference assignment:\n";
|
|
|
|
try {
|
|
|
|
$a->p =& $s;
|
|
|
|
} catch (Error $e) {
|
|
|
|
echo $e->getMessage(), "\n";
|
|
|
|
}
|
2008-07-27 02:00:18 +08:00
|
|
|
|
2019-09-26 18:22:48 +08:00
|
|
|
echo "\n--> reference assignment:\n";
|
|
|
|
try {
|
|
|
|
$s =& $a->p;
|
|
|
|
} catch (Error $e) {
|
|
|
|
echo $e->getMessage(), "\n";
|
|
|
|
}
|
2008-07-27 02:00:18 +08:00
|
|
|
|
2019-09-26 18:22:48 +08:00
|
|
|
echo "\n--> indexed assignment:\n";
|
|
|
|
try {
|
|
|
|
$a->p[0] = $s;
|
|
|
|
} catch (Error $e) {
|
|
|
|
echo $e->getMessage(), "\n";
|
|
|
|
}
|
2008-07-27 02:00:18 +08:00
|
|
|
|
|
|
|
echo "\n--> Confirm assignments have had no impact:\n";
|
|
|
|
var_dump($a);
|
|
|
|
?>
|
|
|
|
--EXPECTF--
|
|
|
|
--> read access:
|
2019-10-01 19:20:42 +08:00
|
|
|
Warning: Trying to get property 'p' of non-object in %s on line %d
|
2008-07-27 02:00:18 +08:00
|
|
|
|
2019-09-26 18:22:48 +08:00
|
|
|
--> direct assignment:
|
|
|
|
Attempt to assign property 'p' of non-object
|
2008-07-27 02:00:18 +08:00
|
|
|
|
2019-09-26 18:22:48 +08:00
|
|
|
--> increment:
|
|
|
|
Attempt to increment/decrement property 'p' of non-object
|
2008-07-27 02:00:18 +08:00
|
|
|
|
|
|
|
--> reference assignment:
|
2019-09-26 18:22:48 +08:00
|
|
|
Attempt to modify property 'p' of non-object
|
2008-07-27 02:00:18 +08:00
|
|
|
|
|
|
|
--> reference assignment:
|
2019-09-26 18:22:48 +08:00
|
|
|
Attempt to modify property 'p' of non-object
|
2008-07-27 02:00:18 +08:00
|
|
|
|
|
|
|
--> indexed assignment:
|
2019-09-26 18:22:48 +08:00
|
|
|
Attempt to modify property 'p' of non-object
|
2008-07-27 02:00:18 +08:00
|
|
|
|
|
|
|
--> Confirm assignments have had no impact:
|
|
|
|
bool(true)
|