Skip to content

Commit 1d5bae6

Browse files
committed
Merge branch 'develop'
* develop: specify next release fix documentation update documentation remove unused exception make Native constructor private Session\Id and Session\Name constructors are now private make the Session immutable add Session::maybe() make Session constructor private use mixed type instead of annotation update dependencies change email test against php 8.2 use ramsey/composer-install use CS 2 require php 8.1
2 parents 236c439 + 34a0b82 commit 1d5bae6

20 files changed

Lines changed: 373 additions & 364 deletions

.github/workflows/ci.yml

Lines changed: 10 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
strategy:
99
matrix:
1010
os: [ubuntu-latest, macOS-latest]
11-
php-version: ['7.4', '8.0']
11+
php-version: ['8.1', '8.2']
1212
name: 'PHPUnit'
1313
steps:
1414
- name: Checkout
@@ -20,17 +20,8 @@ jobs:
2020
extensions: mbstring, intl
2121
coverage: xdebug
2222
ini-values: xdebug.max_nesting_level=2048
23-
- name: Get Composer Cache Directory
24-
id: composer-cache
25-
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
26-
- name: Cache dependencies
27-
uses: actions/cache@v2
28-
with:
29-
path: ${{ steps.composer-cache.outputs.dir }}
30-
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
31-
restore-keys: ${{ runner.os }}-composer-
32-
- name: Install Dependencies
33-
run: composer install --no-progress
23+
- name: Composer
24+
uses: "ramsey/composer-install@v2"
3425
- name: PHPUnit
3526
run: vendor/bin/phpunit --coverage-clover=coverage.clover
3627
- uses: codecov/codecov-action@v1
@@ -40,7 +31,7 @@ jobs:
4031
runs-on: ubuntu-latest
4132
strategy:
4233
matrix:
43-
php-version: ['7.4', '8.0']
34+
php-version: ['8.1', '8.2']
4435
name: 'Psalm'
4536
steps:
4637
- name: Checkout
@@ -50,24 +41,15 @@ jobs:
5041
with:
5142
php-version: ${{ matrix.php-version }}
5243
extensions: mbstring, intl
53-
- name: Get Composer Cache Directory
54-
id: composer-cache
55-
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
56-
- name: Cache dependencies
57-
uses: actions/cache@v2
58-
with:
59-
path: ${{ steps.composer-cache.outputs.dir }}
60-
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
61-
restore-keys: ${{ runner.os }}-composer-
62-
- name: Install Dependencies
63-
run: composer install --no-progress
44+
- name: Composer
45+
uses: "ramsey/composer-install@v2"
6446
- name: Psalm
6547
run: vendor/bin/psalm --shepherd
6648
cs:
6749
runs-on: ubuntu-latest
6850
strategy:
6951
matrix:
70-
php-version: ['7.4']
52+
php-version: ['8.1']
7153
name: 'CS'
7254
steps:
7355
- name: Checkout
@@ -77,16 +59,7 @@ jobs:
7759
with:
7860
php-version: ${{ matrix.php-version }}
7961
extensions: mbstring, intl
80-
- name: Get Composer Cache Directory
81-
id: composer-cache
82-
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
83-
- name: Cache dependencies
84-
uses: actions/cache@v2
85-
with:
86-
path: ${{ steps.composer-cache.outputs.dir }}
87-
key: ${{ runner.os }}-${{ matrix.php-version }}-composer-${{ hashFiles('**/composer.json') }}
88-
restore-keys: ${{ runner.os }}-${{ matrix.php-version }}-composer-
89-
- name: Install Dependencies
90-
run: composer install --no-progress
62+
- name: Composer
63+
uses: "ramsey/composer-install@v2"
9164
- name: CS
92-
run: vendor/bin/php-cs-fixer fix --diff --dry-run --diff-format udiff
65+
run: vendor/bin/php-cs-fixer fix --diff --dry-run
File renamed without changes.

