@@ -355,7 +355,7 @@ static zend_result pass_errors_by_ref(zval *errors_zv, zval *errors)
355
355
356
356
PHPAPI void php_uri_instantiate_uri (
357
357
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
359
359
) {
360
360
zval errors ;
361
361
ZVAL_UNDEF (& errors );
@@ -367,9 +367,9 @@ PHPAPI void php_uri_instantiate_uri(
367
367
base_url = internal_base_url -> uri ;
368
368
}
369
369
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 );
371
371
if (UNEXPECTED (uri == NULL )) {
372
- if (is_constructor ) {
372
+ if (should_throw ) {
373
373
throw_invalid_uri_exception (handler , & errors );
374
374
zval_ptr_dtor (& errors );
375
375
RETURN_THROWS ();
@@ -384,10 +384,14 @@ PHPAPI void php_uri_instantiate_uri(
384
384
zval_ptr_dtor (& errors );
385
385
386
386
uri_object_t * uri_object ;
387
- if (is_constructor ) {
387
+ if (should_update_this_object ) {
388
388
uri_object = Z_URI_OBJECT_P (ZEND_THIS );
389
389
} 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
+ }
391
395
uri_object = Z_URI_OBJECT_P (return_value );
392
396
}
393
397
@@ -406,7 +410,7 @@ static void create_rfc3986_uri(INTERNAL_FUNCTION_PARAMETERS, bool is_constructor
406
410
Z_PARAM_OBJ_OF_CLASS_OR_NULL (base_url_object , rfc3986_uri_ce )
407
411
ZEND_PARSE_PARAMETERS_END ();
408
412
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 );
410
414
}
411
415
412
416
PHP_METHOD (Uri_Rfc3986_Uri , parse )
@@ -432,7 +436,7 @@ static void create_whatwg_uri(INTERNAL_FUNCTION_PARAMETERS, bool is_constructor)
432
436
Z_PARAM_ZVAL (errors )
433
437
ZEND_PARSE_PARAMETERS_END ();
434
438
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 );
436
440
}
437
441
438
442
PHP_METHOD (Uri_WhatWg_Url , parse )
@@ -669,7 +673,7 @@ PHP_METHOD(Uri_Rfc3986_Uri, resolve)
669
673
uri_internal_t * internal_uri = uri_internal_from_obj (this_object );
670
674
URI_CHECK_INITIALIZATION (internal_uri );
671
675
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 );
673
677
}
674
678
675
679
PHP_METHOD (Uri_Rfc3986_Uri , __serialize )
@@ -856,6 +860,24 @@ PHP_METHOD(Uri_WhatWg_Url, toAsciiString)
856
860
RETURN_STR (internal_uri -> handler -> uri_to_string (internal_uri -> uri , URI_RECOMPOSITION_RAW_ASCII , false));
857
861
}
858
862
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
+
859
881
PHP_METHOD (Uri_WhatWg_Url , __unserialize )
860
882
{
861
883
uri_unserialize (INTERNAL_FUNCTION_PARAM_PASSTHRU , URI_PARSER_WHATWG );
0 commit comments