@@ -355,7 +355,7 @@ static zend_result pass_errors_by_ref(zval *errors_zv, zval *errors)
355355
356356PHPAPI void php_uri_instantiate_uri (
357357 INTERNAL_FUNCTION_PARAMETERS , const uri_handler_t * handler , const zend_string * uri_str , const zend_object * base_url_object ,
358- bool is_constructor , zval * errors_zv
358+ bool should_throw , bool should_update_this_object , zval * errors_zv
359359) {
360360 zval errors ;
361361 ZVAL_UNDEF (& errors );
@@ -367,9 +367,9 @@ PHPAPI void php_uri_instantiate_uri(
367367 base_url = internal_base_url -> uri ;
368368 }
369369
370- void * uri = handler -> parse_uri (uri_str , base_url , is_constructor || errors_zv != NULL ? & errors : NULL );
370+ void * uri = handler -> parse_uri (uri_str , base_url , should_throw || errors_zv != NULL ? & errors : NULL );
371371 if (UNEXPECTED (uri == NULL )) {
372- if (is_constructor ) {
372+ if (should_throw ) {
373373 throw_invalid_uri_exception (handler , & errors );
374374 zval_ptr_dtor (& errors );
375375 RETURN_THROWS ();
@@ -384,10 +384,14 @@ PHPAPI void php_uri_instantiate_uri(
384384 zval_ptr_dtor (& errors );
385385
386386 uri_object_t * uri_object ;
387- if (is_constructor ) {
387+ if (should_update_this_object ) {
388388 uri_object = Z_URI_OBJECT_P (ZEND_THIS );
389389 } else {
390- object_init_ex (return_value , Z_CE_P (ZEND_THIS ));
390+ if (EX (func )-> common .fn_flags & ZEND_ACC_STATIC ) {
391+ object_init_ex (return_value , Z_CE_P (ZEND_THIS ));
392+ } else {
393+ object_init_ex (return_value , Z_OBJCE_P (ZEND_THIS ));
394+ }
391395 uri_object = Z_URI_OBJECT_P (return_value );
392396 }
393397
@@ -406,7 +410,7 @@ static void create_rfc3986_uri(INTERNAL_FUNCTION_PARAMETERS, bool is_constructor
406410 Z_PARAM_OBJ_OF_CLASS_OR_NULL (base_url_object , rfc3986_uri_ce )
407411 ZEND_PARSE_PARAMETERS_END ();
408412
409- php_uri_instantiate_uri (INTERNAL_FUNCTION_PARAM_PASSTHRU , & uriparser_uri_handler , uri_str , base_url_object , is_constructor , NULL );
413+ php_uri_instantiate_uri (INTERNAL_FUNCTION_PARAM_PASSTHRU , & uriparser_uri_handler , uri_str , base_url_object , is_constructor , is_constructor , NULL );
410414}
411415
412416PHP_METHOD (Uri_Rfc3986_Uri , parse )
@@ -432,7 +436,7 @@ static void create_whatwg_uri(INTERNAL_FUNCTION_PARAMETERS, bool is_constructor)
432436 Z_PARAM_ZVAL (errors )
433437 ZEND_PARSE_PARAMETERS_END ();
434438
435- php_uri_instantiate_uri (INTERNAL_FUNCTION_PARAM_PASSTHRU , & lexbor_uri_handler , uri_str , base_url_object , is_constructor , errors );
439+ php_uri_instantiate_uri (INTERNAL_FUNCTION_PARAM_PASSTHRU , & lexbor_uri_handler , uri_str , base_url_object , is_constructor , is_constructor , errors );
436440}
437441
438442PHP_METHOD (Uri_WhatWg_Url , parse )
@@ -669,7 +673,7 @@ PHP_METHOD(Uri_Rfc3986_Uri, resolve)
669673 uri_internal_t * internal_uri = uri_internal_from_obj (this_object );
670674 URI_CHECK_INITIALIZATION (internal_uri );
671675
672- php_uri_instantiate_uri (INTERNAL_FUNCTION_PARAM_PASSTHRU , internal_uri -> handler , uri_str , this_object , true, NULL );
676+ php_uri_instantiate_uri (INTERNAL_FUNCTION_PARAM_PASSTHRU , internal_uri -> handler , uri_str , this_object , true, false, NULL );
673677}
674678
675679PHP_METHOD (Uri_Rfc3986_Uri , __serialize )
@@ -856,6 +860,24 @@ PHP_METHOD(Uri_WhatWg_Url, toAsciiString)
856860 RETURN_STR (internal_uri -> handler -> uri_to_string (internal_uri -> uri , URI_RECOMPOSITION_RAW_ASCII , false));
857861}
858862
863+ PHP_METHOD (Uri_WhatWg_Url , resolve )
864+ {
865+ zend_string * uri_str ;
866+ zval * errors = NULL ;
867+
868+ ZEND_PARSE_PARAMETERS_START (1 , 2 )
869+ Z_PARAM_PATH_STR (uri_str )
870+ Z_PARAM_OPTIONAL
871+ Z_PARAM_ZVAL (errors )
872+ ZEND_PARSE_PARAMETERS_END ();
873+
874+ zend_object * this_object = Z_OBJ_P (ZEND_THIS );
875+ uri_internal_t * internal_uri = uri_internal_from_obj (this_object );
876+ URI_CHECK_INITIALIZATION (internal_uri );
877+
878+ php_uri_instantiate_uri (INTERNAL_FUNCTION_PARAM_PASSTHRU , internal_uri -> handler , uri_str , this_object , true, false, errors );
879+ }
880+
859881PHP_METHOD (Uri_WhatWg_Url , __unserialize )
860882{
861883 uri_unserialize (INTERNAL_FUNCTION_PARAM_PASSTHRU , URI_PARSER_WHATWG );
0 commit comments