CHANGELOG.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Changelog
2+
3+
## 3.0.0 - 2023-01-14
4+
5+
### Added
6+
7+
- `Innmind\HttpSession\Session::maybe()`
8+
9+
### Changed
10+
11+
- `Innmind\HttpSession\Manager\Native` constructor is now private, use `::of()` named constructor instead
12+
- `Innmind\HttpSession\Session` is now immutable
13+
- `Innmind\HttpSession\Session\Id` is now immutable
14+
- `Innmind\HttpSession\Session\Name` is now immutable
15+
- `Innmind\HttpSession\Sesssion::set()` has been renamed to `::with()`
16+
- `Innmind\HttpSession\Manager::start()` now returns `Innmind\Immutable\Maybe<Innmind\HttpSession\Session>` instead of throwing
17+
- `Innmind\HttpSession\Manager::save()`
18+
- now expects the `Session` instead of the `Innmind\Http\Message\ServerRequest`
19+
- now returns `Innmind\Immutable\Maybe<Innmind\Immutable\SideEffect>` instead of throwing
20+
- `Innmind\HttpSession\Manager::close()`
21+
- now expects the `Session` instead of the `Innmind\Http\Message\ServerRequest`
22+
- now returns `Innmind\Immutable\Maybe<Innmind\Immutable\SideEffect>` instead of throwing
23+
- Require php 8.1
24+
25+
### Removed
26+
27+
- `Innmind\HttpSession\Manager::get()`
28+
- `Innmind\HttpSession\Manager::contains()`

README.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
Library to manage session for http requests.
88

9-
The goal is to break the paradigm of considering the request and response as a global environment. Request and response should be delt as transiting data. The session for a request should obey this principle as well, thus the signature `Manager::start(ServerRequest): Session`.
9+
The goal is to break the paradigm of considering the request and response as a global environment. Request and response should be delt as transiting data. The session for a request should obey this principle as well, thus the signature `Manager::start(ServerRequest): Maybe<Session>`.
1010

1111
## Installation
1212

@@ -20,6 +20,7 @@ composer require innmind/http-session
2020
use Innmind\HttpSession\Manager\Native;
2121
use Innmind\Http\{
2222
Message\Response\Response,
23+
Message\ServerRequest,
2324
Message\StatusCode,
2425
Headers,
2526
Header\SetCookie,
@@ -28,16 +29,18 @@ use Innmind\Http\{
2829
Header\Parameter\Parameter,
2930
};
3031

31-
$manager = new Native;
32-
$request = /* an instance of Innmind\Http\Message\ServerRequest */
32+
$manager = Native::of();
33+
$request = /* an instance of ServerRequest */
3334

34-
$session = $manager->start($request);
35+
$session = $manager->start($request)->match(
36+
static fn($session) => $session,
37+
static fn() => throw new \RuntimeException('Unable to start the exception'),
38+
);
3539
// inject some data in the session
36-
$manager->save($request);
40+
$manager->save($session);
3741

3842
$response = new Response(
39-
$code = StatusCode::of('OK'),
40-
$code->associatedReasonPhrase(),
43+
$code = StatusCode::ok,
4144
$request->protocolVersion(),
4245
Headers::of(
4346
SetCookie::of(

composer.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@
88
"authors": [
99
{
1010
"name": "Baptiste Langlade",
11-
"email": "langlade.baptiste@gmail.com"
11+
"email": "baptiste.langlade@hey.com"
1212
}
1313
],
1414
"support": {
1515
"issues": "http://github.com/Innmind/HttpSession/issues"
1616
},
1717
"require": {
18-
"php": "~7.4|~8.0",
19-
"innmind/immutable": "~3.5",
20-
"innmind/http": "~4.2"
18+
"php": "~8.1",
19+
"innmind/immutable": "~4.9",
20+
"innmind/http": "~5.3"
2121
},
2222
"autoload": {
2323
"psr-4": {
@@ -33,6 +33,6 @@
3333
"require-dev": {
3434
"phpunit/phpunit": "~9.0",
3535
"vimeo/psalm": "~4.4",
36-
"innmind/coding-standard": "^1.1"
36+
"innmind/coding-standard": "~2.0"
3737
}
3838
}

src/Exception/ConcurrentSessionNotSupported.php

Lines changed: 0 additions & 8 deletions
This file was deleted.

src/Exception/DomainException.php

Lines changed: 0 additions & 8 deletions
This file was deleted.

src/Exception/FailedToCloseSession.php

Lines changed: 0 additions & 8 deletions
This file was deleted.

src/Exception/FailedToSaveSession.php

Lines changed: 0 additions & 8 deletions
This file was deleted.

src/Exception/FailedToStartSession.php

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)