Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#15 nette/http 3.1.6 compatibility #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"require": {
"php": ">=7.1",
"nette/di": "^3.0-RC1@dev",
"nette/http": "^3.0@dev"
"nette/http": "^3.1.6"
},
"require-dev": {
"nette/utils": "^3.0@dev",
Expand Down
40 changes: 29 additions & 11 deletions src/SessionSection.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,30 @@ public function getIterator(): Iterator
return new ArrayIterator($this->data);
}

/**
* @param string $name
* @param mixed $value
*/

/** @param mixed $value */
public function set(string $name, $value, ?string $expiration = NULL): void
{
if ($value === NULL) {
$this->remove($name);
} else {
$this->__set($name, $value);
}
}

/** @return mixed */
public function get(string $name)
{
return $this->__get($name);
}

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

/**
* @param string $name
* @return mixed
*/
/** @return mixed */
public function &__get(string $name)
{
if ($this->warnOnUndefined && !array_key_exists($name, $this->data)) {
Expand All @@ -62,7 +73,7 @@ public function __isset(string $name): bool

public function __unset(string $name): void
{
unset($this->data[$name]);
$this->remove($name);
}

/**
Expand All @@ -82,9 +93,16 @@ public function removeExpiration($variables = NULL): void
{
}

public function remove(): void
/** @param string|string[]|null $name */
public function remove($name = null): void
{
$this->data = [];
if ($name !== NULL) {
foreach ((array) $name as $name) {
unset($this->data[$name]);
}
} else {
$this->data = [];
}
}

}