Skip to content
This repository was archived by the owner on Sep 22, 2025. It is now read-only.

Commit 316ce76

Browse files
committed
Implementing the WhatWgUrl
1 parent 909aa60 commit 316ce76

File tree

9 files changed

+610
-6
lines changed

9 files changed

+610
-6
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
jobs:
88
linux_tests:
99
name: PHP on ${{ matrix.php }} - ${{ matrix.stability }} - ${{ matrix.composer-flags }}
10-
runs-on: ubuntu-20.04
10+
runs-on: ubuntu-22.04
1111
strategy:
1212
matrix:
1313
php: ['8.1', '8.2', '8.3', '8.4']

README.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
1-
# A polyfill for ongoing PHP RFC 3986 URI parsing support
1+
# A polyfill for ongoing PHP RFCFC 3986 and WHATWG compliant URI parsing support
22

3-
This is a PHP polyfill for RFC 3986 compliant URI parsing support based on the
4-
ongoing [RFC](https://wiki.php.net/rfc/url_parsing_api)
3+
This is a PHP polyfill for the ongoing [RFC](https://wiki.php.net/rfc/url_parsing_api) to add support for
54

6-
The polyfill uses [League URI Interface Package](https://github.com/thephpleague/uri-interfaces)
5+
- an RFC 3986 compliant URI parsing
6+
- an WHATWG compliant URI parsing
7+
8+
The polyfills use:
9+
10+
- [League URI Interface Package](https://github.com/thephpleague/uri-interfaces)
11+
- [URL-Parser](https://github.com/TRowbotham/URL-Parser)
712

813
Please view the RFC document to understand the URI instance public API.
14+
15+
> [!WARNING]
16+
> **The implementations are made to be correct not to be fast**

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
},
2323
"require": {
2424
"php": "^8.1",
25-
"league/uri-interfaces": "dev-master"
25+
"league/uri-interfaces": "dev-master",
26+
"rowbot/url": "^4.0"
2627
},
2728
"require-dev": {
2829
"friendsofphp/php-cs-fixer": "^3.68.5",

phpstan.neon

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ includes:
66
parameters:
77
ignoreErrors:
88
- '#Comparison operation "<" between int<80100, 80499> and 80500 is always true.#'
9+
- '#Dead catch - Exception is never thrown in the try block.#'
910
level: max
1011
paths:
1112
- src

src/WhatWg/InvalidUrlException.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
/**
4+
* Aide.Uri (https://https://github.com/bakame-php/aide-uri)
5+
*
6+
* (c) Ignace Nyamagana Butera <nyamsprod@gmail.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
declare(strict_types=1);
13+
14+
namespace Uri\WhatWg;
15+
16+
use Exception;
17+
use Uri\InvalidUriException;
18+
19+
use const PHP_VERSION_ID;
20+
21+
if (PHP_VERSION_ID < 80500) {
22+
class InvalidUrlException extends InvalidUriException
23+
{
24+
/**
25+
* @param array<int, UrlValidationError> $errors
26+
*/
27+
public function __construct(
28+
string $message,
29+
public readonly array $errors = [],
30+
int $code = 0,
31+
?Exception $previous = null
32+
) {
33+
parent::__construct($message, $code, $previous);
34+
}
35+
}
36+
}

0 commit comments

Comments
 (0)