mirror of
https://github.com/php/php-src.git
synced 2024-11-24 02:15:04 +08:00
commit
9c23a50939
36
Zend/tests/bug79155.phpt
Normal file
36
Zend/tests/bug79155.phpt
Normal file
@ -0,0 +1,36 @@
|
||||
--TEST--
|
||||
Bug #79155: Property nullability lost when using multiple property definition
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
class Foo {
|
||||
public ?string $a, $b;
|
||||
public ?stdClass $c, $d;
|
||||
}
|
||||
|
||||
$t = new Foo;
|
||||
$t->a = "str";
|
||||
$t->b = "str";
|
||||
$t->c = new stdClass;
|
||||
$t->d = new stdClass;
|
||||
|
||||
var_dump($t->a, $t->b, $t->c, $t->d);
|
||||
|
||||
$t->a = null;
|
||||
$t->b = null;
|
||||
$t->c = null;
|
||||
$t->d = null;
|
||||
var_dump($t->a, $t->b, $t->c, $t->d);
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
string(3) "str"
|
||||
string(3) "str"
|
||||
object(stdClass)#2 (0) {
|
||||
}
|
||||
object(stdClass)#3 (0) {
|
||||
}
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
@ -5478,15 +5478,15 @@ static zend_type zend_compile_single_typename(zend_ast *ast)
|
||||
return (zend_type) ZEND_TYPE_INIT_CODE(ast->attr, 0, 0);
|
||||
} else {
|
||||
zend_string *class_name = zend_ast_get_str(ast);
|
||||
zend_uchar type = zend_lookup_builtin_type_by_name(class_name);
|
||||
zend_uchar type_code = zend_lookup_builtin_type_by_name(class_name);
|
||||
|
||||
if (type != 0) {
|
||||
if (type_code != 0) {
|
||||
if ((ast->attr & ZEND_NAME_NOT_FQ) != ZEND_NAME_NOT_FQ) {
|
||||
zend_error_noreturn(E_COMPILE_ERROR,
|
||||
"Type declaration '%s' must be unqualified",
|
||||
ZSTR_VAL(zend_string_tolower(class_name)));
|
||||
}
|
||||
return (zend_type) ZEND_TYPE_INIT_CODE(type, 0, 0);
|
||||
return (zend_type) ZEND_TYPE_INIT_CODE(type_code, 0, 0);
|
||||
} else {
|
||||
const char *correct_name;
|
||||
zend_string *orig_name = zend_ast_get_str(ast);
|
||||
@ -5540,6 +5540,7 @@ static zend_type zend_compile_typename(
|
||||
zend_ast *ast, zend_bool force_allow_null, zend_bool use_arena) /* {{{ */
|
||||
{
|
||||
zend_bool allow_null = force_allow_null;
|
||||
zend_ast_attr orig_ast_attr = ast->attr;
|
||||
zend_type type = ZEND_TYPE_INIT_NONE(0);
|
||||
if (ast->attr & ZEND_TYPE_NULLABLE) {
|
||||
allow_null = 1;
|
||||
@ -5649,6 +5650,7 @@ static zend_type zend_compile_typename(
|
||||
}
|
||||
}
|
||||
|
||||
ast->attr = orig_ast_attr;
|
||||
return type;
|
||||
}
|
||||
/* }}} */
|
||||
|
Loading…
Reference in New Issue
Block a user