Skip to content

Commit

Permalink
Merge pull request #22 from karriereat/dev/php-82
Browse files Browse the repository at this point in the history
Add PHP 8.2. Support
  • Loading branch information
lentex authored Mar 1, 2023
2 parents 244c21b + f213338 commit daec83b
Show file tree
Hide file tree
Showing 23 changed files with 467 additions and 460 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: CI

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:

strategy:
fail-fast: true
matrix:
php: [ "8.0", "8.1", "8.2" ]

runs-on: ubuntu-latest
name: PHP@${{ matrix.php }}

steps:
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}

- uses: actions/checkout@v3

- name: Validate composer.json and composer.lock
run: composer validate

- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-suggest

- name: Lint code
run: composer run-script lint

- name: Analyse code
run: composer run-script analyse

- name: Test code
run: composer run-script test
34 changes: 0 additions & 34 deletions .github/workflows/lint.yml

This file was deleted.

34 changes: 0 additions & 34 deletions .github/workflows/test.yml

This file was deleted.

4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ build/
coverage/
coverage.xml
composer.lock
.php_cs.cache
.phpunit.result.cache
.phpunit.result.cache
junit.xml
28 changes: 0 additions & 28 deletions .php_cs

This file was deleted.

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

## [3.0.0] - 2023-03-01
### Added
- Support for PHP 8.2.
- Support for `illuminate/support` and `illuminate/session` version `^10.0`
- Static analysis
- [BREAKING] Return types and type hint

### Changed
- Linting to `pint`
- Unit tests to `pest`

### Removed
- Support for PHP 7.4.
- Support for `illuminate/support` and `illuminate/session` version < `^9.0`

## [2.2.0] - 2022-03-24
## Added
### Added
- Support for `illuminate/support` and `illuminate/session` version `^9.0`

## [2.1.0] - 2021-10-20
## Added
### Added
- Support for PHP 8

## [2.0.0] - 2020-10-06
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<a href="https://www.karriere.at/" target="_blank"><img width="200" src="https://raw.githubusercontent.com/karriereat/.github/main/profile/logo.svg"></a>
<span>&nbsp;&nbsp;&nbsp;</span>
![](https://github.com/karriereat/state/workflows/test/badge.svg)
![](https://github.com/karriereat/state/workflows/lint/badge.svg)
![](https://github.com/karriereat/state/workflows/CI/badge.svg)
[![Packagist Downloads](https://img.shields.io/packagist/dt/karriere/state.svg?style=flat-square)](https://packagist.org/packages/karriere/state)

# State package for Laravel
Expand Down
92 changes: 92 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# Upgrade Guide

## v2 to v3
Most likely this new major version does not contain any breaking changes. Only potential for breaking changes
are return types and type hints.

### Constructor signature changes

#### State.php
```php
// Before
public function __construct($identifier, $name, $data) {}

// After
public function __construct(private string $identifier, private string $name, private array $data) {}
```

#### Stores/CacheStore.php
```php
// Before
public function __construct($statePrefix, CacheItemPoolInterface $cacheItemPool, $expiresAfter = 300) {}

// After
public function __construct(
string $statePrefix,
private CacheItemPoolInterface $cacheItemPool,
private int $expiresAfter = 300,
) {}
```

#### Stores/SessionStore.php
```php
// Before
public function __construct($statePrefix, Session $session) {}

// After
public function __construct(string $statePrefix, private Session $session) {}
```

#### Stores/Store.php
```php
// Before
public function __construct($statePrefix) {}

// After
public function __construct(protected string $statePrefix) {}
```

### Signature changes of public methods

#### Factories/StateFactory.php
```php
// Before
public function build($name, $data) {}

// After
public function build(string $name, array $data): State {}
```

#### State.php
```php
// Before
public function identifier() {}
public function name() {}
public function hasName($name) {}
public function set($data) {}
public function isEmpty() {}
public function raw() {}
public function collection() {}

// After
public function identifier(): string {}
public function name(): string {}
public function hasName(string $name): bool {}
public function set(array $data): void {}
public function isEmpty(): bool {}
public function raw(): array {}
public function collection(): Collection {}
```

#### All "Store classes" (`Stores/*Store.php`)
```php
// Before
public function put(State $state) {}
public function get($identifier, $keepState = false) {}
protected function getStoreKey($identifier) {}

// After
public function put(State $state): void {}
public function get(string $identifier, bool $keepState = false): State {}
protected function getStoreKey(string $identifier): string {}
```
37 changes: 24 additions & 13 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"homepage": "https://github.com/karriereat/state",
"authors": [
{
"name": "Johannes Pichler",
"email": "johannes.pichler@karriere.at"
"name": "Alexander Lentner",
"email": "alexander.lentner@karriere.at"
}
],
"keywords": [
Expand All @@ -19,15 +19,16 @@
],
"license": "Apache-2.0",
"require": {
"php": "^7.4 | ^8.0",
"illuminate/support": "^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.0",
"illuminate/session": "^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.0",
"php": "8.0.* | 8.1.* | 8.2.*",
"illuminate/support": "^9.0 || ^10.0",
"illuminate/session": "^9.0 || ^10.0",
"psr/cache": "^1.0"
},
"require-dev": {
"phpunit/phpunit": "^7.0 || ^8.0 || ^9.0",
"friendsofphp/php-cs-fixer": "^2.0",
"mockery/mockery": "^1.0"
"mockery/mockery": "^1.0",
"pestphp/pest": "^1.22",
"laravel/pint": "^1.5 | ^1.6",
"phpstan/phpstan": "^1.10"
},
"extra": {
"laravel": {
Expand All @@ -49,11 +50,21 @@
"Karriere\\State\\Tests\\": "tests/"
}
},
"minimum-stability": "stable",
"scripts": {
"test": "phpunit",
"coverage": "phpunit --coverage-clover coverage.xml",
"lint": "php-cs-fixer fix -v --dry-run",
"fix": "php-cs-fixer fix -v"
"analyse": "phpstan analyse --memory-limit 512M",
"lint": "pint --test",
"lint:verbose": "pint -v --test",
"fix": "pint",
"test": "vendor/bin/pest",
"coverage": "vendor/bin/pest --coverage --ci --coverage-html coverage --coverage-clover coverage.xml --log-junit junit.xml",
"report": "vendor/bin/pest --coverage",
"report:html": "vendor/bin/pest --coverage --coverage-html coverage"
},
"minimum-stability": "stable",
"config": {
"allow-plugins": {
"pestphp/pest-plugin": true
},
"sort-packages": true
}
}
7 changes: 7 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
parameters:
paths:
- src
level: max
checkGenericClassInNonGenericObjectType: false
excludePaths:
- src/StateServiceProvider.php
23 changes: 23 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true"
verbose="true"
convertDeprecationsToExceptions="true"
>
<testsuites>
<testsuite name="State Test Suite">
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">./src</directory>
</include>
<exclude>
<file>./src/StateServiceProvider.php</file>
<file>./src/StoreFacade.php</file>
</exclude>
</coverage>
</phpunit>
13 changes: 0 additions & 13 deletions phpunit.xml.dist

This file was deleted.

Loading

0 comments on commit daec83b

Please sign in to comment.