Skip to content

Commit

Permalink
Merge f9e5d6a into cd473f8
Browse files Browse the repository at this point in the history
  • Loading branch information
vpn committed Oct 31, 2020
2 parents cd473f8 + f9e5d6a commit 6a4f201
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 54 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -7,3 +7,4 @@
/phpunit.xml
/vendor/
/.phpcs-cache
/.phpunit.result.cache
26 changes: 8 additions & 18 deletions .travis.yml
Expand Up @@ -12,37 +12,27 @@ env:
matrix:
fast_finish: true
include:
- php: 5.6
env:
- DEPS=lowest
- php: 5.6
env:
- DEPS=latest
- php: 7
- php: 7.3
env:
- DEPS=lowest
- php: 7
- php: 7.3
env:
- DEPS=latest
- php: 7.1
- php: 7.4
env:
- DEPS=lowest
- php: 7.1
- php: 7.4
env:
- DEPS=latest
- CS_CHECK=true
- TEST_COVERAGE=true
- php: 7.2
- php: nightly
env:
- COMPOSER_ARGS="--no-interaction --ignore-platform-reqs"
- DEPS=lowest
- php: 7.2
env:
- DEPS=latest
- php: 7.3
env:
- DEPS=lowest
- php: 7.3
- php: nightly
env:
- COMPOSER_ARGS="--no-interaction --ignore-platform-reqs"
- DEPS=latest

