Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions ext/lexbor/lexbor/url/url.c
Original file line number Diff line number Diff line change
Expand Up @@ -860,12 +860,6 @@ lxb_url_is_url_codepoint(lxb_codepoint_t cp)
return lxb_url_codepoint_alphanumeric[(lxb_char_t) cp] != 0xFF;
}

lxb_inline bool
lxb_url_is_special(const lxb_url_t *url)
{
return url->scheme.type != LXB_URL_SCHEMEL_TYPE__UNKNOWN;
}

lxb_inline const lxb_url_scheme_data_t *
lxb_url_scheme_by_type(lxb_url_scheme_type_t type)
{
Expand Down
5 changes: 5 additions & 0 deletions ext/lexbor/lexbor/url/url.h
Original file line number Diff line number Diff line change
Expand Up @@ -845,6 +845,11 @@ lxb_url_get(lxb_url_parser_t *parser)
return parser->url;
}

lxb_inline bool
lxb_url_is_special(const lxb_url_t *url)
{
return url->scheme.type != LXB_URL_SCHEMEL_TYPE__UNKNOWN;
}

#ifdef __cplusplus
} /* extern "C" */
Expand Down
47 changes: 47 additions & 0 deletions ext/uri/php_uri.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,14 @@
#include "uriparser/Uri.h"

zend_class_entry *php_uri_ce_rfc3986_uri;
zend_class_entry *php_uri_ce_rfc3986_uri_type;
zend_class_entry *php_uri_ce_rfc3986_uri_host_type;
zend_class_entry *php_uri_ce_whatwg_url;
zend_class_entry *php_uri_ce_comparison_mode;
zend_class_entry *php_uri_ce_exception;
zend_class_entry *php_uri_ce_error;
zend_class_entry *php_uri_ce_invalid_uri_exception;
zend_class_entry *php_uri_ce_whatwg_url_host_type;
zend_class_entry *php_uri_ce_whatwg_invalid_url_exception;
zend_class_entry *php_uri_ce_whatwg_url_validation_error_type;
zend_class_entry *php_uri_ce_whatwg_url_validation_error;
Expand Down Expand Up @@ -508,6 +511,16 @@ PHP_METHOD(Uri_WhatWg_Url, __construct)
create_whatwg_uri(INTERNAL_FUNCTION_PARAM_PASSTHRU, true);
}

PHP_METHOD(Uri_Rfc3986_Uri, getUriType)
{
ZEND_PARSE_PARAMETERS_NONE();

php_uri_object *uri_object = Z_URI_OBJECT_P(ZEND_THIS);
ZEND_ASSERT(uri_object->uri != NULL);

php_uri_parser_rfc3986_uri_type_read(uri_object->uri, return_value);
}

PHP_METHOD(Uri_Rfc3986_Uri, getScheme)
{
php_uri_property_read_helper(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_URI_PROPERTY_NAME_SCHEME, PHP_URI_COMPONENT_READ_MODE_NORMALIZED_ASCII);
Expand Down Expand Up @@ -611,6 +624,16 @@ PHP_METHOD(Uri_Rfc3986_Uri, getRawHost)
php_uri_property_read_helper(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_URI_PROPERTY_NAME_HOST, PHP_URI_COMPONENT_READ_MODE_RAW);
}

PHP_METHOD(Uri_Rfc3986_Uri, getHostType)
{
ZEND_PARSE_PARAMETERS_NONE();

php_uri_object *uri_object = Z_URI_OBJECT_P(ZEND_THIS);
ZEND_ASSERT(uri_object->uri != NULL);

php_uri_parser_rfc3986_host_type_read(uri_object->uri, return_value);
}

PHP_METHOD(Uri_Rfc3986_Uri, withHost)
{
php_uri_property_write_str_or_null_helper(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_URI_PROPERTY_NAME_HOST);
Expand Down Expand Up @@ -883,6 +906,16 @@ PHP_METHOD(Uri_WhatWg_Url, withScheme)
php_uri_property_write_str_helper(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_URI_PROPERTY_NAME_SCHEME);
}

PHP_METHOD(Uri_WhatWg_Url, isSpecialScheme)
{
ZEND_PARSE_PARAMETERS_NONE();

php_uri_object *uri_object = Z_URI_OBJECT_P(ZEND_THIS);
ZEND_ASSERT(uri_object->uri != NULL);

RETVAL_BOOL(php_uri_parser_whatwg_is_special(uri_object->uri));
}

PHP_METHOD(Uri_WhatWg_Url, withUsername)
{
php_uri_property_write_str_or_null_helper(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_URI_PROPERTY_NAME_USERNAME);
Expand All @@ -903,6 +936,16 @@ PHP_METHOD(Uri_WhatWg_Url, getUnicodeHost)
php_uri_property_read_helper(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_URI_PROPERTY_NAME_HOST, PHP_URI_COMPONENT_READ_MODE_NORMALIZED_UNICODE);
}

PHP_METHOD(Uri_WhatWg_Url, getHostType)
{
ZEND_PARSE_PARAMETERS_NONE();

php_uri_object *uri_object = Z_URI_OBJECT_P(ZEND_THIS);
ZEND_ASSERT(uri_object->uri != NULL);

php_uri_parser_whatwg_host_type_read(uri_object->uri, return_value);
}

