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;
|
|
|
|
|
2020-04-24 16:58:46 +08:00
|
|
|
echo "--> read access:";
|
2008-07-27 02:00:18 +08:00
|
|
|
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--
|
2020-04-24 16:58:46 +08:00
|
|
|
--> read access:
|
2020-05-26 20:10:57 +08:00
|
|
|
Warning: Attempt to read property "p" on bool in %s on line %d
|
2008-07-27 02:00:18 +08:00
|
|
|
|
2019-09-26 18:22:48 +08:00
|
|
|
--> direct assignment:
|
2020-05-26 20:10:57 +08:00
|
|
|
Attempt to assign property "p" on bool
|
2008-07-27 02:00:18 +08:00
|
|
|
|
2019-09-26 18:22:48 +08:00
|
|
|
--> increment:
|
2020-05-26 20:10:57 +08:00
|
|
|
Attempt to increment/decrement property "p" on bool
|
2008-07-27 02:00:18 +08:00
|
|
|
|
|
|
|
--> reference assignment:
|
2020-05-26 20:10:57 +08:00
|
|
|
Attempt to modify property "p" on bool
|
2008-07-27 02:00:18 +08:00
|
|
|
|
|
|
|
--> reference assignment:
|
2020-05-26 20:10:57 +08:00
|
|
|
Attempt to modify property "p" on bool
|
2008-07-27 02:00:18 +08:00
|
|
|
|
|
|
|
--> indexed assignment:
|
2020-05-26 20:10:57 +08:00
|
|
|
Attempt to modify property "p" on bool
|
2008-07-27 02:00:18 +08:00
|
|
|
|
|
|
|
--> Confirm assignments have had no impact:
|
|
|
|
bool(true)
|