Skip to content

Commit

Permalink
prepare 1.2.0 release
Browse files Browse the repository at this point in the history
  • Loading branch information
nyamsprod committed Nov 6, 2017
1 parent e1f08e9 commit 85f6d39
Show file tree
Hide file tree
Showing 21 changed files with 178 additions and 26 deletions.
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,24 @@

All Notable changes to `League\Uri\Components` will be documented in this file

## 1.2.0 - 2017-11-06

### Added

- `League\Uri\build_query` as an alias of `Query::build`

### Fixed

- function docblocks

### Deprecated

- None

### Remove

- None

## 1.1.1 - 2017-11-03

### Added
Expand Down
2 changes: 1 addition & 1 deletion src/Components/AbstractComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @subpackage League\Uri\Components
* @author Ignace Nyamagana Butera <[email protected]>
* @license https://github.com/thephpleague/uri-components/blob/master/LICENSE (MIT License)
* @version 1.1.1
* @version 1.2.0
* @link https://github.com/thephpleague/uri-components
*
Expand Down
2 changes: 1 addition & 1 deletion src/Components/AbstractHierarchicalComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @subpackage League\Uri\Components
* @author Ignace Nyamagana Butera <[email protected]>
* @license https://github.com/thephpleague/uri-components/blob/master/LICENSE (MIT License)
* @version 1.1.1
* @version 1.2.0
* @link https://github.com/thephpleague/uri-components
*
Expand Down
2 changes: 1 addition & 1 deletion src/Components/ComponentInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @subpackage League\Uri\Components
* @author Ignace Nyamagana Butera <[email protected]>
* @license https://github.com/thephpleague/uri-interfaces/blob/master/LICENSE (MIT License)
* @version 1.1.1
* @version 1.2.0
* @link https://github.com/thephpleague/uri-interfaces/
*
Expand Down
2 changes: 1 addition & 1 deletion src/Components/ComponentTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @subpackage League\Uri\Components
* @author Ignace Nyamagana Butera <[email protected]>
* @license https://github.com/thephpleague/uri-components/blob/master/LICENSE (MIT License)
* @version 1.1.1
* @version 1.2.0
* @link https://github.com/thephpleague/uri-components
*
Expand Down
2 changes: 1 addition & 1 deletion src/Components/DataPath.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @subpackage League\Uri\Components
* @author Ignace Nyamagana Butera <[email protected]>
* @license https://github.com/thephpleague/uri-components/blob/master/LICENSE (MIT License)
* @version 1.1.1
* @version 1.2.0
* @link https://github.com/thephpleague/uri-components
*
Expand Down
2 changes: 1 addition & 1 deletion src/Components/EncodingInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @subpackage League\Uri\Components
* @author Ignace Nyamagana Butera <[email protected]>
* @license https://github.com/thephpleague/uri-interfaces/blob/master/LICENSE (MIT License)
* @version 1.1.1
* @version 1.2.0
* @link https://github.com/thephpleague/uri-interfaces/
*
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @subpackage League\Uri\Components
* @author Ignace Nyamagana Butera <[email protected]>
* @license https://github.com/thephpleague/uri-components/blob/master/LICENSE (MIT License)
* @version 1.1.1
* @version 1.2.0
* @link https://github.com/thephpleague/uri-components
*
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Fragment.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @subpackage League\Uri\Components
* @author Ignace Nyamagana Butera <[email protected]>
* @license https://github.com/thephpleague/uri-components/blob/master/LICENSE (MIT License)
* @version 1.1.1
* @version 1.2.0
* @link https://github.com/thephpleague/uri-components
*
Expand Down
2 changes: 1 addition & 1 deletion src/Components/HierarchicalPath.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @subpackage League\Uri\Components
* @author Ignace Nyamagana Butera <[email protected]>
* @license https://github.com/thephpleague/uri-components/blob/master/LICENSE (MIT License)
* @version 1.1.1
* @version 1.2.0
* @link https://github.com/thephpleague/uri-components
*
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Host.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @subpackage League\Uri\Components
* @author Ignace Nyamagana Butera <[email protected]>
* @license https://github.com/thephpleague/uri-components/blob/master/LICENSE (MIT License)
* @version 1.1.1
* @version 1.2.0
* @link https://github.com/thephpleague/uri-components
*
Expand Down
2 changes: 1 addition & 1 deletion src/Components/HostInfoTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @subpackage League\Uri\Components
* @author Ignace Nyamagana Butera <[email protected]>
* @license https://github.com/thephpleague/uri-components/blob/master/LICENSE (MIT License)
* @version 1.1.1
* @version 1.2.0
* @link https://github.com/thephpleague/uri-components
*
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Path.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @subpackage League\Uri\Components
* @author Ignace Nyamagana Butera <[email protected]>
* @license https://github.com/thephpleague/uri-components/blob/master/LICENSE (MIT License)
* @version 1.1.1
* @version 1.2.0
* @link https://github.com/thephpleague/uri-components
*
Expand Down
2 changes: 1 addition & 1 deletion src/Components/PathInfoTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @subpackage League\Uri\Components
* @author Ignace Nyamagana Butera <[email protected]>
* @license https://github.com/thephpleague/uri-components/blob/master/LICENSE (MIT License)
* @version 1.1.1
* @version 1.2.0
* @link https://github.com/thephpleague/uri-components
*
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Port.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @subpackage League\Uri\Components
* @author Ignace Nyamagana Butera <[email protected]>
* @license https://github.com/thephpleague/uri-components/blob/master/LICENSE (MIT License)
* @version 1.1.1
* @version 1.2.0
* @link https://github.com/thephpleague/uri-components
*
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @subpackage League\Uri\Components
* @author Ignace Nyamagana Butera <[email protected]>
* @license https://github.com/thephpleague/uri-components/blob/master/LICENSE (MIT License)
* @version 1.1.1
* @version 1.2.0
* @link https://github.com/thephpleague/uri-components
*
Expand Down
2 changes: 1 addition & 1 deletion src/Components/QueryParserTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @subpackage League\Uri\Components
* @author Ignace Nyamagana Butera <[email protected]>
* @license https://github.com/thephpleague/uri-components/blob/master/LICENSE (MIT License)
* @version 1.1.1
* @version 1.2.0
* @link https://github.com/thephpleague/uri-components
*
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Scheme.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @subpackage League\Uri\Components
* @author Ignace Nyamagana Butera <[email protected]>
* @license https://github.com/thephpleague/uri-components/blob/master/LICENSE (MIT License)
* @version 1.1.1
* @version 1.2.0
* @link https://github.com/thephpleague/uri-components
*
Expand Down
2 changes: 1 addition & 1 deletion src/Components/UserInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @subpackage League\Uri\Components
* @author Ignace Nyamagana Butera <[email protected]>
* @license https://github.com/thephpleague/uri-components/blob/master/LICENSE (MIT License)
* @version 1.1.1
* @version 1.2.0
* @link https://github.com/thephpleague/uri-components
*
Expand Down
32 changes: 24 additions & 8 deletions src/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,29 @@
use League\Uri\Components\Query;

