Skip to content

Commit

Permalink
bug fix empty usage #31
Browse files Browse the repository at this point in the history
PHP's empty does not make the difference between an empty string
and the string '0'. The package is updated to remove the usage of
empty and replace it with `'' === $str` or `'' !== $str` accordingly
  • Loading branch information
nyamsprod committed Jan 19, 2016
1 parent 667d64c commit cde7679
Show file tree
Hide file tree
Showing 97 changed files with 310 additions and 309 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ All Notable changes to `League\Uri` will be documented in this file
- `Formatter::preserveQuery` to improve query inclusion in URI string representation
- `Formatter::preserveFragment` to improve fragment inclusion in URI string representation
- `Formatter::__invoke` as an alias of `Formatter::format`
- `UriParser::__invoke` as an alias of `UriParser::parse`

### Fixed

- Improve Uri Component modification [issue #29](https://github.com/thephpleague/uri/issues/29)
- Improve Path encoding/decoding [issue #28](https://github.com/thephpleague/uri/issues/28)
- Improve lowercase transformation in hostname [issue #27](https://github.com/thephpleague/uri/issues/27)
- Bug when the fragment value is wrongly evaluated as empty [issue #31](https://github.com/thephpleague/uri/issues/31)
- Fix empty string evaluation [issue #31](https://github.com/thephpleague/uri/issues/31)

### Deprecated

Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ URI
[![Latest Version](https://img.shields.io/github/release/thephpleague/uri.svg?style=flat-square)](https://github.com/thephpleague/uri/releases)
[![Total Downloads](https://img.shields.io/packagist/dt/league/uri.svg?style=flat-square)](https://packagist.org/packages/league/uri)

The `League\Uri` package provides simple and intuitive classes to create and manage URIs in PHP.
The `Uri` package provides simple and intuitive classes to create and manage URIs in PHP.

Highlights
------
Expand All @@ -24,7 +24,7 @@ Highlights
Documentation
------

Full documentation can be found at [url.thephpleague.com](http://url.thephpleague.com). Contribute to this documentation in the [gh-pages](https://github.com/thephpleague/url/tree/gh-pages) branch
Full documentation can be found at [url.thephpleague.com](http://url.thephpleague.com). Contribute to this documentation in the [gh-pages](https://github.com/thephpleague/uri/tree/gh-pages) branch

System Requirements
-------
Expand All @@ -40,7 +40,7 @@ To use the library.
Install
-------

Install `League\Uri` using Composer.
Install `Uri` using Composer.

```
$ composer require league/uri
Expand All @@ -49,7 +49,7 @@ $ composer require league/uri
Testing
-------

`League\Uri` has a [PHPUnit](https://phpunit.de) test suite and a coding style compliance test suite using [PHP CS Fixer](http://cs.sensiolabs.org/). To run the tests, run the following command from the project folder.
`Uri` has a [PHPUnit](https://phpunit.de) test suite and a coding style compliance test suite using [PHP CS Fixer](http://cs.sensiolabs.org/). To run the tests, run the following command from the project folder.

``` bash
$ composer test
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "4.0-dev"
"dev-master": "4.1-dev"
}
}
}
6 changes: 3 additions & 3 deletions src/Components/AbstractComponent.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php
/**
* League.Url (http://url.thephpleague.com)
* League.Uri (http://uri.thephpleague.com)
*
* @package League.url
* @package League.uri
* @author Ignace Nyamagana Butera <nyamsprod@gmail.com>
* @copyright 2013-2015 Ignace Nyamagana Butera
* @license https://github.com/thephpleague/uri/blob/master/LICENSE (MIT License)
* @version 4.0.0
* @version 4.1.0
* @link https://github.com/thephpleague/uri/
*/
namespace League\Uri\Components;
Expand Down
6 changes: 3 additions & 3 deletions src/Components/AbstractHierarchicalComponent.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php
/**
* League.Url (http://url.thephpleague.com)
* League.Uri (http://uri.thephpleague.com)
*
* @package League.url
* @package League.uri
* @author Ignace Nyamagana Butera <nyamsprod@gmail.com>
* @copyright 2013-2015 Ignace Nyamagana Butera
* @license https://github.com/thephpleague/uri/blob/master/LICENSE (MIT License)
* @version 4.0.0
* @version 4.1.0
* @link https://github.com/thephpleague/uri/
*/
namespace League\Uri\Components;
Expand Down
6 changes: 3 additions & 3 deletions src/Components/DataPath.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?php

/**
* League.Url (http://url.thephpleague.com)
* League.Uri (http://uri.thephpleague.com)
*
* @package League.url
* @package League.uri
* @author Ignace Nyamagana Butera <nyamsprod@gmail.com>
* @copyright 2013-2015 Ignace Nyamagana Butera
* @license https://github.com/thephpleague/uri/blob/master/LICENSE (MIT License)
* @version 4.0.0
* @version 4.1.0
* @link https://github.com/thephpleague/uri/
*/
namespace League\Uri\Components;
Expand Down
6 changes: 3 additions & 3 deletions src/Components/Fragment.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php
/**
* League.Url (http://url.thephpleague.com)
* League.Uri (http://uri.thephpleague.com)
*
* @package League.url
* @package League.uri
* @author Ignace Nyamagana Butera <nyamsprod@gmail.com>
* @copyright 2013-2015 Ignace Nyamagana Butera
* @license https://github.com/thephpleague/uri/blob/master/LICENSE (MIT License)
* @version 4.0.0
* @version 4.1.0
* @link https://github.com/thephpleague/uri/
*/
namespace League\Uri\Components;
Expand Down
6 changes: 3 additions & 3 deletions src/Components/HierarchicalPath.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php
/**
* League.Url (http://url.thephpleague.com)
* League.Uri (http://uri.thephpleague.com)
*
* @package League.url
* @package League.uri
* @author Ignace Nyamagana Butera <nyamsprod@gmail.com>
* @copyright 2013-2015 Ignace Nyamagana Butera
* @license https://github.com/thephpleague/uri/blob/master/LICENSE (MIT License)
* @version 4.0.0
* @version 4.1.0
* @link https://github.com/thephpleague/uri/
*/
namespace League\Uri\Components;
Expand Down
6 changes: 3 additions & 3 deletions src/Components/Host.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php
/**
* League.Url (http://url.thephpleague.com)
* League.Uri (http://uri.thephpleague.com)
*
* @package League.url
* @package League.uri
* @author Ignace Nyamagana Butera <nyamsprod@gmail.com>
* @copyright 2013-2015 Ignace Nyamagana Butera
* @license https://github.com/thephpleague/uri/blob/master/LICENSE (MIT License)
* @version 4.0.0
* @version 4.1.0
* @link https://github.com/thephpleague/uri/
*/
namespace League\Uri\Components;
Expand Down
8 changes: 4 additions & 4 deletions src/Components/HostIpTrait.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php
/**
* League.Url (http://url.thephpleague.com)
* League.Uri (http://uri.thephpleague.com)
*
* @package League.url
* @package League.uri
* @author Ignace Nyamagana Butera <nyamsprod@gmail.com>
* @copyright 2013-2015 Ignace Nyamagana Butera
* @license https://github.com/thephpleague/uri/blob/master/LICENSE (MIT License)
* @version 4.0.0
* @version 4.1.0
* @link https://github.com/thephpleague/uri/
*/
namespace League\Uri\Components;
Expand Down Expand Up @@ -90,7 +90,7 @@ public function hasZoneIdentifier()
protected function validateIpHost($str)
{
$res = $this->filterIpv6Host($str);
if (!empty($res)) {
if (is_string($res)) {
$this->hostAsIpv4 = false;
$this->hostAsIpv6 = true;

Expand Down
6 changes: 3 additions & 3 deletions src/Components/HostnameInfoTrait.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php
/**
* League.Url (http://url.thephpleague.com)
* League.Uri (http://uri.thephpleague.com)
*
* @package League.url
* @package League.uri
* @author Ignace Nyamagana Butera <nyamsprod@gmail.com>
* @copyright 2013-2015 Ignace Nyamagana Butera
* @license https://github.com/thephpleague/uri/blob/master/LICENSE (MIT License)
* @version 4.0.0
* @version 4.1.0
* @link https://github.com/thephpleague/uri/
*/
namespace League\Uri\Components;
Expand Down
8 changes: 4 additions & 4 deletions src/Components/HostnameTrait.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php
/**
* League.Url (http://url.thephpleague.com)
* League.Uri (http://uri.thephpleague.com)
*
* @package League.url
* @package League.uri
* @author Ignace Nyamagana Butera <nyamsprod@gmail.com>
* @copyright 2013-2015 Ignace Nyamagana Butera
* @license https://github.com/thephpleague/uri/blob/master/LICENSE (MIT License)
* @version 4.0.0
* @version 4.1.0
* @link https://github.com/thephpleague/uri/
*/
namespace League\Uri\Components;
Expand Down Expand Up @@ -59,7 +59,7 @@ protected function convertToAscii(array $labels, $convert)
*/
protected function validateStringHost($str)
{
if (empty($str)) {
if ('' === $str) {
return [];
}
$host = $this->lower($this->setIsAbsolute($str));
Expand Down
6 changes: 3 additions & 3 deletions src/Components/Pass.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php
/**
* League.Url (http://url.thephpleague.com)
* League.Uri (http://uri.thephpleague.com)
*
* @package League.url
* @package League.uri
* @author Ignace Nyamagana Butera <nyamsprod@gmail.com>
* @copyright 2013-2015 Ignace Nyamagana Butera
* @license https://github.com/thephpleague/uri/blob/master/LICENSE (MIT License)
* @version 4.0.0
* @version 4.1.0
* @link https://github.com/thephpleague/uri/
*/
namespace League\Uri\Components;
Expand Down
6 changes: 3 additions & 3 deletions src/Components/Path.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php
/**
* League.Url (http://url.thephpleague.com)
* League.Uri (http://uri.thephpleague.com)
*
* @package League.url
* @package League.uri
* @author Ignace Nyamagana Butera <nyamsprod@gmail.com>
* @copyright 2013-2015 Ignace Nyamagana Butera
* @license https://github.com/thephpleague/uri/blob/master/LICENSE (MIT License)
* @version 4.0.0
* @version 4.1.0
* @link https://github.com/thephpleague/uri/
*/
namespace League\Uri\Components;
Expand Down
6 changes: 3 additions & 3 deletions src/Components/PathTrait.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php
/**
* League.Url (http://url.thephpleague.com)
* League.Uri (http://uri.thephpleague.com)
*
* @package League.url
* @package League.uri
* @author Ignace Nyamagana Butera <nyamsprod@gmail.com>
* @copyright 2013-2015 Ignace Nyamagana Butera
* @license https://github.com/thephpleague/uri/blob/master/LICENSE (MIT License)
* @version 4.0.0
* @version 4.1.0
* @link https://github.com/thephpleague/uri/
*/
namespace League\Uri\Components;
Expand Down
6 changes: 3 additions & 3 deletions src/Components/Port.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php
/**
* League.Url (http://url.thephpleague.com)
* League.Uri (http://uri.thephpleague.com)
*
* @package League.url
* @package League.uri
* @author Ignace Nyamagana Butera <nyamsprod@gmail.com>
* @copyright 2013-2015 Ignace Nyamagana Butera
* @license https://github.com/thephpleague/uri/blob/master/LICENSE (MIT License)
* @version 4.0.0
* @version 4.1.0
* @link https://github.com/thephpleague/uri/
*/
namespace League\Uri\Components;
Expand Down
6 changes: 3 additions & 3 deletions src/Components/Query.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php
/**
* League.Url (http://url.thephpleague.com)
* League.Uri (http://uri.thephpleague.com)
*
* @package League.url
* @package League.uri
* @author Ignace Nyamagana Butera <nyamsprod@gmail.com>
* @copyright 2013-2015 Ignace Nyamagana Butera
* @license https://github.com/thephpleague/uri/blob/master/LICENSE (MIT License)
* @version 4.0.0
* @version 4.1.0
* @link https://github.com/thephpleague/uri/
*/
namespace League\Uri\Components;
Expand Down
8 changes: 4 additions & 4 deletions src/Components/Scheme.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php
/**
* League.Url (http://url.thephpleague.com)
* League.Uri (http://uri.thephpleague.com)
*
* @package League.url
* @package League.uri
* @author Ignace Nyamagana Butera <nyamsprod@gmail.com>
* @copyright 2013-2015 Ignace Nyamagana Butera
* @license https://github.com/thephpleague/uri/blob/master/LICENSE (MIT License)
* @version 4.0.0
* @version 4.1.0
* @link https://github.com/thephpleague/uri/
*/
namespace League\Uri\Components;
Expand Down Expand Up @@ -46,7 +46,7 @@ protected function validate($scheme)
public function getUriComponent()
{
$component = $this->__toString();
if (!empty($component)) {
if ('' !== $component) {
$component .= SchemeInterface::DELIMITER;
}

Expand Down
6 changes: 3 additions & 3 deletions src/Components/User.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php
/**
* League.Url (http://url.thephpleague.com)
* League.Uri (http://uri.thephpleague.com)
*
* @package League.url
* @package League.uri
* @author Ignace Nyamagana Butera <nyamsprod@gmail.com>
* @copyright 2013-2015 Ignace Nyamagana Butera
* @license https://github.com/thephpleague/uri/blob/master/LICENSE (MIT License)
* @version 4.0.0
* @version 4.1.0
* @link https://github.com/thephpleague/uri/
*/
namespace League\Uri\Components;
Expand Down
8 changes: 4 additions & 4 deletions src/Components/UserInfo.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php
/**
* League.Url (http://url.thephpleague.com)
* League.Uri (http://uri.thephpleague.com)
*
* @package League.url
* @package League.uri
* @author Ignace Nyamagana Butera <nyamsprod@gmail.com>
* @copyright 2013-2015 Ignace Nyamagana Butera
* @license https://github.com/thephpleague/uri/blob/master/LICENSE (MIT License)
* @version 4.0.0
* @version 4.1.0
* @link https://github.com/thephpleague/uri/
*/
namespace League\Uri\Components;
Expand Down Expand Up @@ -96,7 +96,7 @@ public function __toString()
public function getUriComponent()
{
$component = $this->__toString();
if (!empty($component)) {
if ('' !== $component) {
$component .= UserInfoInterface::DELIMITER;
}

Expand Down
6 changes: 3 additions & 3 deletions src/Formatter.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php
/**
* League.Url (http://url.thephpleague.com)
* League.Uri (http://uri.thephpleague.com)
*
* @package League.url
* @package League.uri
* @author Ignace Nyamagana Butera <nyamsprod@gmail.com>
* @copyright 2013-2015 Ignace Nyamagana Butera
* @license https://github.com/thephpleague/uri/blob/master/LICENSE (MIT License)
* @version 4.0.0
* @version 4.1.0
* @link https://github.com/thephpleague/uri/
*/
namespace League\Uri;
Expand Down
Loading

0 comments on commit cde7679

Please sign in to comment.