There are several issues with this macro:
- It is incorrectly named: It's not an empty default case. It's an unreachable
default case.
- It is hiding control flow in its definition, which can be confusing for
humans and tools (such as Coccinelle) alike, because it looks like it would
be a statement that belongs to the "current" case rather than opening a new
one.
Since this macro is exactly as long as explicitly spelling out its definition
(excluding the useless `break;`), it is not even making the code any more
succinct.
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
* 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
* uri: Do not pass `uri_internal_t` to property handlers
Within an individual property handler, the `parser` is already implicitly
known, which just leaves the `->uri` field which must contain the entire state
necessary for the handlers to work with.
Pass the `->uri` directly. It avoids one pointer indirection, since the
handlers do not need to follow the pointer to the `uri_internal_t` just to
follow the pointer to the URI state. Instead the URI pointer can directly be
passed using a register with the dereferences (if necessary) happening in the
caller, providing more insight for the compiler to work with.
It also makes it more convenient to use the handlers directly for code that
already knows that it needs a specific URI parser, since no `uri_internal_t`
needs to be constructed to store the already-known information about which
parser to use.
* uri: Use local variable for the URI in `uri_get_debug_properties()`
This makes the code a little less verbose.
* uri: Rename `uri_recomposition_mode_t` to `php_uri_recomposition_mode`
* uri: Align the names of the `php_uri_recomposition_mode` values
* uri: Rename `uri_component_read_mode_t` to `php_uri_component_read_mode`
* uri: Align the names of the `php_uri_component_read_mode` values
* uri: Rename `uri_property_name_t` to `php_uri_property_name`
* uri: Align the names of the `php_uri_property_name` values
* uri: Rename `uri_property_handler_t` to `php_uri_property_handler`
* uri: Rename `uri_(read|write)_t` to `php_uri_property_handler_(read|write)`
* uri: Rename `php_uri_property_handler`’s `(read|write)_func` to `read|write`
The `_func` is implied by the data type and the name of the struct.
* uri: Rename `uri_parser_t` to `php_uri_parser`
* uri: Shorten the names of `php_uri_parser` fields
The `_uri` suffix is implied, because this is an URI parser.
* uri: Make the `.free_uri` handlers safe to call with `NULL`
The `php_uri_free()` function already unconditionally called `->free_uri()` and
thus couldn't be safely used when the `->uri` was `NULL` for some reason.
The lexbor implementation was already safe, because `lxb_url_destroy()` is
guaranteed to be a noop for `NULL`.
* uri: Stop checking for `NULL` before calling `->free_uri()`
This implicitly fixes an `UNEXPECTED(…->uri != NULL)` in `uri_free_obj_handler`
that likely should have read `EXPECTED` instead.
* uri: Remove unnecessary reset of `->uri` to `NULL` in `php_uri_object_handler_free()`
* uri: Document the requirement of `free_uri()` being safe with `NULL`
There were two issues with the previous implementation of normalization:
- `php_raw_url_decode_ex()` would be used to modify a string with RC >1.
- The return value of `php_raw_url_decode_ex()` was not used, resulting in
incorrect string lengths when percent-encoded characters are decoded.
Additionally there was a bogus assertion that verified that strings returned
from the read handlers are RC =2, which was not the case for the
`parse_url`-based parser when repeatedly retrieving a component even without
normalization happening. Remove that assertion, since its usefulness is
questionable. Any obvious data type issues with read handlers should be
detectable when testing during development.
* uri/standard: Move the `parse_url()` URI parser into ext/uri/
Making ext/standard depend on ext/uri/ is a bit iffy (given that it is called
*standard*) and having the parser implementation in ext/uri/ makes it easier to
find and keep in sync.
* uri: Mark local pointers as `const` in uri_parser_php_parse_url.c
* uri: Remove useless explicit cast from void in uri_parser_php_parse_url.c
* uri: Properly prefix symbols in uri_parser_php_parse_url.[ch]
* uri: Remove useless `throw_invalid_uri_exception()` helper in uri_parser_php_parse_url.c