@@ -53,14 +53,11 @@ static zend_array uri_parsers;
53
53
54
54
static HashTable * uri_get_debug_properties (uri_object_t * object )
55
55
{
56
- uri_internal_t * internal_uri = & object -> internal ;
57
- ZEND_ASSERT (internal_uri != NULL );
58
-
59
56
const HashTable * std_properties = zend_std_get_properties (& object -> std );
60
57
HashTable * result = zend_array_dup (std_properties );
61
58
62
- const php_uri_parser * const parser = internal_uri -> parser ;
63
- void * const uri = internal_uri -> uri ;
59
+ const php_uri_parser * const parser = object -> parser ;
60
+ void * const uri = object -> uri ;
64
61
65
62
if (UNEXPECTED (uri == NULL )) {
66
63
return result ;
@@ -324,7 +321,7 @@ ZEND_ATTRIBUTE_NONNULL_ARGS(1, 2) PHPAPI void php_uri_instantiate_uri(
324
321
uri_object_t * uri_object ;
325
322
if (should_update_this_object ) {
326
323
uri_object = Z_URI_OBJECT_P (ZEND_THIS );
327
- if (uri_object -> internal . uri != NULL ) {
324
+ if (uri_object -> uri != NULL ) {
328
325
zend_throw_error (NULL , "Cannot modify readonly object of class %s" , ZSTR_VAL (Z_OBJCE_P (ZEND_THIS )-> name ));
329
326
RETURN_THROWS ();
330
327
}
@@ -337,18 +334,17 @@ ZEND_ATTRIBUTE_NONNULL_ARGS(1, 2) PHPAPI void php_uri_instantiate_uri(
337
334
uri_object = Z_URI_OBJECT_P (return_value );
338
335
}
339
336
340
- const php_uri_parser * uri_parser = uri_object -> internal . parser ;
337
+ const php_uri_parser * uri_parser = uri_object -> parser ;
341
338
342
339
zval errors ;
343
340
ZVAL_UNDEF (& errors );
344
341
345
342
void * base_url = NULL ;
346
343
if (base_url_object != NULL ) {
347
344
ZEND_ASSERT (base_url_object -> std .ce == uri_object -> std .ce );
348
- const uri_internal_t * internal_base_url = & base_url_object -> internal ;
349
- URI_ASSERT_INITIALIZATION (internal_base_url );
350
- ZEND_ASSERT (internal_base_url -> parser == uri_parser );
351
- base_url = internal_base_url -> uri ;
345
+ ZEND_ASSERT (base_url_object -> uri != NULL );
346
+ ZEND_ASSERT (base_url_object -> parser == uri_parser );
347
+ base_url = base_url_object -> uri ;
352
348
}
353
349
354
350
void * uri = uri_parser -> parse (ZSTR_VAL (uri_str ), ZSTR_LEN (uri_str ), base_url , errors_zv != NULL ? & errors : NULL , !should_throw );
@@ -370,7 +366,7 @@ ZEND_ATTRIBUTE_NONNULL_ARGS(1, 2) PHPAPI void php_uri_instantiate_uri(
370
366
RETURN_THROWS ();
371
367
}
372
368
373
- uri_object -> internal . uri = uri ;
369
+ uri_object -> uri = uri ;
374
370
}
375
371
376
372
static void create_rfc3986_uri (INTERNAL_FUNCTION_PARAMETERS , bool is_constructor )
@@ -531,10 +527,10 @@ static void rfc3986_userinfo_read(INTERNAL_FUNCTION_PARAMETERS, php_uri_componen
531
527
{
532
528
ZEND_PARSE_PARAMETERS_NONE ();
533
529
534
- uri_internal_t * internal_uri = Z_URI_INTERNAL_P (ZEND_THIS );
535
- URI_ASSERT_INITIALIZATION ( internal_uri );
530
+ uri_object_t * uri_object = Z_URI_OBJECT_P (ZEND_THIS );
531
+ ZEND_ASSERT ( uri_object -> uri != NULL );
536
532
537
- if (UNEXPECTED (php_uri_parser_rfc3986_userinfo_read (internal_uri -> uri , read_mode , return_value ) == FAILURE )) {
533
+ if (UNEXPECTED (php_uri_parser_rfc3986_userinfo_read (uri_object -> uri , read_mode , return_value ) == FAILURE )) {
538
534
zend_throw_error (NULL , "The userinfo component cannot be retrieved" );
539
535
RETURN_THROWS ();
540
536
}
@@ -565,11 +561,10 @@ PHP_METHOD(Uri_Rfc3986_Uri, withUserInfo)
565
561
ZVAL_STR (& zv , value );
566
562
}
567
563
568
- zend_object * old_object = Z_OBJ_P (ZEND_THIS );
569
- uri_internal_t * internal_uri = Z_URI_INTERNAL_P (ZEND_THIS );
570
- URI_ASSERT_INITIALIZATION (internal_uri );
564
+ uri_object_t * old_uri_object = uri_object_from_obj (Z_OBJ_P (ZEND_THIS ));
565
+ ZEND_ASSERT (old_uri_object -> uri != NULL );
571
566
572
- zend_object * new_object = old_object -> handlers -> clone_obj (old_object );
567
+ zend_object * new_object = old_uri_object -> std . handlers -> clone_obj (& old_uri_object -> std );
573
568
if (new_object == NULL ) {
574
569
RETURN_THROWS ();
575
570
}
@@ -578,10 +573,10 @@ PHP_METHOD(Uri_Rfc3986_Uri, withUserInfo)
578
573
* case of an exception being thrown. */
579
574
RETVAL_OBJ (new_object );
580
575
581
- uri_internal_t * new_internal_uri = uri_internal_from_obj (new_object );
582
- URI_ASSERT_INITIALIZATION ( new_internal_uri );
576
+ uri_object_t * new_uri_object = uri_object_from_obj (new_object );
577
+ ZEND_ASSERT ( new_uri_object -> uri != NULL );
583
578
584
- if (UNEXPECTED (php_uri_parser_rfc3986_userinfo_write (new_internal_uri -> uri , & zv , NULL ) == FAILURE )) {
579
+ if (UNEXPECTED (php_uri_parser_rfc3986_userinfo_write (new_uri_object -> uri , & zv , NULL ) == FAILURE )) {
585
580
RETURN_THROWS ();
586
581
}
587
582
}
@@ -684,11 +679,8 @@ static void throw_cannot_recompose_uri_to_string(uri_object_t *object)
684
679
static void uri_equals (INTERNAL_FUNCTION_PARAMETERS , uri_object_t * that_object , zend_object * comparison_mode )
685
680
{
686
681
uri_object_t * this_object = Z_URI_OBJECT_P (ZEND_THIS );
687
- uri_internal_t * this_internal_uri = & this_object -> internal ;
688
- URI_ASSERT_INITIALIZATION (this_internal_uri );
689
-
690
- uri_internal_t * that_internal_uri = & that_object -> internal ;
691
- URI_ASSERT_INITIALIZATION (that_internal_uri );
682
+ ZEND_ASSERT (this_object -> uri != NULL );
683
+ ZEND_ASSERT (that_object -> uri != NULL );
692
684
693
685
if (this_object -> std .ce != that_object -> std .ce &&
694
686
!instanceof_function (this_object -> std .ce , that_object -> std .ce ) &&
@@ -703,15 +695,15 @@ static void uri_equals(INTERNAL_FUNCTION_PARAMETERS, uri_object_t *that_object,
703
695
exclude_fragment = zend_string_equals_literal (Z_STR_P (case_name ), "ExcludeFragment" );
704
696
}
705
697
706
- zend_string * this_str = this_internal_uri -> parser -> to_string (
707
- this_internal_uri -> uri , PHP_URI_RECOMPOSITION_MODE_NORMALIZED_ASCII , exclude_fragment );
698
+ zend_string * this_str = this_object -> parser -> to_string (
699
+ this_object -> uri , PHP_URI_RECOMPOSITION_MODE_NORMALIZED_ASCII , exclude_fragment );
708
700
if (this_str == NULL ) {
709
701
throw_cannot_recompose_uri_to_string (this_object );
710
702
RETURN_THROWS ();
711
703
}
712
704
713
- zend_string * that_str = that_internal_uri -> parser -> to_string (
714
- that_internal_uri -> uri , PHP_URI_RECOMPOSITION_MODE_NORMALIZED_ASCII , exclude_fragment );
705
+ zend_string * that_str = that_object -> parser -> to_string (
706
+ that_object -> uri , PHP_URI_RECOMPOSITION_MODE_NORMALIZED_ASCII , exclude_fragment );
715
707
if (that_str == NULL ) {
716
708
zend_string_release (this_str );
717
709
throw_cannot_recompose_uri_to_string (that_object );
@@ -742,13 +734,12 @@ PHP_METHOD(Uri_Rfc3986_Uri, toRawString)
742
734
{
743
735
ZEND_PARSE_PARAMETERS_NONE ();
744
736
745
- uri_object_t * this_object = Z_URI_OBJECT_P (ZEND_THIS );
746
- uri_internal_t * internal_uri = & this_object -> internal ;
747
- URI_ASSERT_INITIALIZATION (internal_uri );
737
+ uri_object_t * uri_object = Z_URI_OBJECT_P (ZEND_THIS );
738
+ ZEND_ASSERT (uri_object -> uri != NULL );
748
739
749
- zend_string * uri_str = internal_uri -> parser -> to_string (internal_uri -> uri , PHP_URI_RECOMPOSITION_MODE_RAW_ASCII , false);
740
+ zend_string * uri_str = uri_object -> parser -> to_string (uri_object -> uri , PHP_URI_RECOMPOSITION_MODE_RAW_ASCII , false);
750
741
if (uri_str == NULL ) {
751
- throw_cannot_recompose_uri_to_string (this_object );
742
+ throw_cannot_recompose_uri_to_string (uri_object );
752
743
RETURN_THROWS ();
753
744
}
754
745
@@ -759,13 +750,12 @@ PHP_METHOD(Uri_Rfc3986_Uri, toString)
759
750
{
760
751
ZEND_PARSE_PARAMETERS_NONE ();
761
752
762
- uri_object_t * this_object = Z_URI_OBJECT_P (ZEND_THIS );
763
- uri_internal_t * internal_uri = & this_object -> internal ;
764
- URI_ASSERT_INITIALIZATION (internal_uri );
753
+ uri_object_t * uri_object = Z_URI_OBJECT_P (ZEND_THIS );
754
+ ZEND_ASSERT (uri_object -> uri != NULL );
765
755
766
- zend_string * uri_str = internal_uri -> parser -> to_string (internal_uri -> uri , PHP_URI_RECOMPOSITION_MODE_NORMALIZED_ASCII , false);
756
+ zend_string * uri_str = uri_object -> parser -> to_string (uri_object -> uri , PHP_URI_RECOMPOSITION_MODE_NORMALIZED_ASCII , false);
767
757
if (uri_str == NULL ) {
768
- throw_cannot_recompose_uri_to_string (this_object );
758
+ throw_cannot_recompose_uri_to_string (uri_object );
769
759
RETURN_THROWS ();
770
760
}
771
761
@@ -788,14 +778,13 @@ PHP_METHOD(Uri_Rfc3986_Uri, __serialize)
788
778
{
789
779
ZEND_PARSE_PARAMETERS_NONE ();
790
780
791
- uri_object_t * this_object = Z_URI_OBJECT_P (ZEND_THIS );
792
- uri_internal_t * internal_uri = & this_object -> internal ;
793
- URI_ASSERT_INITIALIZATION (internal_uri );
781
+ uri_object_t * uri_object = Z_URI_OBJECT_P (ZEND_THIS );
782
+ ZEND_ASSERT (uri_object -> uri != NULL );
794
783
795
784
/* Serialize state: "uri" key in the first array */
796
- zend_string * uri_str = internal_uri -> parser -> to_string (internal_uri -> uri , PHP_URI_RECOMPOSITION_MODE_RAW_ASCII , false);
785
+ zend_string * uri_str = uri_object -> parser -> to_string (uri_object -> uri , PHP_URI_RECOMPOSITION_MODE_RAW_ASCII , false);
797
786
if (uri_str == NULL ) {
798
- throw_cannot_recompose_uri_to_string (this_object );
787
+ throw_cannot_recompose_uri_to_string (uri_object );
799
788
RETURN_THROWS ();
800
789
}
801
790
zval tmp ;
@@ -809,7 +798,7 @@ PHP_METHOD(Uri_Rfc3986_Uri, __serialize)
809
798
zend_hash_next_index_insert (Z_ARRVAL_P (return_value ), & arr );
810
799
811
800
/* Serialize regular properties: second array */
812
- ZVAL_ARR (& arr , this_object -> std .handlers -> get_properties (& this_object -> std ));
801
+ ZVAL_ARR (& arr , uri_object -> std .handlers -> get_properties (& uri_object -> std ));
813
802
Z_TRY_ADDREF (arr );
814
803
zend_hash_next_index_insert (Z_ARRVAL_P (return_value ), & arr );
815
804
}
@@ -822,56 +811,55 @@ static void uri_unserialize(INTERNAL_FUNCTION_PARAMETERS)
822
811
Z_PARAM_ARRAY_HT (data )
823
812
ZEND_PARSE_PARAMETERS_END ();
824
813
825
- zend_object * object = Z_OBJ_P (ZEND_THIS );
826
- uri_internal_t * internal_uri = uri_internal_from_obj (object );
827
- if (internal_uri -> uri != NULL ) {
814
+ uri_object_t * uri_object = uri_object_from_obj (Z_OBJ_P (ZEND_THIS ));
815
+ if (uri_object -> uri != NULL ) {
828
816
/* Intentionally throw two exceptions for proper chaining. */
829
- zend_throw_error (NULL , "Cannot modify readonly object of class %s" , ZSTR_VAL (object -> ce -> name ));
830
- zend_throw_exception_ex (NULL , 0 , "Invalid serialization data for %s object" , ZSTR_VAL (object -> ce -> name ));
817
+ zend_throw_error (NULL , "Cannot modify readonly object of class %s" , ZSTR_VAL (uri_object -> std . ce -> name ));
818
+ zend_throw_exception_ex (NULL , 0 , "Invalid serialization data for %s object" , ZSTR_VAL (uri_object -> std . ce -> name ));
831
819
RETURN_THROWS ();
832
820
}
833
821
834
822
/* Verify the expected number of elements, this implicitly ensures that no additional elements are present. */
835
823
if (zend_hash_num_elements (data ) != 2 ) {
836
- zend_throw_exception_ex (NULL , 0 , "Invalid serialization data for %s object" , ZSTR_VAL (object -> ce -> name ));
824
+ zend_throw_exception_ex (NULL , 0 , "Invalid serialization data for %s object" , ZSTR_VAL (uri_object -> std . ce -> name ));
837
825
RETURN_THROWS ();
838
826
}
839
827
840
828
/* Unserialize state: "uri" key in the first array */
841
829
zval * arr = zend_hash_index_find (data , 0 );
842
830
if (arr == NULL || Z_TYPE_P (arr ) != IS_ARRAY ) {
843
- zend_throw_exception_ex (NULL , 0 , "Invalid serialization data for %s object" , ZSTR_VAL (object -> ce -> name ));
831
+ zend_throw_exception_ex (NULL , 0 , "Invalid serialization data for %s object" , ZSTR_VAL (uri_object -> std . ce -> name ));
844
832
RETURN_THROWS ();
845
833
}
846
834
847
835
/* Verify the expected number of elements inside the first array, this implicitly ensures that no additional elements are present. */
848
836
if (zend_hash_num_elements (Z_ARRVAL_P (arr )) != 1 ) {
849
- zend_throw_exception_ex (NULL , 0 , "Invalid serialization data for %s object" , ZSTR_VAL (object -> ce -> name ));
837
+ zend_throw_exception_ex (NULL , 0 , "Invalid serialization data for %s object" , ZSTR_VAL (uri_object -> std . ce -> name ));
850
838
RETURN_THROWS ();
851
839
}
852
840
853
841
zval * uri_zv = zend_hash_str_find_ind (Z_ARRVAL_P (arr ), ZEND_STRL (URI_SERIALIZED_PROPERTY_NAME ));
854
842
if (uri_zv == NULL || Z_TYPE_P (uri_zv ) != IS_STRING ) {
855
- zend_throw_exception_ex (NULL , 0 , "Invalid serialization data for %s object" , ZSTR_VAL (object -> ce -> name ));
843
+ zend_throw_exception_ex (NULL , 0 , "Invalid serialization data for %s object" , ZSTR_VAL (uri_object -> std . ce -> name ));
856
844
RETURN_THROWS ();
857
845
}
858
846
859
- internal_uri -> uri = internal_uri -> parser -> parse (Z_STRVAL_P (uri_zv ), Z_STRLEN_P (uri_zv ), NULL , NULL , true);
860
- if (internal_uri -> uri == NULL ) {
861
- zend_throw_exception_ex (NULL , 0 , "Invalid serialization data for %s object" , ZSTR_VAL (object -> ce -> name ));
847
+ uri_object -> uri = uri_object -> parser -> parse (Z_STRVAL_P (uri_zv ), Z_STRLEN_P (uri_zv ), NULL , NULL , true);
848
+ if (uri_object -> uri == NULL ) {
849
+ zend_throw_exception_ex (NULL , 0 , "Invalid serialization data for %s object" , ZSTR_VAL (uri_object -> std . ce -> name ));
862
850
RETURN_THROWS ();
863
851
}
864
852
865
853
/* Unserialize regular properties: second array */
866
854
arr = zend_hash_index_find (data , 1 );
867
855
if (arr == NULL || Z_TYPE_P (arr ) != IS_ARRAY ) {
868
- zend_throw_exception_ex (NULL , 0 , "Invalid serialization data for %s object" , ZSTR_VAL (object -> ce -> name ));
856
+ zend_throw_exception_ex (NULL , 0 , "Invalid serialization data for %s object" , ZSTR_VAL (uri_object -> std . ce -> name ));
869
857
RETURN_THROWS ();
870
858
}
871
859
872
860
/* Verify that there is no regular property in the second array, because the URI classes have no properties and they are final. */
873
861
if (zend_hash_num_elements (Z_ARRVAL_P (arr )) > 0 ) {
874
- zend_throw_exception_ex (NULL , 0 , "Invalid serialization data for %s object" , ZSTR_VAL (object -> ce -> name ));
862
+ zend_throw_exception_ex (NULL , 0 , "Invalid serialization data for %s object" , ZSTR_VAL (uri_object -> std . ce -> name ));
875
863
RETURN_THROWS ();
876
864
}
877
865
}
@@ -944,21 +932,21 @@ PHP_METHOD(Uri_WhatWg_Url, toUnicodeString)
944
932
ZEND_PARSE_PARAMETERS_NONE ();
945
933
946
934
zend_object * this_object = Z_OBJ_P (ZEND_THIS );
947
- uri_internal_t * internal_uri = uri_internal_from_obj (this_object );
948
- URI_ASSERT_INITIALIZATION ( internal_uri );
935
+ uri_object_t * uri_object = uri_object_from_obj (this_object );
936
+ ZEND_ASSERT ( uri_object -> uri != NULL );
949
937
950
- RETURN_STR (internal_uri -> parser -> to_string (internal_uri -> uri , PHP_URI_RECOMPOSITION_MODE_RAW_UNICODE , false));
938
+ RETURN_STR (uri_object -> parser -> to_string (uri_object -> uri , PHP_URI_RECOMPOSITION_MODE_RAW_UNICODE , false));
951
939
}
952
940
953
941
PHP_METHOD (Uri_WhatWg_Url , toAsciiString )
954
942
{
955
943
ZEND_PARSE_PARAMETERS_NONE ();
956
944
957
945
zend_object * this_object = Z_OBJ_P (ZEND_THIS );
958
- uri_internal_t * internal_uri = uri_internal_from_obj (this_object );
959
- URI_ASSERT_INITIALIZATION ( internal_uri );
946
+ uri_object_t * uri_object = uri_object_from_obj (this_object );
947
+ ZEND_ASSERT ( uri_object -> uri != NULL );
960
948
961
- RETURN_STR (internal_uri -> parser -> to_string (internal_uri -> uri , PHP_URI_RECOMPOSITION_MODE_RAW_ASCII , false));
949
+ RETURN_STR (uri_object -> parser -> to_string (uri_object -> uri , PHP_URI_RECOMPOSITION_MODE_RAW_ASCII , false));
962
950
}
963
951
964
952
PHP_METHOD (Uri_WhatWg_Url , resolve )
@@ -981,11 +969,10 @@ PHP_METHOD(Uri_WhatWg_Url, __serialize)
981
969
ZEND_PARSE_PARAMETERS_NONE ();
982
970
983
971
uri_object_t * this_object = Z_URI_OBJECT_P (ZEND_THIS );
984
- uri_internal_t * internal_uri = & this_object -> internal ;
985
- URI_ASSERT_INITIALIZATION (internal_uri );
972
+ ZEND_ASSERT (this_object -> uri != NULL );
986
973
987
974
/* Serialize state: "uri" key in the first array */
988
- zend_string * uri_str = internal_uri -> parser -> to_string (internal_uri -> uri , PHP_URI_RECOMPOSITION_MODE_RAW_ASCII , false);
975
+ zend_string * uri_str = this_object -> parser -> to_string (this_object -> uri , PHP_URI_RECOMPOSITION_MODE_RAW_ASCII , false);
989
976
if (uri_str == NULL ) {
990
977
throw_cannot_recompose_uri_to_string (this_object );
991
978
RETURN_THROWS ();
@@ -1027,10 +1014,8 @@ PHPAPI uri_object_t *php_uri_object_create(zend_class_entry *class_type, const p
1027
1014
zend_object_std_init (& uri_object -> std , class_type );
1028
1015
object_properties_init (& uri_object -> std , class_type );
1029
1016
1030
- uri_object -> internal = (uri_internal_t ){
1031
- .parser = parser ,
1032
- .uri = NULL ,
1033
- };
1017
+ uri_object -> parser = parser ;
1018
+ uri_object -> uri = NULL ;
1034
1019
1035
1020
return uri_object ;
1036
1021
}
@@ -1049,24 +1034,23 @@ PHPAPI void php_uri_object_handler_free(zend_object *object)
1049
1034
{
1050
1035
uri_object_t * uri_object = uri_object_from_obj (object );
1051
1036
1052
- uri_object -> internal . parser -> destroy (uri_object -> internal . uri );
1037
+ uri_object -> parser -> destroy (uri_object -> uri );
1053
1038
zend_object_std_dtor (& uri_object -> std );
1054
1039
}
1055
1040
1056
1041
PHPAPI zend_object * php_uri_object_handler_clone (zend_object * object )
1057
1042
{
1058
1043
uri_object_t * uri_object = uri_object_from_obj (object );
1059
- uri_internal_t * internal_uri = uri_internal_from_obj (object );
1060
1044
1061
- URI_ASSERT_INITIALIZATION ( internal_uri );
1045
+ ZEND_ASSERT ( uri_object -> uri != NULL );
1062
1046
1063
1047
uri_object_t * new_uri_object = uri_object_from_obj (object -> ce -> create_object (object -> ce ));
1064
- ZEND_ASSERT (new_uri_object -> internal . parser == internal_uri -> parser );
1048
+ ZEND_ASSERT (new_uri_object -> parser == uri_object -> parser );
1065
1049
1066
- void * uri = internal_uri -> parser -> clone (internal_uri -> uri );
1050
+ void * uri = uri_object -> parser -> clone (uri_object -> uri );
1067
1051
ZEND_ASSERT (uri != NULL );
1068
1052
1069
- new_uri_object -> internal . uri = uri ;
1053
+ new_uri_object -> uri = uri ;
1070
1054
1071
1055
zend_objects_clone_members (& new_uri_object -> std , & uri_object -> std );
1072
1056
0 commit comments