From 3f8588d303fdfce04b932b713915c75049b3fe0e Mon Sep 17 00:00:00 2001 From: ignace nyamagana butera Date: Thu, 23 Nov 2023 22:11:55 +0100 Subject: [PATCH] Prepare 7.4.0 release --- components/CHANGELOG.md | 2 +- components/Components/Query.php | 1 - interfaces/CHANGELOG.md | 20 +----------------- uri/CHANGELOG.md | 2 +- uri/Uri.php | 37 +++++++++++++++++---------------- 5 files changed, 22 insertions(+), 40 deletions(-) diff --git a/components/CHANGELOG.md b/components/CHANGELOG.md index f46e524a..5b910819 100644 --- a/components/CHANGELOG.md +++ b/components/CHANGELOG.md @@ -2,7 +2,7 @@ All Notable changes to `League\Uri\Components` will be documented in this file -## Next - TBD +## [7.4.0](https://github.com/thephpleague/uri-components/compare/7.3.0...7.4.0) - 2023-11-23 ### Added diff --git a/components/Components/Query.php b/components/Components/Query.php index a6d254e4..a01d7115 100644 --- a/components/Components/Query.php +++ b/components/Components/Query.php @@ -22,7 +22,6 @@ use League\Uri\QueryString; use Psr\Http\Message\UriInterface as Psr7UriInterface; use Stringable; - use Traversable; use function array_column; diff --git a/interfaces/CHANGELOG.md b/interfaces/CHANGELOG.md index ca989faf..53e7b75c 100644 --- a/interfaces/CHANGELOG.md +++ b/interfaces/CHANGELOG.md @@ -2,25 +2,7 @@ All Notable changes to `League\Uri\Interfaces` will be documented in this file -## Next - TBD - -### Added - -- None - -### Fixed - -- None - -### Deprecated - -- None - -### Removed - -- None - -## [7.3.0](https://github.com/thephpleague/uri-interfaces/compare/7.2.0...7.3.0) - 2023-09-09 +## [Next](https://github.com/thephpleague/uri-interfaces/compare/7.2.0...7.3.0) - 2023-09-09 ### Added diff --git a/uri/CHANGELOG.md b/uri/CHANGELOG.md index 0defd223..4aab23e3 100644 --- a/uri/CHANGELOG.md +++ b/uri/CHANGELOG.md @@ -2,7 +2,7 @@ All Notable changes to `League\Uri` will be documented in this file -## Next - TBD +## [7.4.0](https://github.com/thephpleague/uri/compare/7.3.0...7.4.0) - 2023-09-09 ### Added diff --git a/uri/Uri.php b/uri/Uri.php index 69fe0dce..bf06459c 100644 --- a/uri/Uri.php +++ b/uri/Uri.php @@ -521,29 +521,30 @@ public static function fromData(string $data, string $mimetype = '', string $par default => throw new SyntaxError('Invalid mimeType, `'.$mimetype.'`.'), }; - if ('' != $parameters) { - if (str_starts_with($parameters, ';')) { - $parameters = substr($parameters, 1); - } - - $validateParameter = function (string $parameter): bool { - $properties = explode('=', $parameter); + if ('' === $parameters) { + return self::fromComponents([ + 'scheme' => 'data', + 'path' => self::formatDataPath($mimetype.','.rawurlencode($data)), + ]); + } - return 2 != count($properties) || 'base64' === strtolower($properties[0]); - }; + $isInvalidParameter = static function (string $parameter): bool { + $properties = explode('=', $parameter); - $params = array_filter(explode(';', $parameters)); - if ([] !== array_filter($params, $validateParameter(...))) { - throw new SyntaxError(sprintf('Invalid mediatype parameters, `%s`.', $parameters)); - } + return 2 !== count($properties) || 'base64' === strtolower($properties[0]); + }; - $parameters = ';'.$parameters; + if (str_starts_with($parameters, ';')) { + $parameters = substr($parameters, 1); } - return self::fromComponents([ - 'scheme' => 'data', - 'path' => self::formatDataPath($mimetype.$parameters.','.rawurlencode($data)), - ]); + return match ([]) { + array_filter(explode(';', $parameters), $isInvalidParameter) => self::fromComponents([ + 'scheme' => 'data', + 'path' => self::formatDataPath($mimetype.';'.$parameters.','.rawurlencode($data)), + ]), + default => throw new SyntaxError(sprintf('Invalid mediatype parameters, `%s`.', $parameters)) + }; } /**