Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Allow null and false as standalone types #7546

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 8, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Address review comments
  • Loading branch information
Girgias committed Apr 7, 2022
commit f9d5360cda57f68ac541ff492eb8e0ae0150cf5d
2 changes: 0 additions & 2 deletions 2 Zend/tests/type_declarations/standalone_null.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,5 @@ function test(null $v): null {
var_dump(test(null));

?>
===DONE===
--EXPECT--
NULL
===DONE===
11 changes: 9 additions & 2 deletions 11 Zend/tests/type_declarations/typed_properties_110.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,14 @@ class Foo {
}

$foo = new Foo();
nikic marked this conversation as resolved.
Show resolved Hide resolved
$foo->value = null;

try {
$foo->value = 1;
} catch (\TypeError $e) {
echo $e->getMessage();
}

?>
===DONE===
--EXPECT--
===DONE===
Cannot assign int to property Foo::$value of type null
11 changes: 9 additions & 2 deletions 11 Zend/tests/type_declarations/typed_properties_111.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,14 @@ class Foo {
}

$foo = new Foo();
$foo->value = false;

try {
$foo->value = true;
} catch (\TypeError $e) {
echo $e->getMessage();
}

?>
===DONE===
--EXPECT--
===DONE===
Cannot assign bool to property Foo::$value of type false
6 changes: 3 additions & 3 deletions 6 Zend/zend_compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -6186,11 +6186,11 @@ static bool zend_type_contains_traversable(zend_type type) {
static zend_type zend_compile_typename(
zend_ast *ast, bool force_allow_null) /* {{{ */
{
bool is_marked_nullable = false;
bool is_marked_nullable = ast->attr & ZEND_TYPE_NULLABLE;
zend_ast_attr orig_ast_attr = ast->attr;
zend_type type = ZEND_TYPE_INIT_NONE(0);
if (ast->attr & ZEND_TYPE_NULLABLE) {
is_marked_nullable = true;

if (is_marked_nullable) {
ast->attr &= ~ZEND_TYPE_NULLABLE;
}

Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.