mirror of
https://github.com/php/php-src.git
synced 2026-04-03 22:22:18 +02:00
25
Zend/tests/bug78810.phpt
Normal file
25
Zend/tests/bug78810.phpt
Normal file
@@ -0,0 +1,25 @@
|
||||
--TEST--
|
||||
Bug #78810: RW fetches do not throw "uninitialized property" exception
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
class Test {
|
||||
public int $i;
|
||||
}
|
||||
|
||||
$test = new Test;
|
||||
try {
|
||||
$test->i++;
|
||||
} catch (Error $e) {
|
||||
echo $e->getMessage(), "\n";
|
||||
}
|
||||
try {
|
||||
$test->i += 1;
|
||||
} catch (Error $e) {
|
||||
echo $e->getMessage(), "\n";
|
||||
}
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
Typed property Test::$i must not be accessed before initialization
|
||||
Typed property Test::$i must not be accessed before initialization
|
||||
@@ -1013,8 +1013,16 @@ ZEND_API zval *zend_std_get_property_ptr_ptr(zend_object *zobj, zend_string *nam
|
||||
if (EXPECTED(!zobj->ce->__get) ||
|
||||
UNEXPECTED((*zend_get_property_guard(zobj, name)) & IN_GET)) {
|
||||
if (UNEXPECTED(type == BP_VAR_RW || type == BP_VAR_R)) {
|
||||
ZVAL_NULL(retval);
|
||||
zend_error(E_WARNING, "Undefined property: %s::$%s", ZSTR_VAL(zobj->ce->name), ZSTR_VAL(name));
|
||||
if (UNEXPECTED(prop_info)) {
|
||||
zend_throw_error(NULL,
|
||||
"Typed property %s::$%s must not be accessed before initialization",
|
||||
ZSTR_VAL(prop_info->ce->name),
|
||||
ZSTR_VAL(name));
|
||||
retval = &EG(error_zval);
|
||||
} else {
|
||||
ZVAL_NULL(retval);
|
||||
zend_error(E_WARNING, "Undefined property: %s::$%s", ZSTR_VAL(zobj->ce->name), ZSTR_VAL(name));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* we do have getter - fail and let it try again with usual get/set */
|
||||
|
||||
Reference in New Issue
Block a user