PHP_METHOD(Uri_WhatWg_Url, getFragment)
{
php_uri_property_read_helper(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_URI_PROPERTY_NAME_FRAGMENT, PHP_URI_COMPONENT_READ_MODE_NORMALIZED_UNICODE);
Expand Down Expand Up @@ -1078,6 +1121,9 @@ static PHP_MINIT_FUNCTION(uri)
object_handlers_rfc3986_uri.free_obj = php_uri_object_handler_free;
object_handlers_rfc3986_uri.clone_obj = php_uri_object_handler_clone;

php_uri_ce_rfc3986_uri_type = register_class_Uri_Rfc3986_UriType();
php_uri_ce_rfc3986_uri_host_type = register_class_Uri_Rfc3986_UriHostType();

php_uri_ce_whatwg_url = register_class_Uri_WhatWg_Url();
php_uri_ce_whatwg_url->create_object = php_uri_object_create_whatwg;
php_uri_ce_whatwg_url->default_object_handlers = &object_handlers_whatwg_uri;
Expand All @@ -1091,6 +1137,7 @@ static PHP_MINIT_FUNCTION(uri)
php_uri_ce_error = register_class_Uri_UriError(zend_ce_error);
php_uri_ce_invalid_uri_exception = register_class_Uri_InvalidUriException(php_uri_ce_exception);
php_uri_ce_whatwg_invalid_url_exception = register_class_Uri_WhatWg_InvalidUrlException(php_uri_ce_invalid_uri_exception);
php_uri_ce_whatwg_url_host_type = register_class_Uri_WhatWg_UrlHostType();
php_uri_ce_whatwg_url_validation_error = register_class_Uri_WhatWg_UrlValidationError();
php_uri_ce_whatwg_url_validation_error_type = register_class_Uri_WhatWg_UrlValidationErrorType();

Expand Down
33 changes: 33 additions & 0 deletions ext/uri/php_uri.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,31 @@ enum UriComparisonMode
}

namespace Uri\Rfc3986 {
enum UriType
{
case AbsolutePathReference;
case RelativePathReference;
case NetworkPathReference;
case Uri;
}

enum UriHostType
{
case IPv4;
case IPv6;
case IPvFuture;
case RegisteredName;
}

/** @strict-properties */
final readonly class Uri
{
public static function parse(string $uri, ?\Uri\Rfc3986\Uri $baseUrl = null): ?static {}

public function __construct(string $uri, ?\Uri\Rfc3986\Uri $baseUrl = null) {}

public function getUriType(): ?\Uri\Rfc3986\UriType {}

public function getScheme(): ?string {}

public function getRawScheme(): ?string {}
Expand All @@ -60,6 +78,8 @@ public function getHost(): ?string {}

public function getRawHost(): ?string {}

public function getHostType(): ?\Uri\Rfc3986\UriHostType {}

public function withHost(?string $host): static {}

public function getPort(): ?int {}
Expand Down Expand Up @@ -152,6 +172,15 @@ enum UrlValidationErrorType
public function __construct(string $context, \Uri\WhatWg\UrlValidationErrorType $type, bool $failure) {}
}

enum UrlHostType
{
case IPv4;
case IPv6;
case Domain;
case Opaque;
case Empty;
}

/** @strict-properties */
final readonly class Url
{
Expand All @@ -165,6 +194,8 @@ public function getScheme(): string {}

public function withScheme(string $scheme): static {}

public function isSpecialScheme(): bool {}

/** @implementation-alias Uri\Rfc3986\Uri::getUsername */
public function getUsername(): ?string {}

Expand All @@ -179,6 +210,8 @@ public function getAsciiHost(): ?string {}

public function getUnicodeHost(): ?string {}

public function getHostType(): ?\Uri\WhatWg\UrlHostType {}

/** @implementation-alias Uri\Rfc3986\Uri::withHost */
public function withHost(?string $host): static {}

Expand Down
69 changes: 68 additions & 1 deletion ext/uri/php_uri_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions ext/uri/php_uri_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
#include "php_uri_decl.h"

extern zend_class_entry *php_uri_ce_rfc3986_uri;
extern zend_class_entry *php_uri_ce_rfc3986_uri_type;
extern zend_class_entry *php_uri_ce_rfc3986_uri_host_type;
extern zend_class_entry *php_uri_ce_whatwg_url;
extern zend_class_entry *php_uri_ce_comparison_mode;
extern zend_class_entry *php_uri_ce_exception;
Expand All @@ -26,6 +28,7 @@ extern zend_class_entry *php_uri_ce_invalid_uri_exception;
extern zend_class_entry *php_uri_ce_whatwg_invalid_url_exception;
extern zend_class_entry *php_uri_ce_whatwg_url_validation_error_type;
extern zend_class_entry *php_uri_ce_whatwg_url_validation_error;
extern zend_class_entry *php_uri_ce_whatwg_url_host_type;

typedef enum php_uri_recomposition_mode {
PHP_URI_RECOMPOSITION_MODE_RAW_ASCII,
Expand Down
Loading
Loading