Skip to content

Commit

Permalink
Nette 3.0 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
matej21 committed Apr 8, 2019
1 parent 1ce7b70 commit 1fec7d8
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 36 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"license": "MIT",
"require": {
"php": "~7.1",
"nette/http": "~2.4"
"nette/http": "~3.0"
},
"require-dev": {
"phpstan/phpstan-shim": "~0.9",
Expand Down
2 changes: 1 addition & 1 deletion src/Bridges/Infrastructure/HttpMocksContainerHook.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Mangoweb\Tester\HttpMocks\Session;
use Mangoweb\Tester\Infrastructure\Container\AppContainerHook;
use Nette\DI\ContainerBuilder;
use Nette\DI\Statement;
use Nette\DI\Definitions\Statement;
use Nette\Http\Request;
use Nette\Http\UrlScript;

Expand Down
12 changes: 9 additions & 3 deletions src/HttpRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function setRawBody(?string $body)
}


public function getRawBody()
public function getRawBody(): ?string
{
return $this->body ?? parent::getRawBody();
}
Expand All @@ -32,7 +32,7 @@ public function setHeader(string $name, string $value)
}


public function getHeader($header, $default = NULL)
public function getHeader(string $header, $default = NULL): ?string
{
if (isset($this->headers[$header])) {
return $this->headers[$header];
Expand All @@ -41,8 +41,14 @@ public function getHeader($header, $default = NULL)
}


public function getHeaders()
public function getHeaders(): array
{
return array_merge(parent::getHeaders(), $this->headers);
}


public function isSameSite(): bool
{
return TRUE;
}
}
43 changes: 19 additions & 24 deletions src/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,31 +26,31 @@ public function __construct()
}


public function start()
public function start(): void
{
$this->started = TRUE;
}


public function isStarted()
public function isStarted(): bool
{
return $this->started;
}


public function close()
public function close(): void
{
$this->started = FALSE;
}


public function destroy()
public function destroy(): void
{
$this->started = FALSE;
}


public function exists()
public function exists(): bool
{
return $this->exists;
}
Expand All @@ -62,12 +62,12 @@ public function setFakeExists(bool $exists): void
}


public function regenerateId()
public function regenerateId(): void
{
}


public function getId()
public function getId(): string
{
return $this->id;
}
Expand All @@ -79,7 +79,7 @@ public function setFakeId($id)
}


public function getSection($section, $class = SessionSection::class)
public function getSection(string $section, $class = SessionSection::class): Nette\Http\SessionSection
{
if (isset($this->sections[$section])) {
return $this->sections[$section];
Expand All @@ -92,30 +92,30 @@ public function getSection($section, $class = SessionSection::class)
}


public function hasSection($section)
public function hasSection(string $section): bool
{
return isset($this->sections[$section]);
}


public function getIterator()
public function getIterator(): \Iterator
{
return new \ArrayIterator(array_keys($this->sections));
}


public function clean()
public function clean(): void
{
}


public function setName($name)
public function setName(string $name)
{
return $this;
}


public function getName()
public function getName(): string
{
return '';
}
Expand All @@ -127,41 +127,36 @@ public function setOptions(array $options)
}


public function getOptions()
public function getOptions(): array
{
return [];
}


public function setExpiration($time)
public function setExpiration(?string $time)
{
return $this;
}


public function setCookieParameters($path, $domain = NULL, $secure = NULL, $samesite = NULL)
public function setCookieParameters(string $path, string $domain = NULL, bool $secure = NULL, string $samesite = NULL)
{
return $this;
}


public function getCookieParameters()
public function getCookieParameters(): array
{
return NULL;
return [];
}


public function setSavePath($path)
public function setSavePath(string $path)
{
return $this;
}


public function setStorage(Nette\Http\ISessionStorage $storage)
{
}


public function setHandler(\SessionHandlerInterface $handler)
{
}
Expand Down
14 changes: 7 additions & 7 deletions src/SessionSection.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@ public function __construct(Nette\Http\Session $session, $name)
}


public function getIterator()
public function getIterator(): \Iterator
{
return new \ArrayIterator($this->data);
}


public function __set($name, $value)
public function __set(string $name, $value): void
{
$this->data[$name] = $value;
}


public function &__get($name)
public function &__get(string $name)
{
if ($this->warnOnUndefined && !array_key_exists($name, $this->data)) {
trigger_error("The variable '$name' does not exist in session section", E_USER_NOTICE);
Expand All @@ -39,13 +39,13 @@ public function &__get($name)
}


public function __isset($name)
public function __isset(string $name): bool
{
return isset($this->data[$name]);
}


public function __unset($name)
public function __unset(string $name): void
{
unset($this->data[$name]);
}
Expand All @@ -57,12 +57,12 @@ public function setExpiration($time, $variables = NULL)
}


public function removeExpiration($variables = NULL)
public function removeExpiration($variables = NULL): void
{
}


public function remove()
public function remove(): void
{
$this->data = [];
}
Expand Down

0 comments on commit 1fec7d8

Please sign in to comment.