Skip to content
This repository has been archived by the owner on Jan 31, 2020. It is now read-only.

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
Prepping for 2.2.0RC1.
  • Loading branch information
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/Exception/InvalidUriPartException.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class InvalidUriPartException extends InvalidArgumentException
/**
* Part-specific error codes
*
* @var integer
* @var int
*/
const INVALID_SCHEME = 1;
const INVALID_USER = 2;
Expand Down
4 changes: 2 additions & 2 deletions src/Http.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public function setPassword($password)
* default. Users may still enforce allowing other host types.
*
* @param string $host
* @param integer $allowed
* @param int $allowed
* @return bool
*/
public static function validateHost($host, $allowed = self::HOST_DNS_OR_IPV4_OR_IPV6)
Expand Down Expand Up @@ -162,7 +162,7 @@ protected function parseUserInfo()
*
* If no port is set, will return the default port according to the scheme
*
* @return integer
* @return int
* @see Zend\Uri\Uri::getPort()
*/
public function getPort()
Expand Down
34 changes: 25 additions & 9 deletions src/Uri.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class Uri implements UriInterface
/**
* URI port
*
* @var integer
* @var int
*/
protected $port;

Expand Down Expand Up @@ -97,7 +97,7 @@ class Uri implements UriInterface
/**
* Which host part types are valid for this URI?
*
* @var integer
* @var int
*/
protected $validHostTypes = self::HOST_ALL;

Expand Down Expand Up @@ -253,6 +253,20 @@ public function isAbsolute()
return ($this->scheme !== null);
}

/**
* Reset URI parts
*/
protected function reset()
{
$this->setScheme(null);
$this->setPort(null);
$this->setUserInfo(null);
$this->setHost(null);
$this->setPath(null);
$this->setFragment(null);
$this->setQuery(null);
}

/**
* Parse a URI string
*
Expand All @@ -261,6 +275,8 @@ public function isAbsolute()
*/
public function parse($uri)
{
$this->reset();

// Capture scheme
if (($scheme = self::parseScheme($uri)) !== null) {
$this->setScheme($scheme);
Expand Down Expand Up @@ -601,7 +617,7 @@ public function getHost()
/**
* Get the URI port
*
* @return integer|null
* @return int|null
*/
public function getPort()
{
Expand Down Expand Up @@ -737,7 +753,7 @@ public function setHost($host)
/**
* Set the port part of the URI
*
* @param integer $port
* @param int $port
* @return Uri
*/
public function setPort($port)
Expand Down Expand Up @@ -859,7 +875,7 @@ public static function validateUserInfo($userInfo)
* from what is commonly accepted as valid HTTP URLs for example.
*
* @param string $host
* @param integer $allowed bitmask of allowed host types
* @param int $allowed bitmask of allowed host types
* @return bool
*/
public static function validateHost($host, $allowed = self::HOST_ALL)
Expand Down Expand Up @@ -895,7 +911,7 @@ public static function validateHost($host, $allowed = self::HOST_ALL)
*
* Valid values include numbers between 1 and 65535, and empty values
*
* @param integer $port
* @param int $port
* @return bool
*/
public static function validatePort($port)
Expand Down Expand Up @@ -1139,7 +1155,7 @@ public static function merge($baseUri, $relativeUri)
* Check if a host name is a valid IP address, depending on allowed IP address types
*
* @param string $host
* @param integer $allowed allowed address types
* @param int $allowed allowed address types
* @return bool
*/
protected static function isValidIpAddress($host, $allowed)
Expand Down Expand Up @@ -1237,9 +1253,9 @@ protected static function normalizeHost($host)
* If the class defines a default port for the current scheme, and the
* current port is default, it will be unset.
*
* @param integer $port
* @param int $port
* @param string $scheme
* @return integer|null
* @return int|null
*/
protected static function normalizePort($port, $scheme = null)
{
Expand Down
4 changes: 2 additions & 2 deletions src/UriInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public function getHost();
/**
* Get the URI port
*
* @return integer|null
* @return int|null
*/
public function getPort();

Expand Down Expand Up @@ -202,7 +202,7 @@ public function setHost($host);
/**
* Set the port part of the URI
*
* @param integer $port
* @param int $port
* @return Uri
*/
public function setPort($port);
Expand Down
14 changes: 14 additions & 0 deletions test/UriTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1335,4 +1335,18 @@ public function notStringInputProvider()
array(array('scheme' => 'http', 'host' => 'example.com'))
);
}

public function testParseTwice()
{
$uri = new Uri();
$uri->parse('http://[email protected]:1/absolute/url?query#fragment');
$uri->parse('/relative/url');
$this->assertNull($uri->getScheme());
$this->assertNull($uri->getHost());
$this->assertNull($uri->getUserInfo());
$this->assertNull($uri->getPort());
$this->assertNull($uri->getQuery());
$this->assertNull($uri->getFragment());
}

}

0 comments on commit 963112c

Please sign in to comment.