Skip to content
Merged
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
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"require": {
"php": "~8.2",
"innmind/immutable": "~4.9|~5.0",
"innmind/http": "~7.0"
"innmind/http": "~7.0",
"innmind/validation": "~1.0"
},
"autoload": {
"psr-4": {
Expand All @@ -32,7 +33,7 @@
},
"require-dev": {
"innmind/black-box": "^6.4.1",
"vimeo/psalm": "~5.12",
"innmind/static-analysis": "^1.2.1",
"innmind/coding-standard": "~2.0"
}
}
2 changes: 1 addition & 1 deletion src/Exception/LogicException.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@

namespace Innmind\HttpSession\Exception;

class LogicException extends \LogicException implements Exception
final class LogicException extends \LogicException implements Exception
{
}
13 changes: 12 additions & 1 deletion src/Manager/Native.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
Header\Cookie,
Header\CookieValue,
};
use Innmind\Validation\Is;
use Innmind\Url\Path;
use Innmind\Immutable\{
Map,
Expand All @@ -38,6 +39,7 @@ public static function of(?Path $save = null): self
return new self($save);
}

#[\Override]
public function start(ServerRequest $request): Maybe
{
if ($this->session instanceof Id) {
Expand All @@ -63,7 +65,14 @@ public function start(ServerRequest $request): Maybe
$values = ($values)($key, $value);
}

return Maybe::all(Id::maybe(\session_id()), Name::maybe(\session_name()))
return Maybe::all(
Maybe::just(\session_id())
->keep(Is::string()->asPredicate())
->flatMap(Id::maybe(...)),
Maybe::just(\session_name())
->keep(Is::string()->asPredicate())
->flatMap(Name::maybe(...)),
)
->map(static fn(Id $id, Name $name) => Session::of($id, $name, $values))
->map(function($session) {
$this->session = $session->id();
Expand All @@ -72,6 +81,7 @@ public function start(ServerRequest $request): Maybe
});
}

#[\Override]
public function save(Session $session): Maybe
{
if ($this->session !== $session->id()) {
Expand All @@ -97,6 +107,7 @@ public function save(Session $session): Maybe
return Maybe::just(new SideEffect);
}

#[\Override]
public function close(Session $session): Maybe
{
if ($this->session !== $session->id()) {
Expand Down
Loading