Skip to content

Commit cc24615

Browse files
committed
uri: Clean up naming of uri_object_t variables
1 parent 1cde772 commit cc24615

File tree

2 files changed

+33
-36
lines changed

2 files changed

+33
-36
lines changed

ext/uri/php_uri.c

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -561,11 +561,10 @@ PHP_METHOD(Uri_Rfc3986_Uri, withUserInfo)
561561
ZVAL_STR(&zv, value);
562562
}
563563

564-
zend_object *old_object = Z_OBJ_P(ZEND_THIS);
565-
uri_object_t *old_uri_object = uri_object_from_obj(old_object);
564+
uri_object_t *old_uri_object = uri_object_from_obj(Z_OBJ_P(ZEND_THIS));
566565
ZEND_ASSERT(old_uri_object->uri != NULL);
567566

568-
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);
569568
if (new_object == NULL) {
570569
RETURN_THROWS();
571570
}
@@ -735,12 +734,12 @@ PHP_METHOD(Uri_Rfc3986_Uri, toRawString)
735734
{
736735
ZEND_PARSE_PARAMETERS_NONE();
737736

738-
uri_object_t *this_object = Z_URI_OBJECT_P(ZEND_THIS);
739-
ZEND_ASSERT(this_object->uri != NULL);
737+
uri_object_t *uri_object = Z_URI_OBJECT_P(ZEND_THIS);
738+
ZEND_ASSERT(uri_object->uri != NULL);
740739

741-
zend_string *uri_str = this_object->parser->to_string(this_object->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);
742741
if (uri_str == NULL) {
743-
throw_cannot_recompose_uri_to_string(this_object);
742+
throw_cannot_recompose_uri_to_string(uri_object);
744743
RETURN_THROWS();
745744
}
746745

@@ -751,12 +750,12 @@ PHP_METHOD(Uri_Rfc3986_Uri, toString)
751750
{
752751
ZEND_PARSE_PARAMETERS_NONE();
753752

754-
uri_object_t *this_object = Z_URI_OBJECT_P(ZEND_THIS);
755-
ZEND_ASSERT(this_object->uri != NULL);
753+
uri_object_t *uri_object = Z_URI_OBJECT_P(ZEND_THIS);
754+
ZEND_ASSERT(uri_object->uri != NULL);
756755

757-
zend_string *uri_str = this_object->parser->to_string(this_object->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);
758757
if (uri_str == NULL) {
759-
throw_cannot_recompose_uri_to_string(this_object);
758+
throw_cannot_recompose_uri_to_string(uri_object);
760759
RETURN_THROWS();
761760
}
762761

@@ -779,13 +778,13 @@ PHP_METHOD(Uri_Rfc3986_Uri, __serialize)
779778
{
780779
ZEND_PARSE_PARAMETERS_NONE();
781780

782-
uri_object_t *this_object = Z_URI_OBJECT_P(ZEND_THIS);
783-
ZEND_ASSERT(this_object->uri != NULL);
781+
uri_object_t *uri_object = Z_URI_OBJECT_P(ZEND_THIS);
782+
ZEND_ASSERT(uri_object->uri != NULL);
784783

785784
/* Serialize state: "uri" key in the first array */
786-
zend_string *uri_str = this_object->parser->to_string(this_object->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);
787786
if (uri_str == NULL) {
788-
throw_cannot_recompose_uri_to_string(this_object);
787+
throw_cannot_recompose_uri_to_string(uri_object);
789788
RETURN_THROWS();
790789
}
791790
zval tmp;
@@ -799,7 +798,7 @@ PHP_METHOD(Uri_Rfc3986_Uri, __serialize)
799798
zend_hash_next_index_insert(Z_ARRVAL_P(return_value), &arr);
800799

801800
/* Serialize regular properties: second array */
802-
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));
803802
Z_TRY_ADDREF(arr);
804803
zend_hash_next_index_insert(Z_ARRVAL_P(return_value), &arr);
805804
}
@@ -812,56 +811,55 @@ static void uri_unserialize(INTERNAL_FUNCTION_PARAMETERS)
812811
Z_PARAM_ARRAY_HT(data)
813812
ZEND_PARSE_PARAMETERS_END();
814813

815-
zend_object *object = Z_OBJ_P(ZEND_THIS);
816-
uri_object_t *uri_object = uri_object_from_obj(object);
814+
uri_object_t *uri_object = uri_object_from_obj(Z_OBJ_P(ZEND_THIS));
817815
if (uri_object->uri != NULL) {
818816
/* Intentionally throw two exceptions for proper chaining. */
819-
zend_throw_error(NULL, "Cannot modify readonly object of class %s", ZSTR_VAL(object->ce->name));
820-
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));
821819
RETURN_THROWS();
822820
}
823821

