Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--TEST--
Bug #43332.1 (self and parent as type hint in namespace)
Bug #43332.1 (self and parent as type declaration in namespace)
--FILE--
<?php
namespace foobar;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--TEST--
Bug #43332.2 (self and parent as type hint in namespace)
Bug #43332.2 (self and parent as type declaration in namespace)
--FILE--
<?php
namespace foobar;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--TEST--
Bug #60573 (type hinting with "self" keyword causes weird errors)
Bug #60573 (type declaration with "self" keyword causes weird errors)
--FILE--
<?php
class Foo1 {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--TEST--
Bug #60573 (type hinting with "self" keyword causes weird errors) -- variation 2
Bug #60573 (type declaration with "self" keyword causes weird errors) -- variation 2
--FILE--
<?php
class Foo1 {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
--TEST--
Fully qualified (leading backslash) static type names must fail
--DESCRIPTION--
OSS-Fuzz: https://issues.oss-fuzz.com/issues/532353396
--FILE--
<?php

function test($i): \static {}

?>
--EXPECTF--
Fatal error: Type declaration 'static' must be unqualified in %s on line %d
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
--TEST--
namespace\static is not a valid type declaration
--DESCRIPTION--
OSS-Fuzz: https://issues.oss-fuzz.com/issues/532353396
--FILE--
<?php

function test($i): namespace\static {}

?>
--EXPECTF--
Fatal error: Type declaration 'static' must be unqualified in %s on line %d
3 changes: 3 additions & 0 deletions Zend/zend_compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ static const builtin_type_info builtin_types[] = {
{ZEND_STRL("iterable"), IS_ITERABLE},
{ZEND_STRL("object"), IS_OBJECT},
{ZEND_STRL("mixed"), IS_MIXED},
{ZEND_STRL("static"), IS_STATIC},
{NULL, 0, IS_UNDEF}
};

Expand Down Expand Up @@ -7100,6 +7101,8 @@ static zend_type zend_compile_single_typename(zend_ast *ast)
ZSTR_VAL(zend_string_tolower(type_name)));
}

ZEND_ASSERT(type_code != IS_STATIC && "unqualified static type should have been handled by ZEND_AST_TYPE branch");

/* Transform iterable into a type union alias */
if (type_code == IS_ITERABLE) {
/* Set iterable bit for BC compat during Reflection and string representation of type */
Expand Down
Loading