Skip to content

Commit

Permalink
cs fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dpi committed Mar 8, 2021
1 parent 32aed29 commit 36ee100
Show file tree
Hide file tree
Showing 14 changed files with 127 additions and 130 deletions.
8 changes: 2 additions & 6 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,7 @@
<exclude-pattern>src/Purl/AbstractPart.php</exclude-pattern>
</rule>

<rule ref="SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingParameterTypeHint">
<exclude-pattern>src/Purl/AbstractPart.php</exclude-pattern>
</rule>

<rule ref="SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingReturnTypeHint">
<exclude-pattern>src/Purl/AbstractPart.php</exclude-pattern>
<rule ref="SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingNativeTypeHint">
<severity>0</severity>
</rule>
</ruleset>
38 changes: 17 additions & 21 deletions src/Purl/AbstractPart.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ abstract class AbstractPart implements ArrayAccess
/**
* @return mixed[]
*/
public function getData() : array
public function getData(): array
{
$this->initialize();

Expand All @@ -35,19 +35,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();

Expand All @@ -67,7 +67,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;
Expand All @@ -78,15 +78,15 @@ 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;

return $this;
}

public function remove(string $key) : AbstractPart
public function remove(string $key): AbstractPart
{
$this->initialize();

Expand All @@ -95,7 +95,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);
}
Expand All @@ -111,20 +111,20 @@ public function __get(string $key)
/**
* @param mixed $value
*/
public function __set(string $key, $value) : AbstractPart
public function __set(string $key, $value): void
{
return $this->set($key, $value);
$this->set($key, $value);
}

public function __unset(string $key) : void
public function __unset(string $key): void
{
$this->remove($key);
}

/**
* @param mixed $key
*/
public function offsetExists($key) : bool
public function offsetExists($key): bool
{
$this->initialize();

Expand All @@ -144,25 +144,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;
Expand All @@ -189,7 +185,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;
}
18 changes: 9 additions & 9 deletions src/Purl/Fragment.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ 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);

return $this;
}

public function getFragment() : string
public function getFragment(): string
{
$this->initialize();

Expand All @@ -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 = [];
Expand All @@ -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);
Expand Down
5 changes: 3 additions & 2 deletions src/Purl/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Purl;

use InvalidArgumentException;

use function array_merge;
use function array_reverse;
use function explode;
Expand Down Expand Up @@ -36,7 +37,7 @@ class Parser implements ParserInterface
*
* @return mixed[]
*/
public function parseUrl($url) : array
public function parseUrl($url): array
{
$url = (string) $url;

Expand Down Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion src/Purl/ParserInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ interface ParserInterface
*
* @return mixed[]
*/
public function parseUrl($url) : array;
public function parseUrl($url): array;
}
10 changes: 5 additions & 5 deletions src/Purl/Path.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function __construct(?string $path = null)
$this->path = $path;
}

public function getPath() : string
public function getPath(): string
{
$this->initialize();

Expand All @@ -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;
Expand All @@ -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);
}
Expand Down
8 changes: 4 additions & 4 deletions src/Purl/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,25 @@ 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);

Expand Down
Loading

0 comments on commit 36ee100

Please sign in to comment.