Skip to content

Commit

Permalink
Merge pull request #1 from woytam/issue-15-nette-http-compatibility
Browse files Browse the repository at this point in the history
Kdyby#15 nette/http 3.1.6 compatibility
  • Loading branch information
woytam authored Apr 14, 2023
2 parents 0a30f29 + 5ce8e3a commit c4e2329
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 12 deletions.
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 = [];
}
}

}

0 comments on commit c4e2329

Please sign in to comment.