From 75229e0817cf3e3540c3fbad98d408f28dfcd675 Mon Sep 17 00:00:00 2001 From: Daniel Scherzer Date: Sat, 8 Aug 2026 18:12:31 -0700 Subject: [PATCH] [`%pS` migration] Use `%pS` in ext/uri --- ext/uri/php_uri.c | 24 ++++++++++++------------ ext/uri/php_uri_common.c | 2 +- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/ext/uri/php_uri.c b/ext/uri/php_uri.c index 74a559fd591c..c517b414d194 100644 --- a/ext/uri/php_uri.c +++ b/ext/uri/php_uri.c @@ -346,7 +346,7 @@ ZEND_ATTRIBUTE_NONNULL_ARGS(1, 2) PHPAPI void php_uri_instantiate_uri( if (should_update_this_object) { uri_object = Z_URI_OBJECT_P(ZEND_THIS); if (uri_object->uri != NULL) { - zend_throw_error(NULL, "Cannot modify readonly object of class %s", ZSTR_VAL(Z_OBJCE_P(ZEND_THIS)->name)); + zend_throw_error(NULL, "Cannot modify readonly object of class %pS", Z_OBJCE_P(ZEND_THIS)->name); RETURN_THROWS(); } } else { @@ -464,7 +464,7 @@ PHP_METHOD(Uri_WhatWg_InvalidUrlException, __construct) zend_update_property(php_uri_ce_whatwg_invalid_url_exception, Z_OBJ_P(ZEND_THIS), ZEND_STRL("errors"), &tmp); } else { if (!is_list_of_whatwg_validation_errors(Z_ARR_P(errors))) { - zend_argument_value_error(2, "must be a list of %s", ZSTR_VAL(php_uri_ce_whatwg_url_validation_error->name)); + zend_argument_value_error(2, "must be a list of %pS", php_uri_ce_whatwg_url_validation_error->name); RETURN_THROWS(); } @@ -717,7 +717,7 @@ PHP_METHOD(Uri_Rfc3986_Uri, withFragment) static void throw_cannot_recompose_uri_to_string(php_uri_object *object) { - zend_throw_exception_ex(php_uri_ce_error, 0, "Cannot recompose %s to a string", ZSTR_VAL(object->std.ce->name)); + zend_throw_exception_ex(php_uri_ce_error, 0, "Cannot recompose %pS to a string", object->std.ce->name); } static void uri_equals(INTERNAL_FUNCTION_PARAMETERS, php_uri_object *that_object, zend_enum_Uri_UriComparisonMode comparison_mode) @@ -853,52 +853,52 @@ static void uri_unserialize(INTERNAL_FUNCTION_PARAMETERS) php_uri_object *uri_object = php_uri_object_from_obj(Z_OBJ_P(ZEND_THIS)); if (uri_object->uri != NULL) { /* Intentionally throw two exceptions for proper chaining. */ - zend_throw_error(NULL, "Cannot modify readonly object of class %s", ZSTR_VAL(uri_object->std.ce->name)); - zend_throw_exception_ex(NULL, 0, "Invalid serialization data for %s object", ZSTR_VAL(uri_object->std.ce->name)); + zend_throw_error(NULL, "Cannot modify readonly object of class %pS", uri_object->std.ce->name); + zend_throw_exception_ex(NULL, 0, "Invalid serialization data for %pS object", uri_object->std.ce->name); RETURN_THROWS(); } /* Verify the expected number of elements, this implicitly ensures that no additional elements are present. */ if (zend_hash_num_elements(data) != 2) { - zend_throw_exception_ex(NULL, 0, "Invalid serialization data for %s object", ZSTR_VAL(uri_object->std.ce->name)); + zend_throw_exception_ex(NULL, 0, "Invalid serialization data for %pS object", uri_object->std.ce->name); RETURN_THROWS(); } /* Unserialize state: "uri" key in the first array */ zval *arr = zend_hash_index_find(data, 0); if (arr == NULL || Z_TYPE_P(arr) != IS_ARRAY) { - zend_throw_exception_ex(NULL, 0, "Invalid serialization data for %s object", ZSTR_VAL(uri_object->std.ce->name)); + zend_throw_exception_ex(NULL, 0, "Invalid serialization data for %pS object", uri_object->std.ce->name); RETURN_THROWS(); } /* Verify the expected number of elements inside the first array, this implicitly ensures that no additional elements are present. */ if (zend_hash_num_elements(Z_ARRVAL_P(arr)) != 1) { - zend_throw_exception_ex(NULL, 0, "Invalid serialization data for %s object", ZSTR_VAL(uri_object->std.ce->name)); + zend_throw_exception_ex(NULL, 0, "Invalid serialization data for %pS object", uri_object->std.ce->name); RETURN_THROWS(); } zval *uri_zv = zend_hash_str_find(Z_ARRVAL_P(arr), ZEND_STRL(PHP_URI_SERIALIZE_URI_FIELD_NAME)); if (uri_zv == NULL || Z_TYPE_P(uri_zv) != IS_STRING) { - zend_throw_exception_ex(NULL, 0, "Invalid serialization data for %s object", ZSTR_VAL(uri_object->std.ce->name)); + zend_throw_exception_ex(NULL, 0, "Invalid serialization data for %pS object", uri_object->std.ce->name); RETURN_THROWS(); } uri_object->uri = uri_object->parser->parse(Z_STRVAL_P(uri_zv), Z_STRLEN_P(uri_zv), NULL, NULL, true); if (uri_object->uri == NULL) { - zend_throw_exception_ex(NULL, 0, "Invalid serialization data for %s object", ZSTR_VAL(uri_object->std.ce->name)); + zend_throw_exception_ex(NULL, 0, "Invalid serialization data for %pS object", uri_object->std.ce->name); RETURN_THROWS(); } /* Unserialize regular properties: second array */ arr = zend_hash_index_find(data, 1); if (arr == NULL || Z_TYPE_P(arr) != IS_ARRAY) { - zend_throw_exception_ex(NULL, 0, "Invalid serialization data for %s object", ZSTR_VAL(uri_object->std.ce->name)); + zend_throw_exception_ex(NULL, 0, "Invalid serialization data for %pS object", uri_object->std.ce->name); RETURN_THROWS(); } /* Verify that there is no regular property in the second array, because the URI classes have no properties and they are final. */ if (zend_hash_num_elements(Z_ARRVAL_P(arr)) > 0) { - zend_throw_exception_ex(NULL, 0, "Invalid serialization data for %s object", ZSTR_VAL(uri_object->std.ce->name)); + zend_throw_exception_ex(NULL, 0, "Invalid serialization data for %pS object", uri_object->std.ce->name); RETURN_THROWS(); } } diff --git a/ext/uri/php_uri_common.c b/ext/uri/php_uri_common.c index 0644afda3105..b68a2f920236 100644 --- a/ext/uri/php_uri_common.c +++ b/ext/uri/php_uri_common.c @@ -50,7 +50,7 @@ void php_uri_property_read_helper(INTERNAL_FUNCTION_PARAMETERS, php_uri_property const php_uri_property_handler *property_handler = php_uri_parser_property_handler_by_name(uri_object->parser, property_name); if (UNEXPECTED(property_handler->read(uri_object->uri, component_read_mode, return_value) == FAILURE)) { - 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))); + zend_throw_exception_ex(php_uri_ce_error, 0, "The %pS component cannot be retrieved", get_known_string_by_property_name(property_name)); RETURN_THROWS(); } }