Skip to content

Commit daec83b

Browse files
authored
Merge pull request #22 from karriereat/dev/php-82
Add PHP 8.2. Support
2 parents 244c21b + f213338 commit daec83b

23 files changed

+467
-460
lines changed

.github/workflows/ci.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
build:
11+
12+
strategy:
13+
fail-fast: true
14+
matrix:
15+
php: [ "8.0", "8.1", "8.2" ]
16+
17+
runs-on: ubuntu-latest
18+
name: PHP@${{ matrix.php }}
19+
20+
steps:
21+
- uses: shivammathur/setup-php@v2
22+
with:
23+
php-version: ${{ matrix.php }}
24+
25+
- uses: actions/checkout@v3
26+
27+
- name: Validate composer.json and composer.lock
28+
run: composer validate
29+
30+
- name: Install dependencies
31+
run: composer install --prefer-dist --no-progress --no-suggest
32+
33+
- name: Lint code
34+
run: composer run-script lint
35+
36+
- name: Analyse code
37+
run: composer run-script analyse
38+
39+
- name: Test code
40+
run: composer run-script test

.github/workflows/lint.yml

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

.github/workflows/test.yml

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

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ build/
33
coverage/
44
coverage.xml
55
composer.lock
6-
.php_cs.cache
7-
.phpunit.result.cache
6+
.phpunit.result.cache
7+
junit.xml

.php_cs

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

CHANGELOG.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,27 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [3.0.0] - 2023-03-01
8+
### Added
9+
- Support for PHP 8.2.
10+
- Support for `illuminate/support` and `illuminate/session` version `^10.0`
11+
- Static analysis
12+
- [BREAKING] Return types and type hint
13+
14+
### Changed
15+
- Linting to `pint`
16+
- Unit tests to `pest`
17+
18+
### Removed
19+
- Support for PHP 7.4.
20+
- Support for `illuminate/support` and `illuminate/session` version < `^9.0`
21+
722
## [2.2.0] - 2022-03-24
8-
## Added
23+
### Added
924
- Support for `illuminate/support` and `illuminate/session` version `^9.0`
1025

1126
## [2.1.0] - 2021-10-20
12-
## Added
27+
### Added
1328
- Support for PHP 8
1429

1530
## [2.0.0] - 2020-10-06

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<a href="https://www.karriere.at/" target="_blank"><img width="200" src="https://raw.githubusercontent.com/karriereat/.github/main/profile/logo.svg"></a>
22
<span>&nbsp;&nbsp;&nbsp;</span>
3-
![](https://github.com/karriereat/state/workflows/test/badge.svg)
4-
![](https://github.com/karriereat/state/workflows/lint/badge.svg)
3+
![](https://github.com/karriereat/state/workflows/CI/badge.svg)
54
[![Packagist Downloads](https://img.shields.io/packagist/dt/karriere/state.svg?style=flat-square)](https://packagist.org/packages/karriere/state)
65

76
# State package for Laravel

UPGRADE.md

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# Upgrade Guide
2+
3+
## v2 to v3
4+
Most likely this new major version does not contain any breaking changes. Only potential for breaking changes
5+
are return types and type hints.
6+
7+
### Constructor signature changes
8+
9+
#### State.php
10+
```php
11+
// Before
12+
public function __construct($identifier, $name, $data) {}
13+
14+
// After
15+
public function __construct(private string $identifier, private string $name, private array $data) {}
16+
```
17+
18+
#### Stores/CacheStore.php
19+
```php
20+
// Before
21+
public function __construct($statePrefix, CacheItemPoolInterface $cacheItemPool, $expiresAfter = 300) {}
22+
23+
// After
24+
public function __construct(
25+
string $statePrefix,
26+
private CacheItemPoolInterface $cacheItemPool,
27+
private int $expiresAfter = 300,
28+
) {}
29+
```
30+
31+
#### Stores/SessionStore.php
32+
```php
33+
// Before
34+
public function __construct($statePrefix, Session $session) {}
35+
36+
// After
37+
public function __construct(string $statePrefix, private Session $session) {}
38+
```
39+
40+
#### Stores/Store.php
41+
```php
42+
// Before
43+
public function __construct($statePrefix) {}
44+
45+
// After
46+
public function __construct(protected string $statePrefix) {}
47+
```
48+
49+
### Signature changes of public methods
50+
51+
#### Factories/StateFactory.php
52+
```php
53+
// Before
54+
public function build($name, $data) {}
55+
56+
// After
57+
public function build(string $name, array $data): State {}
58+
```
59+
60+
#### State.php
61+
```php
62+
// Before
63+
public function identifier() {}
64+
public function name() {}
65+
public function hasName($name) {}
66+
public function set($data) {}
67+
public function isEmpty() {}
68+
public function raw() {}
69+
public function collection() {}
70+
71+
// After
72+
public function identifier(): string {}
73+
public function name(): string {}
74+
public function hasName(string $name): bool {}
75+
public function set(array $data): void {}
76+
public function isEmpty(): bool {}
77+
public function raw(): array {}
78+
public function collection(): Collection {}
79+
```
80+
81+
#### All "Store classes" (`Stores/*Store.php`)
82+
```php
83+
// Before
84+
public function put(State $state) {}
85+
public function get($identifier, $keepState = false) {}
86+
protected function getStoreKey($identifier) {}
87+
88+
// After
89+
public function put(State $state): void {}
90+
public function get(string $identifier, bool $keepState = false): State {}
91+
protected function getStoreKey(string $identifier): string {}
92+
```

composer.json

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
"homepage": "https://github.com/karriereat/state",
55
"authors": [
66
{
7-
"name": "Johannes Pichler",
8-
"email": "johannes.pichler@karriere.at"
7+
"name": "Alexander Lentner",
8+
"email": "alexander.lentner@karriere.at"
99
}
1010
],
1111
"keywords": [
@@ -19,15 +19,16 @@
1919
],
2020
"license": "Apache-2.0",
2121
"require": {
22-
"php": "^7.4 | ^8.0",
23-
"illuminate/support": "^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.0",
24-
"illuminate/session": "^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.0",
22+
"php": "8.0.* | 8.1.* | 8.2.*",
23+
"illuminate/support": "^9.0 || ^10.0",
24+
"illuminate/session": "^9.0 || ^10.0",
2525
"psr/cache": "^1.0"
2626
},
2727
"require-dev": {
28-
"phpunit/phpunit": "^7.0 || ^8.0 || ^9.0",
29-
"friendsofphp/php-cs-fixer": "^2.0",
30-
"mockery/mockery": "^1.0"
28+
"mockery/mockery": "^1.0",
29+
"pestphp/pest": "^1.22",
30+
"laravel/pint": "^1.5 | ^1.6",
31+
"phpstan/phpstan": "^1.10"
3132
},
3233
"extra": {
3334
"laravel": {
@@ -49,11 +50,21 @@
4950
"Karriere\\State\\Tests\\": "tests/"
5051
}
5152
},
52-
"minimum-stability": "stable",
5353
"scripts": {
54-
"test": "phpunit",
55-
"coverage": "phpunit --coverage-clover coverage.xml",
56-
"lint": "php-cs-fixer fix -v --dry-run",
57-
"fix": "php-cs-fixer fix -v"
54+
"analyse": "phpstan analyse --memory-limit 512M",
55+
"lint": "pint --test",
56+
"lint:verbose": "pint -v --test",
57+
"fix": "pint",
58+
"test": "vendor/bin/pest",
59+
"coverage": "vendor/bin/pest --coverage --ci --coverage-html coverage --coverage-clover coverage.xml --log-junit junit.xml",
60+
"report": "vendor/bin/pest --coverage",
61+
"report:html": "vendor/bin/pest --coverage --coverage-html coverage"
62+
},
63+
"minimum-stability": "stable",
64+
"config": {
65+
"allow-plugins": {
66+
"pestphp/pest-plugin": true
67+
},
68+
"sort-packages": true
5869
}
5970
}

phpstan.neon

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
parameters:
2+
paths:
3+
- src
4+
level: max
5+
checkGenericClassInNonGenericObjectType: false
6+
excludePaths:
7+
- src/StateServiceProvider.php

0 commit comments

Comments
 (0)