Skip to content

Commit 687edd8

Browse files
authored
Review code (#44)
* add tests files in linter * encapsulate Exception into SessionException * add tests about SessionException * explain codeCoverageIgnore * remove token for codecov * remove option --no-suggest from github action * use multiple php versions (7.4, 8.0) for github action * add functions setLengthSessionID and getLengthSessionID * update README with session options * update comments on Session handler
1 parent 994aa88 commit 687edd8

29 files changed

Lines changed: 1171 additions & 951 deletions

‎.editorconfig‎

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

‎.github/workflows/test.yml‎

Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,37 @@
11
name: test
22

33
on:
4-
push:
5-
pull_request:
4+
push:
5+
pull_request:
66

77
jobs:
8-
test:
9-
runs-on: ubuntu-latest
10-
steps:
11-
- name: Checkout
12-
uses: actions/checkout@v2
13-
- name: Pull
14-
run: docker-compose pull --quiet
15-
- name: Build
16-
run: docker-compose build
17-
- name: Test
18-
run: docker-compose run lib composer ci
19-
- name: Upload coverage
20-
uses: codecov/codecov-action@v1.3.2
21-
if: success()
22-
with:
23-
token: ${{ secrets.CODECOV_TOKEN }}
24-
file: ./coverage/clover.xml
8+
test:
9+
runs-on: ${{ matrix.os }}
10+
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
os:
15+
- ubuntu-latest
16+
php-version:
17+
- '7.4'
18+
- '8.0'
19+
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v2
23+
24+
- name: Pull
25+
run: docker-compose pull --quiet
26+
27+
- name: Build
28+
run: docker-compose build --build-arg PHPVERSION=${{ matrix.php-version }}
29+
30+
- name: Test
31+
run: docker-compose run lib composer ci
32+
33+
- name: Upload coverage
34+
uses: codecov/codecov-action@v1.3.2
35+
if: success()
36+
with:
37+
file: ./coverage/clover.xml

‎.php_cs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22
$finder = PhpCsFixer\Finder::create()
33
->in(__DIR__ . '/src')
4+
->in(__DIR__ . '/tests')
45
;
56
return PhpCsFixer\Config::create()
67
->setRiskyAllowed(true)

‎Dockerfile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ WORKDIR /app
1515
COPY composer.json .
1616
COPY composer.lock .
1717
RUN composer validate
18-
RUN composer install --no-interaction --no-progress --no-suggest
18+
RUN composer install --no-interaction --no-progress
1919

2020
COPY . .
2121

‎README.md‎

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ Session::useCurrentRedisDriver($redis);
9090
Session::set('key', 'value');
9191
$value = Session::get('key');
9292
```
93-
With your own driver implementing SessionHandlerInterface
93+
With your own driver implementing `SessionHandlerInterface` and/or `SessionUpdateTimestampHandlerInterface`
9494
```php
9595
$driver = new MyCustomDriver();
9696
Session::useCustomDriver($driver);
@@ -147,28 +147,72 @@ When flash data is restore, it will be delete in $_SESSION.
147147
#### Static PHP Session Default Driver
148148
* useDefaultDriver(): void
149149
* useDefaultEncryptionDriver(key: string, [method: string|null = null]): void
150+
* setLengthSessionID(length: int): void
151+
* getLengthSessionID(): int
150152

151153
#### Static File Driver
152154
* useFileDriver(): void
153155
* useFileEncryptionDriver(key: string, [method: string|null = null]): void
154156
* setPrefixForFile(prefix: string): void
157+
* setLengthSessionID(length: int): void
158+
* getLengthSessionID(): int
155159

156160
#### Static Database Driver
157161
* useNewDatabaseDriver(configuration: \Rancoud\Database\Configurator|array): void
158162
* useCurrentDatabaseDriver(databaseInstance: \Rancoud\Database\Database): void
159163
* useNewDatabaseEncryptionDriver(configuration: \Rancoud\Database\Configurator|array, key: string, [method: string = null]): void
160164
* useCurrentDatabaseEncryptionDriver(databaseInstance: \Rancoud\Database\Database, key: string, [method: string = null]): void
161165
* setUserIdForDatabase(userId: int): void
166+
* setLengthSessionID(length: int): void
167+
* getLengthSessionID(): int
162168

163169
#### Static Redis Driver
164170
* useNewRedisDriver(configuration: array|string): void
165171
* useCurrentRedisDriver(redisInstance: \Predis\Client): void
166172
* useNewRedisEncryptionDriver(configuration: array|string, key: string, [method: string = null]): void
167173
* useCurrentRedisEncryptionDriver(redisInstance: \Predis\Client, key: string, [method: string = null]): void
174+
* setLengthSessionID(length: int): void
175+
* getLengthSessionID(): int
168176

169177
#### Static Custom Driver
170178
* useCustomDriver(customDriver: \SessionHandlerInterface): void
171179

180+
## Session options
181+
List of session options you can change:
182+
* save_path
183+
* name
184+
* save_handler
185+
* auto_start
186+
* gc_probability
187+
* gc_divisor
188+
* gc_maxlifetime
189+
* serialize_handler
190+
* cookie_lifetime
191+
* cookie_path
192+
* cookie_domain
193+
* cookie_secure
194+
* cookie_httponly
195+
* cookie_samesite
196+
* use_strict_mode
197+
* use_cookies
198+
* use_only_cookies
199+
* referer_check
200+
* cache_limiter
201+
* cache_expire
202+
* use_trans_sid
203+
* trans_sid_tags
204+
* trans_sid_hosts
205+
* sid_length
206+
* sid_bits_per_character
207+
* upload_progress.enabled
208+
* upload_progress.cleanup
209+
* upload_progress.prefix
210+
* upload_progress.name
211+
* upload_progress.freq
212+
* upload_progress.min_freq
213+
* lazy_write
214+
* read_and_close
215+
172216
## Driver Informations
173217
### Default
174218
Use SessionHandler

‎composer.json‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,16 @@
1515
"Rancoud\\Session\\": "src"
1616
}
1717
},
18+
"autoload-dev": {
19+
"psr-4": {
20+
"tests\\": "tests"
21+
}
22+
},
1823
"require": {
1924
"php": ">=7.4.0",
20-
"ext-openssl": ">=7.4.0"
25+
"ext-openssl": "*",
26+
"ext-session": "*",
27+
"ext-mbstring": "*"
2128
},
2229
"require-dev": {
2330
"friendsofphp/php-cs-fixer": "^2.16",
@@ -36,7 +43,7 @@
3643
"php-cs-fixer fix"
3744
],
3845
"test": [
39-
"phpdbg -qrr vendor/bin/phpunit --colors --coverage-text --coverage-clover ./coverage/clover.xml"
46+
"phpdbg -qrr vendor/bin/phpunit --colors --coverage-html ./coverage --coverage-text --coverage-clover ./coverage/clover.xml"
4047
]
4148
}
4249
}

‎composer.lock‎

Lines changed: 22 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎phpcs.xml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<arg value="p"/>
77

88
<file>src</file>
9+
<file>tests</file>
910

1011
<rule ref="PSR2"/>
1112

0 commit comments

Comments
 (0)