-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deprecating getComponents and adding BaseUri::isOpaque
- Loading branch information
Showing
11 changed files
with
116 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -104,6 +104,18 @@ BaseUri::from("//example.com/toto")->isNetworkPath(); //returns true | |
BaseUri::from("/🍣🍺")->isNetworkPath(); //returns false | ||
~~~ | ||
|
||
### BaseUri::isOpaque | ||
|
||
<p class="message-notice">added in version <code>7.5.0</code></p> | ||
|
||
Tells whether the given URI object represents an opaque URI. An URI is said to be | ||
opaque if and only if it is absolute but does not have an authority | ||
|
||
~~~php | ||
BaseUri::from("email:[email protected]?subject=🏳️🌈"))->isOpaque(); //returns true | ||
BaseUri::from("/🍣🍺")->isOpaque(); //returns false | ||
~~~ | ||
|
||
### BaseUri::isRelativePath | ||
|
||
Tells whether the given URI object represents a relative path. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ | |
use PHPUnit\Framework\Attributes\CoversClass; | ||
use PHPUnit\Framework\Attributes\DataProvider; | ||
use PHPUnit\Framework\Attributes\Group; | ||
use PHPUnit\Framework\Attributes\Test; | ||
use PHPUnit\Framework\TestCase; | ||
use Psr\Http\Message\UriInterface as Psr7UriInterface; | ||
|
||
|
@@ -583,4 +584,44 @@ public static function rfc8089UriProvider(): iterable | |
], | ||
]; | ||
} | ||
|
||
#[DataProvider('opaqueUriProvider')] | ||
#[Test] | ||
public function it_tells_if_an_uri_is_opaque(bool $expected, string $uri): void | ||
{ | ||
self::assertSame($expected, BaseUri::from($uri)->isOpaque()); | ||
} | ||
|
||
public static function opaqueUriProvider(): iterable | ||
{ | ||
yield 'empty URI' => [ | ||
'expected' => false, | ||
'uri' => '', | ||
]; | ||
|
||
yield 'relative URI' => [ | ||
'expected' => false, | ||
'uri' => 'path?query#fragment', | ||
]; | ||
|
||
yield 'URI with authority' => [ | ||
'expected' => false, | ||
'uri' => '//authority/path?query#fragment', | ||
]; | ||
|
||
yield 'absolute HTTP URI' => [ | ||
'expected' => false, | ||
'uri' => 'https://authority/path?query#fragment', | ||
]; | ||
|
||
yield 'absolute mail URI' => [ | ||
'expected' => true, | ||
'uri' => 'mail:[email protected]', | ||
]; | ||
|
||
yield 'data URI' => [ | ||
'expected' => true, | ||
'uri' => 'data:', | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters