diff --git a/phpcs.xml.dist b/phpcs.xml.dist
index 340a8a2..aff0430 100644
--- a/phpcs.xml.dist
+++ b/phpcs.xml.dist
@@ -29,12 +29,4 @@
src/Purl/AbstractPart.php
-
-
- src/Purl/AbstractPart.php
-
-
-
- src/Purl/AbstractPart.php
-
diff --git a/src/Purl/AbstractPart.php b/src/Purl/AbstractPart.php
index 55dd4ae..0f7a834 100644
--- a/src/Purl/AbstractPart.php
+++ b/src/Purl/AbstractPart.php
@@ -13,19 +13,18 @@
*/
abstract class AbstractPart implements ArrayAccess
{
- /** @var bool */
- protected $initialized = false;
+ protected bool $initialized = false;
/** @var mixed[] */
- protected $data = [];
+ protected array $data = [];
/** @var string[] */
- protected $partClassMap = [];
+ protected array $partClassMap = [];
/**
* @return mixed[]
*/
- public function getData() : array
+ public function getData(): array
{
$this->initialize();
@@ -35,19 +34,19 @@ public function getData() : array
/**
* @param mixed[] $data
*/
- public function setData(array $data) : void
+ public function setData(array $data): void
{
$this->initialize();
$this->data = $data;
}
- public function isInitialized() : bool
+ public function isInitialized(): bool
{
return $this->initialized;
}
- public function has(string $key) : bool
+ public function has(string $key): bool
{
$this->initialize();
@@ -67,7 +66,7 @@ public function get(string $key)
/**
* @param mixed $value
*/
- public function set(string $key, $value) : AbstractPart
+ public function set(string $key, $value): AbstractPart
{
$this->initialize();
$this->data[$key] = $value;
@@ -78,7 +77,7 @@ public function set(string $key, $value) : AbstractPart
/**
* @param mixed $value
*/
- public function add($value) : AbstractPart
+ public function add($value): AbstractPart
{
$this->initialize();
$this->data[] = $value;
@@ -86,7 +85,7 @@ public function add($value) : AbstractPart
return $this;
}
- public function remove(string $key) : AbstractPart
+ public function remove(string $key): AbstractPart
{
$this->initialize();
@@ -95,7 +94,7 @@ public function remove(string $key) : AbstractPart
return $this;
}
- public function __isset(string $key) : bool
+ public function __isset(string $key): bool
{
return $this->has($key);
}
@@ -111,12 +110,12 @@ public function __get(string $key)
/**
* @param mixed $value
*/
- public function __set(string $key, $value) : AbstractPart
+ public function __set(string $key, $value): AbstractPart
{
return $this->set($key, $value);
}
- public function __unset(string $key) : void
+ public function __unset(string $key): void
{
$this->remove($key);
}
@@ -124,7 +123,7 @@ public function __unset(string $key) : void
/**
* @param mixed $key
*/
- public function offsetExists($key) : bool
+ public function offsetExists($key): bool
{
$this->initialize();
@@ -144,25 +143,21 @@ public function offsetGet($key)
/**
* @param mixed $key
* @param mixed $value
- *
- * @return void
*/
- public function offsetSet($key, $value)
+ public function offsetSet($key, $value): void
{
$this->set($key, $value);
}
/**
* @param mixed $key
- *
- * @return void
*/
- public function offsetUnset($key)
+ public function offsetUnset($key): void
{
$this->remove($key);
}
- protected function initialize() : void
+ protected function initialize(): void
{
if ($this->initialized === true) {
return;
@@ -189,7 +184,7 @@ protected function preparePartValue(string $key, $value)
return ! $value instanceof $className ? new $className($value) : $value;
}
- abstract public function __toString() : string;
+ abstract public function __toString(): string;
- abstract protected function doInitialize() : void;
+ abstract protected function doInitialize(): void;
}
diff --git a/src/Purl/Fragment.php b/src/Purl/Fragment.php
index b126f0e..aeac799 100644
--- a/src/Purl/Fragment.php
+++ b/src/Purl/Fragment.php
@@ -18,16 +18,16 @@
class Fragment extends AbstractPart
{
/** @var string|null The original fragment string. */
- private $fragment;
+ private ?string $fragment = null;
/** @var mixed[] */
- protected $data = [
+ protected array $data = [
'path' => null,
'query' => null,
];
/** @var string[] */
- protected $partClassMap = [
+ protected array $partClassMap = [
'path' => 'Purl\Path',
'query' => 'Purl\Query',
];
@@ -50,7 +50,7 @@ public function __construct($fragment = null, ?Query $query = null)
/**
* @param mixed $value
*/
- public function set(string $key, $value) : AbstractPart
+ public function set(string $key, $value): AbstractPart
{
$this->initialize();
$this->data[$key] = $this->preparePartValue($key, $value);
@@ -58,7 +58,7 @@ public function set(string $key, $value) : AbstractPart
return $this;
}
- public function getFragment() : string
+ public function getFragment(): string
{
$this->initialize();
@@ -69,7 +69,7 @@ public function getFragment() : string
);
}
- public function setFragment(string $fragment) : AbstractPart
+ public function setFragment(string $fragment): AbstractPart
{
$this->initialized = false;
$this->data = [];
@@ -78,40 +78,40 @@ public function setFragment(string $fragment) : AbstractPart
return $this;
}
- public function setPath(Path $path) : AbstractPart
+ public function setPath(Path $path): AbstractPart
{
$this->data['path'] = $path;
return $this;
}
- public function getPath() : Path
+ public function getPath(): Path
{
$this->initialize();
return $this->data['path'];
}
- public function setQuery(Query $query) : AbstractPart
+ public function setQuery(Query $query): AbstractPart
{
$this->data['query'] = $query;
return $this;
}
- public function getQuery() : Query
+ public function getQuery(): Query
{
$this->initialize();
return $this->data['query'];
}
- public function __toString() : string
+ public function __toString(): string
{
return $this->getFragment();
}
- protected function doInitialize() : void
+ protected function doInitialize(): void
{
if ($this->fragment !== null) {
$parsed = parse_url($this->fragment);
diff --git a/src/Purl/Parser.php b/src/Purl/Parser.php
index 8685c99..bad041e 100644
--- a/src/Purl/Parser.php
+++ b/src/Purl/Parser.php
@@ -5,6 +5,7 @@
namespace Purl;
use InvalidArgumentException;
+
use function array_merge;
use function array_reverse;
use function explode;
@@ -18,7 +19,7 @@
class Parser implements ParserInterface
{
/** @var mixed[] */
- private static $defaultParts = [
+ private static array $defaultParts = [
'scheme' => null,
'host' => null,
'port' => null,
@@ -36,7 +37,7 @@ class Parser implements ParserInterface
*
* @return mixed[]
*/
- public function parseUrl($url) : array
+ public function parseUrl($url): array
{
$url = (string) $url;
@@ -64,7 +65,7 @@ public function parseUrl($url) : array
/**
* @return mixed[]
*/
- protected function doParseUrl(string $url) : array
+ protected function doParseUrl(string $url): array
{
$parsedUrl = parse_url($url);
diff --git a/src/Purl/ParserInterface.php b/src/Purl/ParserInterface.php
index 84c411b..5283e0b 100644
--- a/src/Purl/ParserInterface.php
+++ b/src/Purl/ParserInterface.php
@@ -11,5 +11,5 @@ interface ParserInterface
*
* @return mixed[]
*/
- public function parseUrl($url) : array;
+ public function parseUrl($url): array;
}
diff --git a/src/Purl/Path.php b/src/Purl/Path.php
index b46c3dc..52d3a82 100644
--- a/src/Purl/Path.php
+++ b/src/Purl/Path.php
@@ -15,14 +15,14 @@
class Path extends AbstractPart
{
/** @var string|null The original path string. */
- private $path;
+ private ?string $path = null;
public function __construct(?string $path = null)
{
$this->path = $path;
}
- public function getPath() : string
+ public function getPath(): string
{
$this->initialize();
@@ -31,7 +31,7 @@ public function getPath() : string
}, $this->data));
}
- public function setPath(string $path) : void
+ public function setPath(string $path): void
{
$this->initialized = false;
$this->path = $path;
@@ -40,19 +40,19 @@ public function setPath(string $path) : void
/**
* @return mixed[]
*/
- public function getSegments() : array
+ public function getSegments(): array
{
$this->initialize();
return $this->data;
}
- public function __toString() : string
+ public function __toString(): string
{
return $this->getPath();
}
- protected function doInitialize() : void
+ protected function doInitialize(): void
{
$this->data = explode('/', (string) $this->path);
}
diff --git a/src/Purl/Query.php b/src/Purl/Query.php
index 8f81569..a038e00 100644
--- a/src/Purl/Query.php
+++ b/src/Purl/Query.php
@@ -13,32 +13,32 @@
class Query extends AbstractPart
{
/** @var string|null The original query string. */
- private $query;
+ private ?string $query = null;
public function __construct(?string $query = null)
{
$this->query = $query;
}
- public function getQuery() : string
+ public function getQuery(): string
{
$this->initialize();
return http_build_query($this->data);
}
- public function setQuery(string $query) : void
+ public function setQuery(string $query): void
{
$this->initialized = false;
$this->query = $query;
}
- public function __toString() : string
+ public function __toString(): string
{
return $this->getQuery();
}
- protected function doInitialize() : void
+ protected function doInitialize(): void
{
parse_str((string) $this->query, $data);
diff --git a/src/Purl/Url.php b/src/Purl/Url.php
index c0343df..dfe0ee3 100644
--- a/src/Purl/Url.php
+++ b/src/Purl/Url.php
@@ -28,13 +28,12 @@
class Url extends AbstractPart
{
/** @var string|null The original url string. */
- private $url;
+ private ?string $url = null;
- /** @var ParserInterface|null */
- private $parser;
+ private ?ParserInterface $parser = null;
/** @var mixed[] */
- protected $data = [
+ protected array $data = [
'scheme' => null,
'host' => null,
'port' => null,
@@ -51,7 +50,7 @@ class Url extends AbstractPart
];
/** @var string[] */
- protected $partClassMap = [
+ protected array $partClassMap = [
'path' => 'Purl\Path',
'query' => 'Purl\Query',
'fragment' => 'Purl\Fragment',
@@ -63,7 +62,7 @@ public function __construct(?string $url = null, ?ParserInterface $parser = null
$this->parser = $parser;
}
- public static function parse(string $url) : Url
+ public static function parse(string $url): Url
{
return new self($url);
}
@@ -71,7 +70,7 @@ public static function parse(string $url) : Url
/**
* @return Url[] $urls
*/
- public static function extract(string $string) : array
+ public static function extract(string $string): array
{
$regex = '/(http|https|ftp|ftps)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,}(\/\S*)?/';
@@ -84,7 +83,7 @@ public static function extract(string $string) : array
return $urls;
}
- public static function fromCurrent() : Url
+ public static function fromCurrent(): Url
{
$scheme = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] === 443 ? 'https' : 'http';
@@ -108,8 +107,10 @@ public static function fromCurrent() : Url
// Only set port if different from default (80 or 443)
if (isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT']) {
$port = $_SERVER['SERVER_PORT'];
- if (($scheme === 'http' && $port !== 80) ||
- ($scheme === 'https' && $port !== 443)) {
+ if (
+ ($scheme === 'http' && $port !== 80) ||
+ ($scheme === 'https' && $port !== 443)
+ ) {
$url->set('port', $port);
}
}
@@ -125,7 +126,7 @@ public static function fromCurrent() : Url
return $url;
}
- public function getParser() : ParserInterface
+ public function getParser(): ParserInterface
{
if ($this->parser === null) {
$this->parser = self::createDefaultParser();
@@ -134,7 +135,7 @@ public function getParser() : ParserInterface
return $this->parser;
}
- public function setParser(ParserInterface $parser) : void
+ public function setParser(ParserInterface $parser): void
{
$this->parser = $parser;
}
@@ -142,7 +143,7 @@ public function setParser(ParserInterface $parser) : void
/**
* @param string|Url $url
*/
- public function join($url) : Url
+ public function join($url): Url
{
$this->initialize();
$parts = $this->getParser()->parseUrl($url);
@@ -169,7 +170,7 @@ public function join($url) : Url
/**
* @param mixed $value
*/
- public function set(string $key, $value) : AbstractPart
+ public function set(string $key, $value): AbstractPart
{
$this->initialize();
@@ -178,56 +179,56 @@ public function set(string $key, $value) : AbstractPart
return $this;
}
- public function setPath(Path $path) : AbstractPart
+ public function setPath(Path $path): AbstractPart
{
$this->data['path'] = $path;
return $this;
}
- public function getPath() : Path
+ public function getPath(): Path
{
$this->initialize();
return $this->data['path'];
}
- public function setQuery(Query $query) : AbstractPart
+ public function setQuery(Query $query): AbstractPart
{
$this->data['query'] = $query;
return $this;
}
- public function getQuery() : Query
+ public function getQuery(): Query
{
$this->initialize();
return $this->data['query'];
}
- public function setFragment(Fragment $fragment) : AbstractPart
+ public function setFragment(Fragment $fragment): AbstractPart
{
$this->data['fragment'] = $fragment;
return $this;
}
- public function getFragment() : Fragment
+ public function getFragment(): Fragment
{
$this->initialize();
return $this->data['fragment'];
}
- public function getNetloc() : string
+ public function getNetloc(): string
{
$this->initialize();
return ($this->user !== null && $this->pass !== null ? $this->user . ($this->pass !== null ? ':' . $this->pass : '') . '@' : '') . $this->host . ($this->port !== null ? ':' . $this->port : '');
}
- public function getUrl() : string
+ public function getUrl(): string
{
$this->initialize();
@@ -240,26 +241,26 @@ public function getUrl() : string
return self::httpBuildUrl($parts);
}
- public function setUrl(string $url) : void
+ public function setUrl(string $url): void
{
$this->initialized = false;
$this->data = [];
$this->url = $url;
}
- public function isAbsolute() : bool
+ public function isAbsolute(): bool
{
$this->initialize();
return $this->scheme !== null && $this->host !== null;
}
- public function __toString() : string
+ public function __toString(): string
{
return $this->getUrl();
}
- protected function doInitialize() : void
+ protected function doInitialize(): void
{
$parts = $this->getParser()->parseUrl($this->url);
@@ -279,7 +280,7 @@ protected function doInitialize() : void
/**
* @param string[] $parts
*/
- private static function httpBuildUrl(array $parts) : string
+ private static function httpBuildUrl(array $parts): string
{
$relative = self::httpBuildRelativeUrl($parts);
@@ -300,7 +301,7 @@ private static function httpBuildUrl(array $parts) : string
/**
* @param string[] $parts
*/
- private static function httpBuildRelativeUrl(array $parts) : string
+ private static function httpBuildRelativeUrl(array $parts): string
{
$parts['path'] = ltrim($parts['path'], '/');
@@ -312,7 +313,7 @@ private static function httpBuildRelativeUrl(array $parts) : string
);
}
- private static function createDefaultParser() : Parser
+ private static function createDefaultParser(): Parser
{
return new Parser();
}
diff --git a/tests/Purl/Test/FragmentTest.php b/tests/Purl/Test/FragmentTest.php
index baef335..4135656 100644
--- a/tests/Purl/Test/FragmentTest.php
+++ b/tests/Purl/Test/FragmentTest.php
@@ -11,7 +11,7 @@
class FragmentTest extends TestCase
{
- public function testConstruct() : void
+ public function testConstruct(): void
{
$fragment = new Fragment('test?param=value');
$this->assertInstanceOf('Purl\Path', $fragment->path);
@@ -26,13 +26,13 @@ public function testConstruct() : void
$this->assertEquals('param=value', (string) $fragment->query);
}
- public function testGetFragment() : void
+ public function testGetFragment(): void
{
$fragment = new Fragment('test?param=value');
$this->assertEquals('test?param=value', $fragment->getFragment());
}
- public function testSetFragment() : void
+ public function testSetFragment(): void
{
$fragment = new Fragment('test?param=value');
$this->assertEquals('test?param=value', $fragment->getFragment());
@@ -40,7 +40,7 @@ public function testSetFragment() : void
$this->assertEquals('changed?param=value', $fragment->getFragment());
}
- public function testGetSetPath() : void
+ public function testGetSetPath(): void
{
$fragment = new Fragment();
$path = new Path('test');
@@ -49,7 +49,7 @@ public function testGetSetPath() : void
$this->assertEquals('test', (string) $fragment);
}
- public function testGetSetQuery() : void
+ public function testGetSetQuery(): void
{
$fragment = new Fragment();
$query = new Query('param=value');
@@ -58,26 +58,26 @@ public function testGetSetQuery() : void
$this->assertEquals('?param=value', (string) $fragment);
}
- public function testToString() : void
+ public function testToString(): void
{
$fragment = new Fragment('test?param=value');
$this->assertEquals('test?param=value', (string) $fragment);
}
- public function testIsInitialized() : void
+ public function testIsInitialized(): void
{
$fragment = new Fragment('test?param=value');
$this->assertFalse($fragment->isInitialized());
}
- public function testHas() : void
+ public function testHas(): void
{
$fragment = new Fragment('test?param=value');
$fragment->setData(['param' => 'value']);
$this->assertTrue($fragment->has('param'));
}
- public function testRemove() : void
+ public function testRemove(): void
{
$fragment = new Fragment('test?param=value');
$fragment->setData(['param' => 'value']);
@@ -85,7 +85,7 @@ public function testRemove() : void
$this->assertFalse($fragment->has('param'));
}
- public function testIsset() : void
+ public function testIsset(): void
{
$fragment = new Fragment('test?param=value');
$fragment->setData(['param' => 'value']);
@@ -93,21 +93,21 @@ public function testIsset() : void
$this->assertFalse($fragment->has('param'));
}
- public function testOffsetExists() : void
+ public function testOffsetExists(): void
{
$fragment = new Fragment('test?param=value');
$fragment->setData(['param' => 'value']);
$this->assertTrue($fragment->offsetExists('param'));
}
- public function testOffsetGet() : void
+ public function testOffsetGet(): void
{
$fragment = new Fragment('test?param=value');
$fragment->setData(['param' => 'value']);
$this->assertEquals('value', $fragment->offsetGet('param'));
}
- public function testOffsetUnset() : void
+ public function testOffsetUnset(): void
{
$fragment = new Fragment('test?param=value');
$fragment->setData(['param' => 'value']);
diff --git a/tests/Purl/Test/MemoryUsageTest.php b/tests/Purl/Test/MemoryUsageTest.php
index d127646..aa00a90 100644
--- a/tests/Purl/Test/MemoryUsageTest.php
+++ b/tests/Purl/Test/MemoryUsageTest.php
@@ -6,6 +6,7 @@
use PHPUnit\Framework\TestCase;
use Purl\Url;
+
use function floor;
use function log;
use function memory_get_usage;
@@ -14,7 +15,7 @@
class MemoryUsageTest extends TestCase
{
- public function testMemoryUsage() : void
+ public function testMemoryUsage(): void
{
$domains = [
'http://google.de',
@@ -39,7 +40,7 @@ public function testMemoryUsage() : void
self::assertEquals($this->roundMemoryUsage($memoryStart), $this->roundMemoryUsage($memoryEnd));
}
- private function roundMemoryUsage(float $size) : float
+ private function roundMemoryUsage(float $size): float
{
return round($size / pow(1024, $i = floor(log($size, 1024))));
}
diff --git a/tests/Purl/Test/ParserTest.php b/tests/Purl/Test/ParserTest.php
index b0a71ae..466fc01 100644
--- a/tests/Purl/Test/ParserTest.php
+++ b/tests/Purl/Test/ParserTest.php
@@ -10,23 +10,22 @@
class ParserTest extends TestCase
{
- /** @var Parser */
- private $parser;
+ private Parser $parser;
- protected function setUp() : void
+ protected function setUp(): void
{
parent::setUp();
$this->parser = new Parser();
}
- protected function tearDown() : void
+ protected function tearDown(): void
{
$this->parser = null;
parent::tearDown();
}
- public function testParseUrl() : void
+ public function testParseUrl(): void
{
$parts = $this->parser->parseUrl('https://sub.domain.jwage.com:443/about?param=value#fragment?param=value');
$this->assertEquals([
@@ -43,7 +42,7 @@ public function testParseUrl() : void
], $parts);
}
- public function testParseBadUrlThrowsInvalidArgumentException() : void
+ public function testParseBadUrlThrowsInvalidArgumentException(): void
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('Invalid url http:///example.com');
diff --git a/tests/Purl/Test/PathTest.php b/tests/Purl/Test/PathTest.php
index 1357167..b2d4e49 100644
--- a/tests/Purl/Test/PathTest.php
+++ b/tests/Purl/Test/PathTest.php
@@ -9,13 +9,13 @@
class PathTest extends TestCase
{
- public function testConstruct() : void
+ public function testConstruct(): void
{
$path = new Path('test');
$this->assertEquals('test', $path->getPath());
}
- public function testGetSetPath() : void
+ public function testGetSetPath(): void
{
$path = new Path();
$this->assertEquals('', $path->getPath());
@@ -23,13 +23,13 @@ public function testGetSetPath() : void
$this->assertEquals('test', $path->getPath());
}
- public function testGetSegments() : void
+ public function testGetSegments(): void
{
$path = new Path('about/me');
$this->assertEquals(['about', 'me'], $path->getSegments());
}
- public function testToString() : void
+ public function testToString(): void
{
$path = new Path('about/me');
$this->assertEquals('about/me', (string) $path);
diff --git a/tests/Purl/Test/QueryTest.php b/tests/Purl/Test/QueryTest.php
index 6a62372..16e40b7 100644
--- a/tests/Purl/Test/QueryTest.php
+++ b/tests/Purl/Test/QueryTest.php
@@ -9,13 +9,13 @@
class QueryTest extends TestCase
{
- public function testConstruct() : void
+ public function testConstruct(): void
{
$query = new Query('param=value');
$this->assertEquals('param=value', $query->getQuery());
}
- public function testGetSetQuery() : void
+ public function testGetSetQuery(): void
{
$query = new Query();
$this->assertEquals('', $query->getQuery());
@@ -23,13 +23,13 @@ public function testGetSetQuery() : void
$this->assertEquals('param1=value1¶m2=value2', $query->getQuery());
}
- public function testToString() : void
+ public function testToString(): void
{
$query = new Query('param1=value1¶m2=value2');
$this->assertEquals('param1=value1¶m2=value2', (string) $query);
}
- public function testGetSetData() : void
+ public function testGetSetData(): void
{
$query = new Query('param1=value1¶m2=value2');
$this->assertEquals(['param1' => 'value1', 'param2' => 'value2'], $query->getData());
diff --git a/tests/Purl/Test/UrlTest.php b/tests/Purl/Test/UrlTest.php
index ec0b071..8a2dfdf 100644
--- a/tests/Purl/Test/UrlTest.php
+++ b/tests/Purl/Test/UrlTest.php
@@ -10,11 +10,12 @@
use Purl\Path;
use Purl\Query;
use Purl\Url;
+
use function count;
class UrlTest extends TestCase
{
- public function testConstruct() : void
+ public function testConstruct(): void
{
$url = new Url();
$url->setUrl('http://jwage.com');
@@ -26,7 +27,7 @@ public function testConstruct() : void
$this->assertSame($parser, $url->getParser());
}
- public function testSetParser() : void
+ public function testSetParser(): void
{
$parser = new TestParser();
$url = new Url();
@@ -34,7 +35,7 @@ public function testSetParser() : void
$this->assertSame($parser, $url->getParser());
}
- public function testParseSanity() : void
+ public function testParseSanity(): void
{
$url = new Url('https://host.com:443/path with spaces?param1 with spaces=value1 with spaces¶m2=value2#fragment1/fragment2 with spaces?param1=value1¶m2 with spaces=value2 with spaces');
$this->assertEquals('https', $url->scheme);
@@ -52,14 +53,14 @@ public function testParseSanity() : void
$this->assertEquals('fragment1/fragment2%20with%20spaces', (string) $url->fragment->path);
}
- public function testParseStaticMethod() : void
+ public function testParseStaticMethod(): void
{
$url = Url::parse('http://google.com');
$this->assertInstanceOf('Purl\Url', $url);
$this->assertEquals('http://google.com/', (string) $url);
}
- public function testBuild() : void
+ public function testBuild(): void
{
$url = Url::parse('http://jwage.com')
->set('port', '443')
@@ -82,7 +83,7 @@ public function testBuild() : void
$this->assertEquals('https://jwage.com:443/about/me?param1=value1¶m2=value2#/fragment1/fragment2?param1=value1¶m2=value2', (string) $url);
}
- public function testJoin() : void
+ public function testJoin(): void
{
$url = new Url('http://jwage.com/about?param=value#fragment');
$this->assertEquals('http://jwage.com/about?param=value#fragment', (string) $url);
@@ -90,7 +91,7 @@ public function testJoin() : void
$this->assertEquals('http://about.me/jwage?param=value#fragment', (string) $url);
}
- public function testSetPath() : void
+ public function testSetPath(): void
{
$url = new Url('http://jwage.com');
$url->path = 'about';
@@ -98,7 +99,7 @@ public function testSetPath() : void
$this->assertEquals('about', (string) $url->path);
}
- public function testGetPath() : void
+ public function testGetPath(): void
{
$url = new Url('http://jwage.com');
$url->path = 'about';
@@ -106,7 +107,7 @@ public function testGetPath() : void
$this->assertEquals('about', (string) $url->getPath());
}
- public function testSetQuery() : void
+ public function testSetQuery(): void
{
$url = new Url('http://jwage.com');
$url->query->set('param1', 'value1');
@@ -115,7 +116,7 @@ public function testSetQuery() : void
$this->assertEquals(['param1' => 'value1'], $url->query->getData());
}
- public function testGetQuery() : void
+ public function testGetQuery(): void
{
$url = new Url('http://jwage.com');
$url->query->set('param1', 'value1');
@@ -124,7 +125,7 @@ public function testGetQuery() : void
$this->assertEquals(['param1' => 'value1'], $url->getQuery()->getData());
}
- public function testSetFragment() : void
+ public function testSetFragment(): void
{
$url = new Url('http://jwage.com');
$url->fragment->path = 'about';
@@ -132,13 +133,13 @@ public function testSetFragment() : void
$this->assertEquals('http://jwage.com/#about?param1=value1', (string) $url);
}
- public function testProtocolRelativeUrl() : void
+ public function testProtocolRelativeUrl(): void
{
$url = new Url('https://example.com');
$this->assertEquals('https', $url->join('//code.jquery.com/jquery-3.10.js')->scheme);
}
- public function testGetFragment() : void
+ public function testGetFragment(): void
{
$url = new Url('http://jwage.com');
$url->fragment->path = 'about';
@@ -146,19 +147,19 @@ public function testGetFragment() : void
$this->assertEquals('about?param1=value1', (string) $url->getFragment());
}
- public function testGetNetloc() : void
+ public function testGetNetloc(): void
{
$url = new Url('https://user:pass@jwage.com:443');
$this->assertEquals('user:pass@jwage.com:443', $url->getNetloc());
}
- public function testGetUrl() : void
+ public function testGetUrl(): void
{
$url = new Url('http://jwage.com');
$this->assertEquals('http://jwage.com/', $url->getUrl());
}
- public function testSetUrl() : void
+ public function testSetUrl(): void
{
$url = new Url('http://jwage.com');
$this->assertEquals('http://jwage.com/', $url->getUrl());
@@ -166,14 +167,14 @@ public function testSetUrl() : void
$this->assertEquals('http://google.com/', $url->getUrl());
}
- public function testArrayAccess() : void
+ public function testArrayAccess(): void
{
$url = new Url('http://jwage.com');
$url['path'] = 'about';
$this->assertEquals('http://jwage.com/about', (string) $url);
}
- public function testCanonicalization() : void
+ public function testCanonicalization(): void
{
$url = new Url('http://jwage.com');
$this->assertEquals('com.jwage', $url->canonical);
@@ -185,7 +186,7 @@ public function testCanonicalization() : void
$this->assertEquals('uk.co.jwage.domain.sub/index.php?param1=value1', $url->canonical);
}
- public function testPath() : void
+ public function testPath(): void
{
$url = new Url('http://jwage.com');
$url->path->add('about')->add('me');
@@ -194,7 +195,7 @@ public function testPath() : void
$this->assertEquals('http://jwage.com/new/path', (string) $url);
}
- public function testFragment() : void
+ public function testFragment(): void
{
$url = new Url('http://jwage.com');
$url->fragment = 'test';
@@ -207,7 +208,7 @@ public function testFragment() : void
$this->assertEquals('param1=value1', (string) $url->fragment->query);
}
- public function testQuery() : void
+ public function testQuery(): void
{
$url = new Url('http://jwage.com');
$url->query = 'param1=value1¶m2=value2';
@@ -216,7 +217,7 @@ public function testQuery() : void
$this->assertEquals('param1=value1¶m2=value2¶m3=value3', (string) $url->query);
}
- public function testIsAbsolute() : void
+ public function testIsAbsolute(): void
{
$url1 = new Url('http://jwage.com');
$this->assertTrue($url1->isAbsolute());
@@ -225,20 +226,20 @@ public function testIsAbsolute() : void
$this->assertFalse($url2->isAbsolute());
}
- public function testGetResource() : void
+ public function testGetResource(): void
{
$url = new Url('http://jwage.com/about?query=value');
$this->assertEquals('/about?query=value', $url->resource);
}
- public function testPort() : void
+ public function testPort(): void
{
$url = new Url('http://jwage.com:443');
$this->assertEquals('443', $url->port);
$this->assertEquals('http://jwage.com:443/', (string) $url);
}
- public function testAuth() : void
+ public function testAuth(): void
{
$url = new Url('http://user:pass@jwage.com');
$this->assertEquals('user', $url->user);
@@ -256,7 +257,7 @@ public function testAuth() : void
$this->assertEquals('http://user@jwage.com/', (string) $url);
}
- public function testExtract() : void
+ public function testExtract(): void
{
$urls = Url::extract("test\nmore test https://google.com ftp://jwage.com ftps://jwage.com http://google.com\ntesting this out http://jwage.com more text https://we-are-a-professional-studio-of.photography");
$this->assertEquals(6, count($urls));
@@ -268,7 +269,7 @@ public function testExtract() : void
$this->assertEquals('https://we-are-a-professional-studio-of.photography/', (string) $urls[5]);
}
- public function testManualObjectConstruction() : void
+ public function testManualObjectConstruction(): void
{
$url = new Url('http://jwage.com');
$url->set('path', new Path('about'));
@@ -277,7 +278,7 @@ public function testManualObjectConstruction() : void
$this->assertEquals('http://jwage.com/about?param=value#about?param=value', (string) $url);
}
- public function testIdeGettersAndSetters() : void
+ public function testIdeGettersAndSetters(): void
{
$url = new Url('http://jwage.com');
$url->setPath(new Path('about'));
@@ -286,7 +287,7 @@ public function testIdeGettersAndSetters() : void
$this->assertEquals('http://jwage.com/about?param=value#about?param=value', (string) $url);
}
- public function testFromCurrentServerVariables() : void
+ public function testFromCurrentServerVariables(): void
{
$_SERVER['HTTP_HOST'] = 'jwage.com';
$_SERVER['SERVER_PORT'] = 80;
@@ -335,7 +336,7 @@ public function testFromCurrentServerVariables() : void
$this->assertEquals('http://user:passwd123@jwage.com/', (string) $url);
}
- public function testRelativeUrl() : void
+ public function testRelativeUrl(): void
{
// test all resource parts
$url = new Url('/path1/path2?x=1&y=2#frag');
@@ -364,7 +365,7 @@ class TestParser implements ParserInterface
*
* @return mixed[]
*/
- public function parseUrl($url) : array
+ public function parseUrl($url): array
{
return [];
}