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
4 changes: 2 additions & 2 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: ctype, date, filter, intl, pcre, spl
extensions: ctype, date, filter, intl, pcre, sodium, spl
tools: composer
ini-values: error_reporting=E_ALL
coverage: pcov
Expand Down Expand Up @@ -164,7 +164,7 @@ jobs:
# Should be the higest supported version, so we can use the newest tools
php-version: '8.5'
tools: composer, composer-require-checker, composer-unused
extensions: ctype, date, filter, pcre, sodium, spl
extensions: ctype, date, filter, intl, pcre, sodium, spl
coverage: none

- name: Setup problem matchers for PHP
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"ext-spl": "*",

"guzzlehttp/psr7": "~2.8",
"webmozart/assert": "~1.12"
"webmozart/assert": "~2.0"
},
"require-dev": {
"ext-intl": "*",
Expand Down
603 changes: 310 additions & 293 deletions src/Assert.php

Large diffs are not rendered by default.

7 changes: 3 additions & 4 deletions src/Base64Trait.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,8 @@ trait Base64Trait
/**
* Note: This test is not bullet-proof but prevents a string containing illegal characters
* from being passed and ensures the string roughly follows the correct format for a Base64 encoded string
*
* @param string $value
* @param string $message
*/
protected static function validBase64(string $value, string $message = ''): void
protected static function validBase64(string $value, string $message = ''): string
{
$result = true;

Expand All @@ -56,5 +53,7 @@ protected static function validBase64(string $value, string $message = ''): void
$value,
));
}

return $value;
}
}
47 changes: 0 additions & 47 deletions src/NotInArrayTrait.php

This file was deleted.

41 changes: 26 additions & 15 deletions src/URITrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ trait URITrait
* not handle any custom exception passed to it. *
***********************************************************************************/

private static Uri $uri;


/**
* @param string $value
* @param string $message
*/
protected static function validURN(string $value, string $message = ''): void
protected static function validURN(string $value, string $message = ''): string
{
try {
$uri = new Uri($value);
self::$uri = new Uri($value);
} catch (MalformedUriException $e) {
throw new InvalidArgumentException(sprintf(
$message ?: '\'%s\' is not a valid RFC3986 compliant URI',
Expand All @@ -42,54 +42,65 @@ protected static function validURN(string $value, string $message = ''): void
}

if (
$uri->getScheme() !== 'urn'
|| $uri->getPath() !== substr($value, strlen($uri->getScheme()) + 1)
self::$uri->getScheme() !== 'urn'
|| self::$uri->getPath() !== substr($value, strlen(self::$uri->getScheme()) + 1)
) {
throw new InvalidArgumentException(sprintf(
$message ?: '\'%s\' is not a valid RFC8141 compliant URN',
$value,
));
}

return $value;
}


/**
* @param string $value
* @param string $message
*/
protected static function validURL(string $value, string $message = ''): void
protected static function validURL(string $value, string $message = ''): string
{
try {
$uri = new Uri($value);
self::$uri = new Uri($value);
} catch (MalformedUriException $e) {
throw new InvalidArgumentException(sprintf(
$message ?: '\'%s\' is not a valid RFC3986 compliant URI',
$value,
));
}

if ($uri->getScheme() !== 'http' && $uri->getScheme() !== 'https') {
if (self::$uri->getScheme() !== 'http' && self::$uri->getScheme() !== 'https') {
throw new InvalidArgumentException(sprintf(
$message ?: '\'%s\' is not a valid RFC2396 compliant URL',
$value,
));
}

return $value;
}


/**
* @param string $value
* @param string $message
*/
protected static function validURI(string $value, string $message = ''): void
protected static function validURI(string $value, string $message = ''): string
{
try {
new Uri($value);
self::$uri = new Uri($value);
} catch (MalformedUriException $e) {
throw new InvalidArgumentException(sprintf(
$message ?: '\'%s\' is not a valid RFC3986 compliant URI',
$value,
));
}

return $value;
}


/**
* For convenience and efficiency, to get the Uri-object from the last assertion.
*/
public static function getUri(): Uri
{
return self::$uri;
}
}
48 changes: 0 additions & 48 deletions tests/Assert/NotInArrayTest.php

This file was deleted.

Loading