Skip to content

Commit e23c622

Browse files
authored
uri: Clean up naming of remaining public symbols (#19917)
* uri: Rename `uri_object_t` to `php_uri_object` * uri: Rename `uri_(read|write)_component_*` to `php_uri_property_(read|write)_*_helper` * uri: Rename `URI_SERIALIZED_PROPERTY_NAME` to `PHP_URI_SERIALIZE_URI_FIELD_NAME` * uri: Rename `uri_internal_t` to `php_uri_internal` * uri: Use proper `php_uri_ce_` prefix for all CEs * uri: Make the object handlers `static` and remove them from the header
1 parent 6e1b190 commit e23c622

File tree

9 files changed

+198
-199
lines changed

9 files changed

+198
-199
lines changed

ext/openssl/xp_ssl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2640,7 +2640,7 @@ static char *php_openssl_get_url_name(const char *resourcename,
26402640
return NULL;
26412641
}
26422642

2643-
uri_internal_t *internal_uri = php_uri_parse(uri_parser, resourcename, resourcenamelen, true);
2643+
php_uri_internal *internal_uri = php_uri_parse(uri_parser, resourcename, resourcenamelen, true);
26442644
if (internal_uri == NULL) {
26452645
return NULL;
26462646
}

ext/uri/php_uri.c

Lines changed: 120 additions & 119 deletions
Large diffs are not rendered by default.

ext/uri/php_uri.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ PHPAPI zend_result php_uri_parser_register(const php_uri_parser *uri_parser);
5151
*/
5252
PHPAPI const php_uri_parser *php_uri_get_parser(zend_string *uri_parser_name);
5353

54-
ZEND_ATTRIBUTE_NONNULL PHPAPI uri_internal_t *php_uri_parse(const php_uri_parser *uri_parser, const char *uri_str, size_t uri_str_len, bool silent);
54+
ZEND_ATTRIBUTE_NONNULL PHPAPI php_uri_internal *php_uri_parse(const php_uri_parser *uri_parser, const char *uri_str, size_t uri_str_len, bool silent);
5555

5656
/**
5757
* Retrieves the scheme component based on the read_mode and passes it to the zv ZVAL in case of success.
@@ -66,7 +66,7 @@ ZEND_ATTRIBUTE_NONNULL PHPAPI uri_internal_t *php_uri_parse(const php_uri_parser
6666
* @param zv The output parameter containing the retrieved component as a ZVAL (either IS_STRING or IS_NULL).
6767
* @return SUCCESS in case of success, FAILURE otherwise.
6868
*/
69-
ZEND_ATTRIBUTE_NONNULL PHPAPI zend_result php_uri_get_scheme(const uri_internal_t *internal_uri, php_uri_component_read_mode read_mode, zval *zv);
69+
ZEND_ATTRIBUTE_NONNULL PHPAPI zend_result php_uri_get_scheme(const php_uri_internal *internal_uri, php_uri_component_read_mode read_mode, zval *zv);
7070

7171
/**
7272
* Retrieves the username component based on the read_mode and passes it to the zv ZVAL in case of success.
@@ -81,7 +81,7 @@ ZEND_ATTRIBUTE_NONNULL PHPAPI zend_result php_uri_get_scheme(const uri_internal_
8181
* @param zv The output parameter containing the retrieved component as a ZVAL (either IS_STRING or IS_NULL).
8282
* @return SUCCESS in case of success, FAILURE otherwise.
8383
*/
84-
ZEND_ATTRIBUTE_NONNULL PHPAPI zend_result php_uri_get_username(const uri_internal_t *internal_uri, php_uri_component_read_mode read_mode, zval *zv);
84+
ZEND_ATTRIBUTE_NONNULL PHPAPI zend_result php_uri_get_username(const php_uri_internal *internal_uri, php_uri_component_read_mode read_mode, zval *zv);
8585

8686
/**
8787
* Retrieves the password component based on the read_mode and passes it to the zv ZVAL in case of success.
@@ -96,7 +96,7 @@ ZEND_ATTRIBUTE_NONNULL PHPAPI zend_result php_uri_get_username(const uri_interna
9696
* @param zv The output parameter containing the retrieved component as a ZVAL (either IS_STRING or IS_NULL).
9797
* @return SUCCESS in case of success, FAILURE otherwise.
9898
*/
99-
ZEND_ATTRIBUTE_NONNULL PHPAPI zend_result php_uri_get_password(const uri_internal_t *internal_uri, php_uri_component_read_mode read_mode, zval *zv);
99+
ZEND_ATTRIBUTE_NONNULL PHPAPI zend_result php_uri_get_password(const php_uri_internal *internal_uri, php_uri_component_read_mode read_mode, zval *zv);
100100

101101
/**
102102
* Retrieves the host component based on the read_mode and passes it to the zv ZVAL in case of success.
@@ -111,7 +111,7 @@ ZEND_ATTRIBUTE_NONNULL PHPAPI zend_result php_uri_get_password(const uri_interna
111111
* @param zv The output parameter containing the retrieved component as a ZVAL (either IS_STRING or IS_NULL).
112112
* @return SUCCESS in case of success, FAILURE otherwise.
113113
*/
114-
ZEND_ATTRIBUTE_NONNULL PHPAPI zend_result php_uri_get_host(const uri_internal_t *internal_uri, php_uri_component_read_mode read_mode, zval *zv);
114+
ZEND_ATTRIBUTE_NONNULL PHPAPI zend_result php_uri_get_host(const php_uri_internal *internal_uri, php_uri_component_read_mode read_mode, zval *zv);
115115

116116
/**
117117
* Retrieves the port component based on the read_mode and passes it to the zv ZVAL in case of success.
@@ -126,7 +126,7 @@ ZEND_ATTRIBUTE_NONNULL PHPAPI zend_result php_uri_get_host(const uri_internal_t
126126
* @param zv The output parameter containing the retrieved component as a ZVAL (either IS_LONG or IS_NULL).
127127
* @return SUCCESS in case of success, FAILURE otherwise.
128128
*/
129-
ZEND_ATTRIBUTE_NONNULL PHPAPI zend_result php_uri_get_port(const uri_internal_t *internal_uri, php_uri_component_read_mode read_mode, zval *zv);
129+
ZEND_ATTRIBUTE_NONNULL PHPAPI zend_result php_uri_get_port(const php_uri_internal *internal_uri, php_uri_component_read_mode read_mode, zval *zv);
130130

131131
/**
132132
* Retrieves the path component based on the read_mode and passes it to the zv ZVAL in case of success.
@@ -141,7 +141,7 @@ ZEND_ATTRIBUTE_NONNULL PHPAPI zend_result php_uri_get_port(const uri_internal_t
141141
* @param zv The output parameter containing the retrieved component as a ZVAL (either IS_STRING or IS_NULL).
142142
* @return SUCCESS in case of success, FAILURE otherwise.
143143
*/
144-
ZEND_ATTRIBUTE_NONNULL PHPAPI zend_result php_uri_get_path(const uri_internal_t *internal_uri, php_uri_component_read_mode read_mode, zval *zv);
144+
ZEND_ATTRIBUTE_NONNULL PHPAPI zend_result php_uri_get_path(const php_uri_internal *internal_uri, php_uri_component_read_mode read_mode, zval *zv);
145145

146146
/**
147147
* Retrieves the query component based on the read_mode and passes it to the zv ZVAL in case of success.
@@ -156,7 +156,7 @@ ZEND_ATTRIBUTE_NONNULL PHPAPI zend_result php_uri_get_path(const uri_internal_t
156156
* @param zv The output parameter containing the retrieved component as a ZVAL (either IS_STRING or IS_NULL).
157157
* @return SUCCESS in case of success, FAILURE otherwise.
158158
*/
159-
ZEND_ATTRIBUTE_NONNULL PHPAPI zend_result php_uri_get_query(const uri_internal_t *internal_uri, php_uri_component_read_mode read_mode, zval *zv);
159+
ZEND_ATTRIBUTE_NONNULL PHPAPI zend_result php_uri_get_query(const php_uri_internal *internal_uri, php_uri_component_read_mode read_mode, zval *zv);
160160

161161
/**
162162
* Retrieves the fragment component based on the read_mode and passes it to the zv ZVAL in case of success.
@@ -171,14 +171,14 @@ ZEND_ATTRIBUTE_NONNULL PHPAPI zend_result php_uri_get_query(const uri_internal_t
171171
* @param zv The output parameter containing the retrieved component as a ZVAL (either IS_STRING or IS_NULL).
172172
* @return SUCCESS in case of success, FAILURE otherwise.
173173
*/
174-
ZEND_ATTRIBUTE_NONNULL PHPAPI zend_result php_uri_get_fragment(const uri_internal_t *internal_uri, php_uri_component_read_mode read_mode, zval *zv);
174+
ZEND_ATTRIBUTE_NONNULL PHPAPI zend_result php_uri_get_fragment(const php_uri_internal *internal_uri, php_uri_component_read_mode read_mode, zval *zv);
175175

176176
/**
177177
* Frees the uri member within the provided internal URI.
178178
*
179179
* @param internal_uri The internal URI
180180
*/
181-
ZEND_ATTRIBUTE_NONNULL PHPAPI void php_uri_free(uri_internal_t *internal_uri);
181+
ZEND_ATTRIBUTE_NONNULL PHPAPI void php_uri_free(php_uri_internal *internal_uri);
182182

183183
/**
184184
* Creates a new php_uri struct containing all the URI components. The components are retrieved based on the read_mode parameter.
@@ -207,7 +207,7 @@ ZEND_ATTRIBUTE_NONNULL PHPAPI php_uri *php_uri_parse_to_struct(
207207
ZEND_ATTRIBUTE_NONNULL PHPAPI void php_uri_struct_free(php_uri *uri);
208208

209209
ZEND_ATTRIBUTE_NONNULL_ARGS(1, 2) PHPAPI void php_uri_instantiate_uri(
210-
INTERNAL_FUNCTION_PARAMETERS, const zend_string *uri_str, const uri_object_t *base_url_object,
210+
INTERNAL_FUNCTION_PARAMETERS, const zend_string *uri_str, const php_uri_object *base_url_object,
211211
bool should_throw, bool should_update_this_object, zval *errors_zv
212212
);
213213

ext/uri/php_uri_common.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,24 +42,24 @@ static zend_string *get_known_string_by_property_name(php_uri_property_name prop
4242
}
4343
}
4444

45-
void uri_read_component(INTERNAL_FUNCTION_PARAMETERS, php_uri_property_name property_name, php_uri_component_read_mode component_read_mode)
45+
void php_uri_property_read_helper(INTERNAL_FUNCTION_PARAMETERS, php_uri_property_name property_name, php_uri_component_read_mode component_read_mode)
4646
{
4747
ZEND_PARSE_PARAMETERS_NONE();
4848

49-
uri_object_t *uri_object = Z_URI_OBJECT_P(ZEND_THIS);
49+
php_uri_object *uri_object = Z_URI_OBJECT_P(ZEND_THIS);
5050
ZEND_ASSERT(uri_object->uri != NULL);
5151

5252
const php_uri_property_handler *property_handler = php_uri_parser_property_handler_by_name(uri_object->parser, property_name);
5353

5454
if (UNEXPECTED(property_handler->read(uri_object->uri, component_read_mode, return_value) == FAILURE)) {
55-
zend_throw_exception_ex(uri_error_ce, 0, "The %s component cannot be retrieved", ZSTR_VAL(get_known_string_by_property_name(property_name)));
55+
zend_throw_exception_ex(php_uri_ce_error, 0, "The %s component cannot be retrieved", ZSTR_VAL(get_known_string_by_property_name(property_name)));
5656
RETURN_THROWS();
5757
}
5858
}
5959

60-
static void uri_write_component_ex(INTERNAL_FUNCTION_PARAMETERS, php_uri_property_name property_name, zval *property_zv)
60+
static void php_uri_property_write_helper(INTERNAL_FUNCTION_PARAMETERS, php_uri_property_name property_name, zval *property_zv)
6161
{
62-
uri_object_t *old_uri_object = Z_URI_OBJECT_P(ZEND_THIS);
62+
php_uri_object *old_uri_object = Z_URI_OBJECT_P(ZEND_THIS);
6363
ZEND_ASSERT(old_uri_object->uri != NULL);
6464

6565
zend_object *new_object = old_uri_object->std.handlers->clone_obj(&old_uri_object->std);
@@ -73,7 +73,7 @@ static void uri_write_component_ex(INTERNAL_FUNCTION_PARAMETERS, php_uri_propert
7373

7474
const php_uri_property_handler *property_handler = php_uri_parser_property_handler_by_name(old_uri_object->parser, property_name);
7575

76-
uri_object_t *new_uri_object = uri_object_from_obj(new_object);
76+
php_uri_object *new_uri_object = php_uri_object_from_obj(new_object);
7777
ZEND_ASSERT(new_uri_object->uri != NULL);
7878
if (UNEXPECTED(property_handler->write == NULL)) {
7979
zend_readonly_property_modification_error_ex(ZSTR_VAL(old_uri_object->std.ce->name),
@@ -91,7 +91,7 @@ static void uri_write_component_ex(INTERNAL_FUNCTION_PARAMETERS, php_uri_propert
9191
ZEND_ASSERT(Z_ISUNDEF(errors));
9292
}
9393

94-
void uri_write_component_str(INTERNAL_FUNCTION_PARAMETERS, php_uri_property_name property_name)
94+
void php_uri_property_write_str_helper(INTERNAL_FUNCTION_PARAMETERS, php_uri_property_name property_name)
9595
{
9696
zend_string *value;
9797

@@ -102,10 +102,10 @@ void uri_write_component_str(INTERNAL_FUNCTION_PARAMETERS, php_uri_property_name
102102
zval zv;
103103
ZVAL_STR(&zv, value);
104104

105-
uri_write_component_ex(INTERNAL_FUNCTION_PARAM_PASSTHRU, property_name, &zv);
105+
php_uri_property_write_helper(INTERNAL_FUNCTION_PARAM_PASSTHRU, property_name, &zv);
106106
}
107107

108-
void uri_write_component_str_or_null(INTERNAL_FUNCTION_PARAMETERS, php_uri_property_name property_name)
108+
void php_uri_property_write_str_or_null_helper(INTERNAL_FUNCTION_PARAMETERS, php_uri_property_name property_name)
109109
{
110110
zend_string *value;
111111

@@ -120,10 +120,10 @@ void uri_write_component_str_or_null(INTERNAL_FUNCTION_PARAMETERS, php_uri_prope
120120
ZVAL_STR(&zv, value);
121121
}
122122

123-
uri_write_component_ex(INTERNAL_FUNCTION_PARAM_PASSTHRU, property_name, &zv);
123+
php_uri_property_write_helper(INTERNAL_FUNCTION_PARAM_PASSTHRU, property_name, &zv);
124124
}
125125

126-
void uri_write_component_long_or_null(INTERNAL_FUNCTION_PARAMETERS, php_uri_property_name property_name)
126+
void php_uri_property_write_long_or_null_helper(INTERNAL_FUNCTION_PARAMETERS, php_uri_property_name property_name)
127127
{
128128
zend_long value;
129129
bool value_is_null;
@@ -139,5 +139,5 @@ void uri_write_component_long_or_null(INTERNAL_FUNCTION_PARAMETERS, php_uri_prop
139139
ZVAL_LONG(&zv, value);
140140
}
141141

142-
uri_write_component_ex(INTERNAL_FUNCTION_PARAM_PASSTHRU, property_name, &zv);
142+
php_uri_property_write_helper(INTERNAL_FUNCTION_PARAM_PASSTHRU, property_name, &zv);
143143
}

ext/uri/php_uri_common.h

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,15 @@
1717
#ifndef PHP_URI_COMMON_H
1818
#define PHP_URI_COMMON_H
1919

20-
extern zend_class_entry *uri_rfc3986_uri_ce;
21-
extern zend_object_handlers uri_rfc3986_uri_object_handlers;
22-
extern zend_class_entry *uri_whatwg_url_ce;
23-
extern zend_object_handlers uri_whatwg_uri_object_handlers;
24-
extern zend_class_entry *uri_comparison_mode_ce;
25-
extern zend_class_entry *uri_exception_ce;
26-
extern zend_class_entry *uri_error_ce;
27-
extern zend_class_entry *uri_invalid_uri_exception_ce;
28-
extern zend_class_entry *uri_whatwg_invalid_url_exception_ce;
29-
extern zend_class_entry *uri_whatwg_url_validation_error_type_ce;
30-
extern zend_class_entry *uri_whatwg_url_validation_error_ce;
20+
extern zend_class_entry *php_uri_ce_rfc3986_uri;
21+
extern zend_class_entry *php_uri_ce_whatwg_url;
22+
extern zend_class_entry *php_uri_ce_comparison_mode;
23+
extern zend_class_entry *php_uri_ce_exception;
24+
extern zend_class_entry *php_uri_ce_error;
25+
extern zend_class_entry *php_uri_ce_invalid_uri_exception;
26+
extern zend_class_entry *php_uri_ce_whatwg_invalid_url_exception;
27+
extern zend_class_entry *php_uri_ce_whatwg_url_validation_error_type;
28+
extern zend_class_entry *php_uri_ce_whatwg_url_validation_error;
3129

3230
typedef enum php_uri_recomposition_mode {
3331
PHP_URI_RECOMPOSITION_MODE_RAW_ASCII,
@@ -137,31 +135,31 @@ typedef struct php_uri_parser {
137135
} property_handler;
138136
} php_uri_parser;
139137

140-
typedef struct uri_internal_t {
138+
typedef struct php_uri_internal {
141139
const php_uri_parser *parser;
142140
void *uri;
143-
} uri_internal_t;
141+
} php_uri_internal;
144142

145-
typedef struct uri_object_t {
143+
typedef struct php_uri_object {
146144
const php_uri_parser *parser;
147145
void *uri;
148146
zend_object std;
149-
} uri_object_t;
147+
} php_uri_object;
150148

151-
static inline uri_object_t *uri_object_from_obj(zend_object *object) {
152-
return (uri_object_t*)((char*)(object) - XtOffsetOf(uri_object_t, std));
149+
static inline php_uri_object *php_uri_object_from_obj(zend_object *object) {
150+
return (php_uri_object*)((char*)(object) - XtOffsetOf(php_uri_object, std));
153151
}
154152

155-
#define Z_URI_OBJECT_P(zv) uri_object_from_obj(Z_OBJ_P((zv)))
153+
#define Z_URI_OBJECT_P(zv) php_uri_object_from_obj(Z_OBJ_P((zv)))
156154

157-
PHPAPI uri_object_t *php_uri_object_create(zend_class_entry *class_type, const php_uri_parser *parser);
155+
PHPAPI php_uri_object *php_uri_object_create(zend_class_entry *class_type, const php_uri_parser *parser);
158156
PHPAPI void php_uri_object_handler_free(zend_object *object);
159157
PHPAPI zend_object *php_uri_object_handler_clone(zend_object *object);
160158

161159
#define PHP_URI_PARSER_RFC3986 "Uri\\Rfc3986\\Uri"
162160
#define PHP_URI_PARSER_WHATWG "Uri\\WhatWg\\Url"
163161
#define PHP_URI_PARSER_PHP_PARSE_URL "parse_url"
164-
#define URI_SERIALIZED_PROPERTY_NAME "uri"
162+
#define PHP_URI_SERIALIZE_URI_FIELD_NAME "uri"
165163

166164
static inline const php_uri_property_handler *php_uri_parser_property_handler_by_name(const php_uri_parser *parser, php_uri_property_name property_name)
167165
{
@@ -186,9 +184,9 @@ static inline const php_uri_property_handler *php_uri_parser_property_handler_by
186184
}
187185
}
188186

189-
void uri_read_component(INTERNAL_FUNCTION_PARAMETERS, php_uri_property_name property_name, php_uri_component_read_mode component_read_mode);
190-
void uri_write_component_str(INTERNAL_FUNCTION_PARAMETERS, php_uri_property_name property_name);
191-
void uri_write_component_str_or_null(INTERNAL_FUNCTION_PARAMETERS, php_uri_property_name property_name);
192-
void uri_write_component_long_or_null(INTERNAL_FUNCTION_PARAMETERS, php_uri_property_name property_name);
187+
void php_uri_property_read_helper(INTERNAL_FUNCTION_PARAMETERS, php_uri_property_name property_name, php_uri_component_read_mode component_read_mode);
188+
void php_uri_property_write_str_helper(INTERNAL_FUNCTION_PARAMETERS, php_uri_property_name property_name);
189+
void php_uri_property_write_str_or_null_helper(INTERNAL_FUNCTION_PARAMETERS, php_uri_property_name property_name);
190+
void php_uri_property_write_long_or_null_helper(INTERNAL_FUNCTION_PARAMETERS, php_uri_property_name property_name);
193191

194192
#endif

ext/uri/uri_parser_php_parse_url.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ static void *uri_parser_php_parse_url_parse(const char *uri_str, size_t uri_str_
148148

149149
php_url *url = php_url_parse_ex2(uri_str, uri_str_len, &has_port);
150150
if (url == NULL && !silent) {
151-
zend_throw_exception(uri_invalid_uri_exception_ce, "The specified URI is malformed", 0);
151+
zend_throw_exception(php_uri_ce_invalid_uri_exception, "The specified URI is malformed", 0);
152152
}
153153

154154
return url;

0 commit comments

Comments
 (0)