before_install:
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Expand Up @@ -21,14 +21,14 @@
"extra": {
},
"require": {
"php": "^5.6 || ^7.0",
"php": "^7.3 || ~8.0.0",
"laminas/laminas-escaper": "^2.5",
"laminas/laminas-validator": "^2.10",
"laminas/laminas-zendframework-bridge": "^1.0"
},
"require-dev": {
"laminas/laminas-coding-standard": "^2.1",
"phpunit/phpunit": "^5.7.27 || ^6.5.8 || ^7.1.4"
"phpunit/phpunit": "^9.3"
},
"autoload": {
"psr-4": {
Expand Down
20 changes: 10 additions & 10 deletions src/Exception/InvalidUriPartException.php
Expand Up @@ -15,14 +15,14 @@ class InvalidUriPartException extends InvalidArgumentException
*
* @var int
*/
const INVALID_SCHEME = 1;
const INVALID_USER = 2;
const INVALID_PASSWORD = 4;
const INVALID_USERINFO = 6;
const INVALID_HOSTNAME = 8;
const INVALID_PORT = 16;
const INVALID_AUTHORITY = 30;
const INVALID_PATH = 32;
const INVALID_QUERY = 64;
const INVALID_FRAGMENT = 128;
public const INVALID_SCHEME = 1;
public const INVALID_USER = 2;
public const INVALID_PASSWORD = 4;
public const INVALID_USERINFO = 6;
public const INVALID_HOSTNAME = 8;
public const INVALID_PORT = 16;
public const INVALID_AUTHORITY = 30;
public const INVALID_PATH = 32;
public const INVALID_QUERY = 64;
public const INVALID_FRAGMENT = 128;
}
39 changes: 21 additions & 18 deletions src/Uri.php
Expand Up @@ -49,14 +49,14 @@ class Uri implements UriInterface
/**
* Character classes defined in RFC-3986
*/
const CHAR_UNRESERVED = 'a-zA-Z0-9_\-\.~';
const CHAR_GEN_DELIMS = ':\/\?#\[\]@';
const CHAR_SUB_DELIMS = '!\$&\'\(\)\*\+,;=';
const CHAR_RESERVED = ':\/\?#\[\]@!\$&\'\(\)\*\+,;=';
public const CHAR_UNRESERVED = 'a-zA-Z0-9_\-\.~';
public const CHAR_GEN_DELIMS = ':\/\?#\[\]@';
public const CHAR_SUB_DELIMS = '!\$&\'\(\)\*\+,;=';
public const CHAR_RESERVED = ':\/\?#\[\]@!\$&\'\(\)\*\+,;=';
/**
* Not in the spec - those characters have special meaning in urlencoded query parameters
*/
const CHAR_QUERY_DELIMS = '!\$\'\(\)\*\,';
public const CHAR_QUERY_DELIMS = '!\$\'\(\)\*\,';

/**
* Host part types represented as binary masks
Expand All @@ -65,18 +65,18 @@ class Uri implements UriInterface
* Place 1 or 0 in the different positions for enable or disable the part.
* Finally use a hexadecimal representation.
*/
const HOST_IPV4 = 0x01; //00001
const HOST_IPV6 = 0x02; //00010
const HOST_IPVFUTURE = 0x04; //00100
const HOST_IPVANY = 0x07; //00111
const HOST_DNS = 0x08; //01000
const HOST_DNS_OR_IPV4 = 0x09; //01001
const HOST_DNS_OR_IPV6 = 0x0A; //01010
const HOST_DNS_OR_IPV4_OR_IPV6 = 0x0B; //01011
const HOST_DNS_OR_IPVANY = 0x0F; //01111
const HOST_REGNAME = 0x10; //10000
const HOST_DNS_OR_IPV4_OR_IPV6_OR_REGNAME = 0x1B; //11011
const HOST_ALL = 0x1F; //11111
public const HOST_IPV4 = 0x01; //00001
public const HOST_IPV6 = 0x02; //00010
public const HOST_IPVFUTURE = 0x04; //00100
public const HOST_IPVANY = 0x07; //00111
public const HOST_DNS = 0x08; //01000
public const HOST_DNS_OR_IPV4 = 0x09; //01001
public const HOST_DNS_OR_IPV6 = 0x0A; //01010
public const HOST_DNS_OR_IPV4_OR_IPV6 = 0x0B; //01011
public const HOST_DNS_OR_IPVANY = 0x0F; //01111
public const HOST_REGNAME = 0x10; //10000
public const HOST_DNS_OR_IPV4_OR_IPV6_OR_REGNAME = 0x1B; //11011
public const HOST_ALL = 0x1F; //11111

/**
* URI scheme
Expand Down Expand Up @@ -1140,7 +1140,10 @@ public static function removePathDotSegments($path)
break;
case 0 === strpos($path, '/../'):
$path = '/' . substr($path, 4);
$lastSlashPos = strrpos($output, '/', -1);
$lastSlashPos = false;
if ($output !== '') {
$lastSlashPos = strrpos($output, '/', -1);
}
if (false === $lastSlashPos) {
break;
}
Expand Down
6 changes: 3 additions & 3 deletions src/UriFactory.php
Expand Up @@ -82,11 +82,11 @@ public static function unregisterScheme($scheme)
*/
public static function getRegisteredSchemeClass($scheme)
{
if (isset(static::$schemeClasses[$scheme])) {
return static::$schemeClasses[$scheme];
if (! isset(static::$schemeClasses[$scheme])) {
return null;
}

return;
return static::$schemeClasses[$scheme];
}

/**
Expand Down
6 changes: 3 additions & 3 deletions test/UriFactoryTest.php
Expand Up @@ -33,11 +33,11 @@ class UriFactoryTest extends TestCase
*/
public function testRegisteringNewScheme($scheme, $class)
{
$this->assertAttributeNotContains($class, 'schemeClasses', UriFactory::class);
self::assertNull(UriFactory::getRegisteredSchemeClass($scheme));
UriFactory::registerScheme($scheme, $class);
$this->assertAttributeContains($class, 'schemeClasses', UriFactory::class);
self::assertSame($class, UriFactory::getRegisteredSchemeClass($scheme));
UriFactory::unregisterScheme($scheme);
$this->assertAttributeNotContains($class, 'schemeClasses', UriFactory::class);
self::assertNull(UriFactory::getRegisteredSchemeClass($scheme));
}

/**
Expand Down

0 comments on commit 6a4f201

Please sign in to comment.