@@ -7426,11 +7426,14 @@ static zend_type zend_compile_single_typename(zend_ast *ast)
74267426
74277427 return (zend_type ) ZEND_TYPE_INIT_CODE (ast -> attr , 0 , 0 );
74287428 } else {
7429- zend_string * type_name = zend_ast_get_str (ast );
7429+ ZEND_ASSERT (ast -> kind == ZEND_AST_CLASS_REF );
7430+ zend_ast * name_ast = ast -> child [0 ];
7431+ zend_ast * args_ast = ast -> child [1 ];
7432+ zend_string * type_name = zend_ast_get_str (name_ast );
74307433 uint8_t type_code = zend_lookup_builtin_type_by_name (type_name );
74317434
74327435 if (type_code != 0 ) {
7433- if ((ast -> attr & ZEND_NAME_NOT_FQ ) != ZEND_NAME_NOT_FQ ) {
7436+ if ((name_ast -> attr & ZEND_NAME_NOT_FQ ) != ZEND_NAME_NOT_FQ ) {
74347437 zend_error_noreturn (E_COMPILE_ERROR ,
74357438 "Type declaration '%s' must be unqualified" ,
74367439 ZSTR_VAL (zend_string_tolower (type_name )));
@@ -7447,7 +7450,7 @@ static zend_type zend_compile_single_typename(zend_ast *ast)
74477450 return (zend_type ) ZEND_TYPE_INIT_CODE (type_code , 0 , 0 );
74487451 } else {
74497452 const char * correct_name ;
7450- uint32_t fetch_type = zend_get_class_fetch_type_ast (ast );
7453+ uint32_t fetch_type = zend_get_class_fetch_type_ast (name_ast );
74517454
74527455 if (ce && ce -> num_generic_parameters > 0 ) {
74537456 for (uint32_t generic_param_index = 0 ; generic_param_index < ce -> num_generic_parameters ; generic_param_index ++ ) {
@@ -7460,7 +7463,7 @@ static zend_type zend_compile_single_typename(zend_ast *ast)
74607463
74617464 zend_string * class_name = type_name ;
74627465 if (fetch_type == ZEND_FETCH_CLASS_DEFAULT ) {
7463- class_name = zend_resolve_class_name_ast (ast );
7466+ class_name = zend_resolve_class_name_ast (name_ast );
74647467 zend_assert_valid_class_name (class_name , "a type name" );
74657468 } else {
74667469 ZEND_ASSERT (fetch_type == ZEND_FETCH_CLASS_SELF || fetch_type == ZEND_FETCH_CLASS_PARENT );
@@ -7487,7 +7490,7 @@ static zend_type zend_compile_single_typename(zend_ast *ast)
74877490 zend_string_addref (class_name );
74887491 }
74897492
7490- if (ast -> attr == ZEND_NAME_NOT_FQ
7493+ if (name_ast -> attr == ZEND_NAME_NOT_FQ && ! args_ast
74917494 && zend_is_confusable_type (type_name , & correct_name )
74927495 && zend_is_not_imported (type_name )) {
74937496 const char * extra =
@@ -7508,6 +7511,7 @@ static zend_type zend_compile_single_typename(zend_ast *ast)
75087511
75097512 class_name = zend_new_interned_string (class_name );
75107513 zend_alloc_ce_cache (class_name );
7514+ // TODO: use args_ast
75117515 return (zend_type ) ZEND_TYPE_INIT_CLASS (class_name , /* allow null */ false, 0 );
75127516 }
75137517 }
0 commit comments