Skip to content

Commit

Permalink
Require PHP 8.1+
Browse files Browse the repository at this point in the history
  • Loading branch information
olvlvl committed Oct 3, 2023
1 parent 60e54de commit 7d5adf0
Show file tree
Hide file tree
Showing 114 changed files with 617 additions and 1,393 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ on:
jobs:
phpstan:
name: phpstan
runs-on: ubuntu-18.04
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: "7.1"
php-version: "8.1"
ini-values: memory_limit=-1
tools: composer:v2
- name: Cache dependencies
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
jobs:
phpunit:
name: phpunit
runs-on: ubuntu-18.04
runs-on: ubuntu-latest
services:
redis:
# Docker Hub image
Expand All @@ -24,8 +24,6 @@ jobs:
strategy:
matrix:
php-version:
- "7.1"
- "7.4"
- "8.1"
steps:
- name: Checkout
Expand Down Expand Up @@ -58,7 +56,7 @@ jobs:
ICANBOOGIE_CLDR_CHECK_URL: 'yes'

- name: Upload code coverage
if: ${{ matrix.php-version == '7.1' }}
if: ${{ matrix.php-version == '8.1' }}
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.phpunit.result.cache
.phpunit.cache
build
cache
composer.lock
Expand Down
File renamed without changes.
25 changes: 0 additions & 25 deletions Dockerfile71

This file was deleted.

52 changes: 52 additions & 0 deletions MIGRATION.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,31 @@
# Migration



## v5.x to v6.0

### New Requirements

- PHP >=8.1 <8.2

### New features

None

### Backward Incompatible Changes

None

### Deprecated Features

None

### Other Changes

None



## v4.x to v5.0

