[php-src] PR #20243: uri: Make `php_uri_parser` structs PHPAPI

From: Date: Mon, 20 Oct 2025 12:42:55 +0000
Subject: [php-src] PR #20243: uri: Make `php_uri_parser` structs PHPAPI
Groups: php.git-pulls 
Request: Send a blank email to [email protected] to get a copy of this message
Pull Request: https://github.com/php/php-src/pull/20243
Author: TimWolla

This one probably is very borderline. Sorry it comes so late, I'm only now trying to integrate
ext/uri in one of my external extensions and thus finding the pain point of the internal API. 

If you don't feel comfortable for PHP 8.5, that's fine. To give you an insight of the API:

```
    zend_string *parser_name = ZSTR_INIT_LITERAL(PHP_URI_PARSER_RFC3986, 0);
    const php_uri_parser *parser = php_uri_get_parser(parser_name);
    zend_string_release(parser_name);

    void *parsed = parser->parse(ZSTR_VAL(uri), ZSTR_LEN(uri), /* base_url */ NULL, /* errors */
NULL, /* silent */ true);
   /* … */
    parser->destroy(parsed);
```
could become:
```
void *parsed = php_uri_parser_rfc3986.parse(ZSTR_VAL(uri), ZSTR_LEN(uri), /* base_url */ NULL, /*
errors */ NULL, /* silent */ true);
/* … */
php_uri_parser_rfc3986.destroy(parsed);
```

--------------

This allows extensions that already know which parser to use and don't need the generic lookup
facility to directly refer to the desired parser without needing to go through
php_uri_get_parser() (which also requires allocating a zend_string*).

Following php/php-src#20173
Related to php/php-src#19868


Thread (1 message)

  • TimWolla
« previous php.git-pulls (#33734) next »