/**
* Parse the query string like parse_str without mangling the results
* Build a query string from an associative array
*
* @see Query::extract
* @see Query::build
*
* @param array $pairs The query pairs
* @param string $separator The query string separator
* @param int $enc_type The query encoding type
*
* @return string
*/
function build_query(array $pairs, string $separator = '&', int $enc_type = PHP_QUERY_RFC3986): string
{
return Query::build($pairs, $separator, $enc_type);
}

/**
* Parse a query string into an associative array
*
* @see Query::parse
*
* @param string $query
* @param string $separator
* @param int $enc_type
* @param string $query The query string to parse
* @param string $separator The query string separator
* @param int $enc_type The query encoding algorithm
*
* @return array
*/
Expand All @@ -36,9 +52,9 @@ function parse_query(string $query, string $separator = '&', int $enc_type = PHP
*
* @see Query::extract
*
* @param string $query
* @param string $separator
* @param int $enc_type
* @param string $query The query string to parse
* @param string $separator The query string separator
* @param int $enc_type The query encoding algorithm
*
* @return array
*/
Expand Down
118 changes: 118 additions & 0 deletions tests/FunctionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,4 +202,122 @@ public function parserProvider()
],
];
}

/**
* @dataProvider buildProvider
* @param array $pairs
* @param string $expected_rfc1738
* @param string $expected_rfc3986
* @param string $expected_rfc3987
* @param string $expected_no_encoding
*/
public function testBuild(
$pairs,
$expected_rfc1738,
$expected_rfc3986,
$expected_rfc3987,
$expected_no_encoding
) {
$this->assertSame($expected_rfc1738, Uri\build_query($pairs, '&', PHP_QUERY_RFC1738));
$this->assertSame($expected_rfc3986, Uri\build_query($pairs, '&', PHP_QUERY_RFC3986));
$this->assertSame($expected_rfc3987, Uri\build_query($pairs, '&', Query::RFC3987_ENCODING));
$this->assertSame($expected_no_encoding, Uri\build_query($pairs, '&', Query::NO_ENCODING));
}

