Skip to content

Commit

Permalink
Merge pull request #1 from Riimu/build-update
Browse files Browse the repository at this point in the history
Build update
  • Loading branch information
Riimu committed Oct 4, 2015
2 parents c7e9674 + 120f08e commit 2be6bac
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 10 deletions.
10 changes: 7 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ php:
- 5.6
- 5.5
- 5.4
- 7.0
- hhvm

cache:
directories:
Expand All @@ -14,8 +16,8 @@ before_install:
- composer self-update

install:
- composer require --no-update --no-interaction "phpunit/phpunit:4.*" "squizlabs/php_codesniffer:2.*" "fabpot/php-cs-fixer:1.*"
- travis_retry composer install --no-interaction
- composer require --no-update --no-interaction "phpunit/phpunit:*" "squizlabs/php_codesniffer:*" "fabpot/php-cs-fixer:*"
- travis_retry composer install --no-interaction --prefer-source
- travis_retry wget https://scrutinizer-ci.com/ocular.phar

script:
Expand All @@ -24,4 +26,6 @@ script:
- vendor/bin/php-cs-fixer fix --dry-run --diff

after_script:
- php ocular.phar code-coverage:upload --format=php-clover coverage.clover
- if [ -f coverage.clover ]; then
php ocular.phar code-coverage:upload --format=php-clover coverage.clover;
fi
5 changes: 5 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog #

## v2.0.1 (2015-10-04) ##

* Fix forward slash normalization in some URIs in PHP7
* Fix several methods accidentally accepting string arrays

## v2.0.0 (2015-09-11) ##

* The `UrlInfo` has been renamed to`Uri`
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,10 @@ may encounter are as follows:
* The number of forward slashes in the beginning of the path in the string
returned by `__toString()` may change depending on whether the URL has an
`authority` component or not.
* Percent encoded characters in parsed and generated URIs in the `userinfo`
component may differ due to the fact that the `UriParser` works with the
PSR-7 specification which does not provide a way to provide encoded username
or password.

## Credits ##

Expand Down
9 changes: 5 additions & 4 deletions src/Uri.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,10 @@ public function __construct($uri = '', $mode = UriParser::MODE_RFC3986)
throw new \InvalidArgumentException("Invalid URI '$uri'");
}

foreach (get_object_vars($parsed) as $name => $value) {
$properties = get_object_vars($parsed);
array_walk($properties, function ($value, $name) {
$this->$name = $value;
}
});
}
}

Expand Down Expand Up @@ -373,7 +374,7 @@ private function normalize($string)
function ($match) {
return strtoupper($match[0]);
},
$string
(string) $string
);
}

Expand Down Expand Up @@ -424,7 +425,7 @@ private function getNormalizedUriPath()

if ($this->getAuthority() === '') {
return preg_replace('#^/+#', '/', $path);
} elseif (in_array(substr($path, 0, 1), [false, '/'], true)) {
} elseif ($path === '' || $path[0] === '/') {
return $path;
}

Expand Down
18 changes: 15 additions & 3 deletions tests/tests/UriTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ public function testEmptyUserInfo()
$this->assertUri('', (new Uri())->withUserInfo('', 'password'));
}

public function testPath()
public function testPathWithoutAuthorityOrScheme()
{
$this->assertUri('path/to/file.html', (new Uri())->withPath('path/to/file.html'));
$this->assertUri('/path/to/file.html', (new Uri())->withPath('/path/to/file.html'));
$this->assertUri('/path/to/file.html', (new Uri())->withPath('//path/to/file.html'));
}

public function testSchemePath()
public function testPathWithScheme()
{
$uri = (new Uri())->withScheme('scheme');

Expand All @@ -54,7 +54,7 @@ public function testSchemePath()
$this->assertUri('scheme:/path/to/file.html', $uri->withPath('//path/to/file.html'));
}

public function testAuthorityPath()
public function testPathWithAuthority()
{
$uri = (new Uri())->withHost('www.example.com');

Expand Down Expand Up @@ -141,6 +141,18 @@ public function testCaseNormalization()
$this->assertUri('scheme:', (new Uri())->withScheme('SCHEME'));
}

public function testArrayAsPath()
{
$uri = new Uri();

try {
$uri = $uri->withPath(['foo', 'bar']);
} catch (\Exception $exception) {
}

$this->assertInternalType('string', $uri->getPath());
}

public function testImmutability()
{
$uri = new Uri();
Expand Down

0 comments on commit 2be6bac

Please sign in to comment.