### New Requirements
Expand Down Expand Up @@ -168,3 +194,29 @@ None
- Compatible with PHP 8.1+
- Targets [CLDR v36](https://www.unicode.org/reports/tr35/tr35-57/tr35.html)
- Improved type annotations, including generics.

<!--
## vX.x to vX.x
### New Requirements
None
### New features
None
### Backward Incompatible Changes
None
### Deprecated Features
None
### Other Changes
None
-->
17 changes: 4 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ PHPUNIT = vendor/bin/phpunit

# do not edit the following lines

.PHONY: usage
usage:
@echo "test: Runs the test suite.\ndoc: Creates the documentation.\nclean: Removes the documentation, the dependencies and the Composer files."

vendor:
@composer install

Expand All @@ -24,7 +20,7 @@ test: test-dependencies
.PHONY: test-coverage
test-coverage: test-dependencies
@mkdir -p build/coverage
@XDEBUG_MODE=coverage $(PHPUNIT) --coverage-html build/coverage --coverage-text
@XDEBUG_MODE=coverage $(PHPUNIT) --coverage-html build/coverage

.PHONY: test-coveralls
test-coveralls: test-dependencies
Expand All @@ -36,22 +32,17 @@ test-cleanup:
@rm -f cache/*

.PHONY: test-container
test-container: test-container-71

.PHONY: test-container-71
test-container-71:
@-docker-compose run --rm app71 bash
@docker-compose down
test-container: test-container-81

.PHONY: test-container-81
test-container-81:
@-docker-compose run --rm app81 bash
@docker-compose down
@docker-compose down -v

.PHONY: test-container-82
test-container-82:
@-docker-compose run --rm app82 bash
@docker-compose down
@docker-compose down -v

.PHONY: lint
lint:
Expand Down
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@
"sort-packages": true
},
"require": {
"php": ">=7.1 <8.2",
"php": ">=8.1 <8.2",
"ext-curl": "*",
"ext-json": "*",
"ext-mbstring": "*",
"icanboogie/common": "^1.3",
"icanboogie/accessor": "^3.0|^4.0"
"icanboogie/common": "^2.0",
"icanboogie/accessor": "^4.0"
},
"require-dev": {
"ext-redis": "*",
"phpstan/phpstan": "^1.4",
"phpunit/phpunit": "^7.5.20|^8.5"
"phpstan/phpstan": "^1.10",
"phpunit/phpunit": "^10.3"
},
"autoload": {
"psr-4": {
Expand Down
19 changes: 2 additions & 17 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,25 +1,10 @@
---
version: "3.2"
services:
app71:
build:
context: .
dockerfile: Dockerfile71
environment:
PHP_IDE_CONFIG: 'serverName=icanboogie-cldr'
ICANBOOGIE_CLDR_REDIS_HOST: redis
ICANBOOGIE_CLDR_REDIS_PORT: 6379
depends_on:
- redis
volumes:
- .:/app:delegated
- ~/.composer:/root/.composer:delegated
working_dir: /app

app81:
build:
context: .
dockerfile: Dockerfile8
dockerfile: Dockerfile
args:
PHP_VERSION: '8.1'
environment:
Expand All @@ -36,7 +21,7 @@ services:
app82:
build:
context: .
dockerfile: Dockerfile8
dockerfile: Dockerfile
args:
PHP_VERSION: '8.2'
environment:
Expand Down
17 changes: 6 additions & 11 deletions lib/AbstractCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

use ArrayAccess;
use BadMethodCallException;
use Closure;

/**
* An abstract collection.
Expand All @@ -27,16 +28,11 @@ abstract class AbstractCollection implements ArrayAccess
/**
* @var array<string, T>
*/
private $collection = [];
private array $collection = [];

/**
* @var callable(string): T
*/
private $create_instance;

public function __construct(callable $create_instance)
{
$this->create_instance = $create_instance;
public function __construct(
private readonly Closure $create_instance
) {
}

/**
Expand All @@ -55,7 +51,6 @@ public function offsetExists($offset): bool
#[\ReturnTypeWillChange]
public function offsetGet($offset)
{
return $this->collection[$offset]
?? $this->collection[$offset] = ($this->create_instance)($offset);
return $this->collection[$offset] ??= ($this->create_instance)($offset);
}
}
31 changes: 10 additions & 21 deletions lib/AbstractSectionCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,18 @@
namespace ICanBoogie\CLDR;

use ArrayAccess;
use ICanBoogie\Accessor\AccessorTrait;
use ICanBoogie\OffsetNotDefined;

/**
* @implements ArrayAccess<string, array>
*
* @property-read Repository $repository
*/
abstract class AbstractSectionCollection implements ArrayAccess
{
use AccessorTrait;
use CollectionTrait;
use RepositoryPropertyTrait;

/**
* @var Repository
*/
private $repository;

public function __construct(Repository $repository)
{
$this->repository = $repository;
public function __construct(
public readonly Repository $repository
) {
}

abstract public function offsetExists($offset): bool;
Expand All @@ -44,27 +34,26 @@ abstract public function offsetExists($offset): bool;
*
* @phpstan-ignore-next-line
*/
private $sections = [];
private array $sections = [];

/**
* @param string $offset
*
* @throws OffsetNotDefined
* @throws ResourceNotFound
*/
#[\ReturnTypeWillChange]
public function offsetGet($offset) /* @phpstan-ignore-line */
#[\ReturnTypeWillChange] // @phpstan-ignore-line
public function offsetGet($offset)
{
if (!$this->offsetExists($offset))
{
throw new OffsetNotDefined([ $offset, $this ]);
}

return $this->sections[$offset]
?? $this->sections[$offset] = $this->repository->fetch(
$this->path_for($offset),
$this->data_path_for($offset)
);
return $this->sections[$offset] ??= $this->repository->fetch(
$this->path_for($offset),
$this->data_path_for($offset)
);
}

/**
Expand Down
11 changes: 3 additions & 8 deletions lib/Cache/CacheCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,12 @@
*/
final class CacheCollection implements Cache
{
/**
* @var Cache[]
*/
private $collection;

/**
* @param Cache[] $collection
*/
public function __construct(array $collection)
{
$this->collection = $collection;
public function __construct(
private readonly array $collection
) {
}

public function get(string $path): ?array
Expand Down
Loading

0 comments on commit 7d5adf0

Please sign in to comment.