public function buildProvider()
{
return [
'empty string' => [
'pairs' => [],
'expected_rfc1738' => '',
'expected_rfc3986' => '',
'expected_rfc3987' => '',
'expected_no_encoding' => '',
],
'identical keys' => [
'pairs' => ['a' => ['1', '2']],
'expected_rfc1738' => 'a=1&a=2',
'expected_rfc3986' => 'a=1&a=2',
'expected_rfc3987' => 'a=1&a=2',
'expected_no_encoding' => 'a=1&a=2',
],
'no value' => [
'pairs' => ['a' => null, 'b' => null],
'expected_rfc1738' => 'a&b',
'expected_rfc3986' => 'a&b',
'expected_rfc3987' => 'a&b',
'expected_no_encoding' => 'a&b',
],
'empty value' => [
'pairs' => ['a' => '', 'b' => ''],
'expected_rfc1738' => 'a=&b=',
'expected_rfc3986' => 'a=&b=',
'expected_rfc3987' => 'a=&b=',
'expected_no_encoding' => 'a=&b=',
],
'php array' => [
'pairs' => ['a[]' => ['1', '2']],
'expected_rfc1738' => 'a%5B%5D=1&a%5B%5D=2',
'expected_rfc3986' => 'a%5B%5D=1&a%5B%5D=2',
'expected_rfc3987' => 'a[]=1&a[]=2',
'expected_no_encoding' => 'a[]=1&a[]=2',
],
'preserve dot' => [
'pairs' => ['a.b' => '3'],
'expected_rfc1738' => 'a.b=3',
'expected_rfc3986' => 'a.b=3',
'expected_rfc3987' => 'a.b=3',
'expected_no_encoding' => 'a.b=3',
],
'no key stripping' => [
'pairs' => ['a' => '', 'b' => null],
'expected_rfc1738' => 'a=&b',
'expected_rfc3986' => 'a=&b',
'expected_rfc3987' => 'a=&b',
'expected_no_encoding' => 'a=&b',
],
'no value stripping' => [
'pairs' => ['a' => 'b='],
'expected_rfc1738' => 'a=b=',
'expected_rfc3986' => 'a=b=',
'expected_rfc3987' => 'a=b=',
'expected_no_encoding' => 'a=b=',
],
'key only' => [
'pairs' => ['a' => null],
'expected_rfc1738' => 'a',
'expected_rfc3986' => 'a',
'expected_rfc3987' => 'a',
'expected_no_encoding' => 'a',
],
'preserve falsey 1' => [
'pairs' => ['0' => null],
'expected_rfc1738' => '0',
'expected_rfc3986' => '0',
'expected_rfc3987' => '0',
'expected_no_encoding' => '0',
],
'preserve falsey 2' => [
'pairs' => ['0' => ''],
'expected_rfc1738' => '0=',
'expected_rfc3986' => '0=',
'expected_rfc3987' => '0=',
'expected_no_encoding' => '0=',
],
'preserve falsey 3' => [
'pairs' => ['0' => '0'],
'expected_rfc1738' => '0=0',
'expected_rfc3986' => '0=0',
'expected_rfc3987' => '0=0',
'expected_no_encoding' => '0=0',
],
'rcf1738' => [
'pairs' => ['toto' => 'foo+bar'],
'expected_rfc1738' => 'toto=foo%2Bbar',
'expected_rfc3986' => 'toto=foo+bar',
'expected_rfc3987' => 'toto=foo+bar',
'expected_no_encoding' => 'toto=foo+bar',
],
];
}
}

0 comments on commit 85f6d39

Please sign in to comment.