824822
/* Verify the expected number of elements, this implicitly ensures that no additional elements are present. */
825823
if (zend_hash_num_elements(data) != 2) {
826-
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));
827825
RETURN_THROWS();
828826
}
829827

830828
/* Unserialize state: "uri" key in the first array */
831829
zval *arr = zend_hash_index_find(data, 0);
832830
if (arr == NULL || Z_TYPE_P(arr) != IS_ARRAY) {
833-
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));
834832
RETURN_THROWS();
835833
}
836834

837835
/* Verify the expected number of elements inside the first array, this implicitly ensures that no additional elements are present. */
838836
if (zend_hash_num_elements(Z_ARRVAL_P(arr)) != 1) {
839-
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));
840838
RETURN_THROWS();
841839
}
842840

843841
zval *uri_zv = zend_hash_str_find_ind(Z_ARRVAL_P(arr), ZEND_STRL(URI_SERIALIZED_PROPERTY_NAME));
844842
if (uri_zv == NULL || Z_TYPE_P(uri_zv) != IS_STRING) {
845-
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));
846844
RETURN_THROWS();
847845
}
848846

849847
uri_object->uri = uri_object->parser->parse(Z_STRVAL_P(uri_zv), Z_STRLEN_P(uri_zv), NULL, NULL, true);
850848
if (uri_object->uri == NULL) {
851-
zend_throw_exception_ex(NULL, 0, "Invalid serialization data for %s object", ZSTR_VAL(object->ce->name));
849+
zend_throw_exception_ex(NULL, 0, "Invalid serialization data for %s object", ZSTR_VAL(uri_object->std.ce->name));
852850
RETURN_THROWS();
853851
}
854852

855853
/* Unserialize regular properties: second array */
856854
arr = zend_hash_index_find(data, 1);
857855
if (arr == NULL || Z_TYPE_P(arr) != IS_ARRAY) {
858-
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));
859857
RETURN_THROWS();
860858
}
861859

862860
/* Verify that there is no regular property in the second array, because the URI classes have no properties and they are final. */
863861
if (zend_hash_num_elements(Z_ARRVAL_P(arr)) > 0) {
864-
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));
865863
RETURN_THROWS();
866864
}
867865
}

ext/uri/php_uri_common.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,10 @@ void uri_read_component(INTERNAL_FUNCTION_PARAMETERS, php_uri_property_name prop
5959

6060
static void uri_write_component_ex(INTERNAL_FUNCTION_PARAMETERS, php_uri_property_name property_name, zval *property_zv)
6161
{
62-
zend_object *old_object = Z_OBJ_P(ZEND_THIS);
63-
uri_object_t *internal_uri = Z_URI_OBJECT_P(ZEND_THIS);
64-
ZEND_ASSERT(internal_uri->uri != NULL);
62+
uri_object_t *old_uri_object = Z_URI_OBJECT_P(ZEND_THIS);
63+
ZEND_ASSERT(old_uri_object->uri != NULL);
6564

66-
zend_object *new_object = old_object->handlers->clone_obj(old_object);
65+
zend_object *new_object = old_uri_object->std.handlers->clone_obj(&old_uri_object->std);
6766
if (new_object == NULL) {
6867
RETURN_THROWS();
6968
}
@@ -72,19 +71,19 @@ static void uri_write_component_ex(INTERNAL_FUNCTION_PARAMETERS, php_uri_propert
7271
* case of an exception being thrown. */
7372
RETVAL_OBJ(new_object);
7473

75-
const php_uri_property_handler *property_handler = php_uri_parser_property_handler_by_name(internal_uri->parser, property_name);
74+
const php_uri_property_handler *property_handler = php_uri_parser_property_handler_by_name(old_uri_object->parser, property_name);
7675

77-
uri_object_t *new_internal_uri = uri_object_from_obj(new_object);
78-
ZEND_ASSERT(new_internal_uri->uri != NULL);
76+
uri_object_t *new_uri_object = uri_object_from_obj(new_object);
77+
ZEND_ASSERT(new_uri_object->uri != NULL);
7978
if (UNEXPECTED(property_handler->write == NULL)) {
80-
zend_readonly_property_modification_error_ex(ZSTR_VAL(old_object->ce->name),
79+
zend_readonly_property_modification_error_ex(ZSTR_VAL(old_uri_object->std.ce->name),
8180
ZSTR_VAL(get_known_string_by_property_name(property_name)));
8281
RETURN_THROWS();
8382
}
8483

8584
zval errors;
8685
ZVAL_UNDEF(&errors);
87-
if (UNEXPECTED(property_handler->write(new_internal_uri->uri, property_zv, &errors) == FAILURE)) {
86+
if (UNEXPECTED(property_handler->write(new_uri_object->uri, property_zv, &errors) == FAILURE)) {
8887
zval_ptr_dtor(&errors);
8988
RETURN_THROWS();
9089
}

0 commit comments

Comments
 (0)