From 0d5742e8a9c9bbcab41d119038c1e8ff3d0752bc Mon Sep 17 00:00:00 2001
From: ignace nyamagana butera
Date: Mon, 21 Aug 2023 22:15:03 +0200
Subject: [PATCH] Prepare 7.1 release
---
components/CHANGELOG.md | 2 +-
components/composer.json | 2 +-
docs/components/7.0/modifiers.md | 40 +++++++++++++++++++++
docs/interfaces/7.0/query-parser-builder.md | 40 ++++++++++++++++++++-
interfaces/CHANGELOG.md | 4 +--
uri/CHANGELOG.md | 2 +-
uri/composer.json | 2 +-
7 files changed, 85 insertions(+), 7 deletions(-)
diff --git a/components/CHANGELOG.md b/components/CHANGELOG.md
index 15fda3b1..447da884 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.1.0 - 2023-08-21
### Added
diff --git a/components/composer.json b/components/composer.json
index 2cf5ac0a..cbb39d03 100644
--- a/components/composer.json
+++ b/components/composer.json
@@ -29,7 +29,7 @@
],
"require": {
"php": "^8.1",
- "league/uri": "^7.0"
+ "league/uri": "^7.1"
},
"suggest": {
"ext-bcmath": "to improve IPV4 host parsing",
diff --git a/docs/components/7.0/modifiers.md b/docs/components/7.0/modifiers.md
index 6898622e..f5b1858a 100644
--- a/docs/components/7.0/modifiers.md
+++ b/docs/components/7.0/modifiers.md
@@ -92,6 +92,46 @@ The following modifiers update and normalize the URI query component.
resulting query string may update the component character encoding. These changes are expected because of
the rules governing parsing and building query string.
+### Modifier::encodeQuery
+
+since version 7.1.0
+
+Change the encoding of the query string. You can either specify one of PHP's constant between `PHP_QUERY_RFC1738` and
+`PHP_QUERY_RFC3986`
+
+~~~php
+use League\Uri\Modifier;
+
+echo Modifier::from("https://example.com/?kingkong=toto&foo=bar%20baz&kingkong=ape")
+ ->encodeQuery(PHP_QUERY_RFC1738)
+ ->getUri()
+ ->getQuery();
+//display "kingkong=toto&kingkong=ape&foo=bar+baz"
+~~~
+
+or for more specific conversions you can provide a `League\Uri\KeyValuePair\Converter` class.
+
+~~~php
+use League\Uri\KeyValuePair\Converter as KeyValuePairConverter;
+use League\Uri\Modifier;
+use Nyholm\Psr7\Uri;
+
+$converter = KeyValuePairConverter::new(';')
+ ->withEncodingMap([
+ '%3F' => '?',
+ '%2F' => '/',
+ '%40' => '@',
+ '%3A' => ':',
+ ]);
+
+Modifier::from(new Uri('https://example.com?foo[2]=bar#fragment'))
+ ->appendQuery('url=https://example.com?foo[2]=bar#fragment')
+ ->encodeQuery($converter)
+ ->getUri()
+ ->getQuery();
+//display "foo%5B2%5D=bar;url=https://example.com?foo%5B2%5D%3Dbar%23fragment"
+~~~
+
### Modifier::sortQuery
Sorts the query according to its key values. The sorting rules are the same uses by WHATWG `URLSearchParams::sort` method.
diff --git a/docs/interfaces/7.0/query-parser-builder.md b/docs/interfaces/7.0/query-parser-builder.md
index d565c9d2..141dc345 100644
--- a/docs/interfaces/7.0/query-parser-builder.md
+++ b/docs/interfaces/7.0/query-parser-builder.md
@@ -7,7 +7,9 @@ Query Parser and Builder
=======
The `League\Uri\QueryString` is a PHP URI query parser and builder.
-The parsing/building algorithms preserve pairs order and uses the same algorithm used by JavaScript UrlSearchParams
+
+The parsing/building algorithms preserve pairs order and uses the same algorithm used by
+JavaScript UrlSearchParams
```php
7.1 you can have an improved control over the characters conversion
+by using the `League\Uri\KeyValuePair\Converter` class. The class is responsible for parsing the string into key/value
+pair and for converting key/value pairs into string adding an extra string replacement before parsing and
+after building the string.
+
+```php
+use League\Uri\KeyValuePair\Converter as KeyValuePairConverter;
+use League\Uri\QueryString;
+
+$converter = KeyValuePairConverter::new(';')
+ ->withEncodingMap([
+ '%3F' => '?',
+ '%2F' => '/',
+ '%40' => '@',
+ '%3A' => ':',
+ '%5B' => '[',
+ '%5D' => ']',
+ '%3D' => '=',
+ '%23' => '#',
+ ]);
+
+$keyValuePairs = QueryString::parseFromValue('foo=bar&url=https://example.com?foo[2]=bar#fragment');
+
+echo QueryString::buildFromPairs($keyValuePairs, $converter));
+// displays foo=bar;url=https://example.com?foo[2]=bar#fragment
+```
+
+You can use the class on the following methods as the second argument:
+
+- `buildFromPairs` improved version of `build`
+- `extractFromValue` improved version of `extract`
+- `parseFromValue` improved version of `parse`
+
## Exceptions
All exceptions extend the `League\Uri\Exceptions\UriException` marker class which extends PHP's `Throwable` class.
diff --git a/interfaces/CHANGELOG.md b/interfaces/CHANGELOG.md
index 6079af75..e3c6dcc7 100644
--- a/interfaces/CHANGELOG.md
+++ b/interfaces/CHANGELOG.md
@@ -2,7 +2,7 @@
All Notable changes to `League\Uri\Interfaces` will be documented in this file
-## Next - TBD
+## 7.1.0 - 2023-08-21
### Added
@@ -11,7 +11,7 @@ All Notable changes to `League\Uri\Interfaces` will be documented in this file
### Fixed
-- Rewrite `QueryString` classes and fix query encoding for basic RFC3986.
+- Rewrite `QueryString` classes and fix query encoding for basic RFC3986. [#109](https://github.com/thephpleague/uri-src/issues/109)
### Deprecated
diff --git a/uri/CHANGELOG.md b/uri/CHANGELOG.md
index 06666351..ac7cc384 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.1.0 - 2023-08-21
### Added
diff --git a/uri/composer.json b/uri/composer.json
index b03df7d5..66b1b5f0 100644
--- a/uri/composer.json
+++ b/uri/composer.json
@@ -45,7 +45,7 @@
],
"require": {
"php": "^8.1",
- "league/uri-interfaces": "^7.0"
+ "league/uri-interfaces": "^7.1"
},
"autoload": {
"psr-4": {