@@ -6455,6 +6455,14 @@ static zend_type zend_compile_typename(
64556455 }
64566456
64576457 free_alloca (type_list , use_heap );
6458+
6459+ uint32_t type_mask = ZEND_TYPE_FULL_MASK (type );
6460+ if ((type_mask & MAY_BE_OBJECT ) && (ZEND_TYPE_IS_COMPLEX (type ) || (type_mask & MAY_BE_STATIC ))) {
6461+ zend_string * type_str = zend_type_to_string (type );
6462+ zend_error_noreturn (E_COMPILE_ERROR ,
6463+ "Type %s contains both object and a class type, which is redundant" ,
6464+ ZSTR_VAL (type_str ));
6465+ }
64586466 } else if (ast -> kind == ZEND_AST_TYPE_INTERSECTION ) {
64596467 zend_ast_list * list = zend_ast_get_list (ast );
64606468 zend_type_list * type_list ;
@@ -6515,13 +6523,6 @@ static zend_type zend_compile_typename(
65156523 zend_error_noreturn (E_COMPILE_ERROR , "Type mixed cannot be marked as nullable since mixed already includes null" );
65166524 }
65176525
6518- if ((type_mask & MAY_BE_OBJECT ) && (ZEND_TYPE_IS_COMPLEX (type ) || (type_mask & MAY_BE_STATIC ))) {
6519- zend_string * type_str = zend_type_to_string (type );
6520- zend_error_noreturn (E_COMPILE_ERROR ,
6521- "Type %s contains both object and a class type, which is redundant" ,
6522- ZSTR_VAL (type_str ));
6523- }
6524-
65256526 if ((type_mask & MAY_BE_NULL ) && is_marked_nullable ) {
65266527 zend_error_noreturn (E_COMPILE_ERROR , "null cannot be marked as nullable" );
65276528 }
@@ -8083,7 +8084,7 @@ static void zend_compile_use(zend_ast *ast) /* {{{ */
80838084
80848085 /* Check that we are not attempting to alias a built-in type */
80858086 if (type == ZEND_SYMBOL_CLASS && zend_is_reserved_class_name (old_name )) {
8086- zend_error_noreturn (E_COMPILE_ERROR ,
8087+ zend_error_noreturn (E_COMPILE_ERROR ,
80878088 "Cannot alias '%s' as it is a built-in type" , ZSTR_VAL (old_name ));
80888089 }
80898090
0 commit comments