Skip to content

Commit ee1b290

Browse files
committed
Address review comments
1 parent 4ac943b commit ee1b290

File tree

4 files changed

+21
-9
lines changed

4 files changed

+21
-9
lines changed

Zend/tests/type_declarations/standalone_null.phpt

-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,5 @@ function test(null $v): null {
1010
var_dump(test(null));
1111

1212
?>
13-
===DONE===
1413
--EXPECT--
1514
NULL
16-
===DONE===

Zend/tests/type_declarations/typed_properties_110.phpt

+9-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,14 @@ class Foo {
77
}
88

99
$foo = new Foo();
10+
$foo->value = null;
11+
12+
try {
13+
$foo->value = 1;
14+
} catch (\TypeError $e) {
15+
echo $e->getMessage();
16+
}
17+
1018
?>
11-
===DONE===
1219
--EXPECT--
13-
===DONE===
20+
Cannot assign int to property Foo::$value of type null

Zend/tests/type_declarations/typed_properties_111.phpt

+9-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,14 @@ class Foo {
77
}
88

99
$foo = new Foo();
10+
$foo->value = false;
11+
12+
try {
13+
$foo->value = true;
14+
} catch (\TypeError $e) {
15+
echo $e->getMessage();
16+
}
17+
1018
?>
11-
===DONE===
1219
--EXPECT--
13-
===DONE===
20+
Cannot assign bool to property Foo::$value of type false

Zend/zend_compile.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -6188,11 +6188,11 @@ static bool zend_type_contains_traversable(zend_type type) {
61886188
static zend_type zend_compile_typename(
61896189
zend_ast *ast, bool force_allow_null) /* {{{ */
61906190
{
6191-
bool is_marked_nullable = false;
6191+
bool is_marked_nullable = ast->attr & ZEND_TYPE_NULLABLE;
61926192
zend_ast_attr orig_ast_attr = ast->attr;
61936193
zend_type type = ZEND_TYPE_INIT_NONE(0);
6194-
if (ast->attr & ZEND_TYPE_NULLABLE) {
6195-
is_marked_nullable = true;
6194+
6195+
if (is_marked_nullable) {
61966196
ast->attr &= ~ZEND_TYPE_NULLABLE;
61976197
}
61986198

0 commit comments

Comments
 (0)