Skip to content

Commit

Permalink
Require PHP 8.2+
Browse files Browse the repository at this point in the history
  • Loading branch information
olvlvl committed Mar 20, 2024
1 parent 785731a commit 97697b4
Show file tree
Hide file tree
Showing 47 changed files with 311 additions and 347 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/code-style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ on:

jobs:
phpcs:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
coverage: none
php-version: "8.1"
php-version: "8.3"
ini-values: memory_limit=-1
tools: phpcs, cs2pr
- name: Run PHP Code Sniffer
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ on:
jobs:
phpstan:
name: phpstan
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: "8.1"
php-version: "8.3"
ini-values: memory_limit=-1
tools: composer:v2
- name: Cache dependencies
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: |
~/.composer/cache
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ on:
jobs:
phpunit:
name: phpunit
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
strategy:
matrix:
php-version:
- "8.1"
- "8.2"
- "8.3"
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
Expand All @@ -25,7 +25,7 @@ jobs:
tools: composer:v2
extensions: pdo_mysql
- name: Cache dependencies
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: |
~/.composer/cache
Expand All @@ -40,7 +40,7 @@ jobs:
run: make test-coveralls

- name: Upload code coverage
if: ${{ matrix.php-version == '8.1' }}
if: ${{ matrix.php-version == '8.3' }}
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
.composer-attribute-collector
.phpunit.cache
build
composer.lock
Expand Down
51 changes: 31 additions & 20 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,31 +1,42 @@
ARG PHP_VERSION
FROM php:${PHP_VERSION}-cli-buster
FROM php:${PHP_VERSION}-cli-bookworm

RUN apt-get update && \
apt-get install -y autoconf pkg-config && \
pecl channel-update pecl.php.net && \
pecl install xdebug && \
RUN <<-EOF
apt-get update
apt-get install -y autoconf pkg-config
pecl channel-update pecl.php.net
pecl install xdebug
docker-php-ext-enable opcache xdebug
EOF

RUN echo '\
xdebug.client_host=host.docker.internal\n\
xdebug.mode=develop\n\
xdebug.start_with_request=yes\n\
' >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
RUN <<-EOF
cat <<-SHELL >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
xdebug.client_host=host.docker.internal
xdebug.mode=develop
xdebug.start_with_request=yes
SHELL

RUN echo '\
display_errors=On\n\
error_reporting=E_ALL\n\
date.timezone=UTC\n\
' >> /usr/local/etc/php/conf.d/php.ini
cat <<-SHELL >> /usr/local/etc/php/conf.d/php.ini
display_errors=On
error_reporting=E_ALL
date.timezone=UTC
SHELL
EOF

ENV COMPOSER_ALLOW_SUPERUSER 1

RUN apt-get update && \
apt-get install unzip && \
curl -s https://raw.githubusercontent.com/composer/getcomposer.org/76a7060ccb93902cd7576b67264ad91c8a2700e2/web/installer | php -- --quiet && \
mv composer.phar /usr/local/bin/composer && \
echo 'export PATH="$HOME/.composer/vendor/bin:$PATH"\n' >> /root/.bashrc
RUN <<-EOF
apt-get update
apt-get install unzip
curl -s https://raw.githubusercontent.com/composer/getcomposer.org/76a7060ccb93902cd7576b67264ad91c8a2700e2/web/installer | php -- --quiet
mv composer.phar /usr/local/bin/composer
cat <<-SHELL >> /root/.bashrc
export PATH="$HOME/.composer/vendor/bin:$PATH"
SHELL
EOF

RUN composer global require squizlabs/php_codesniffer

# extra

RUN docker-php-ext-install pdo_mysql
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
The icanboogie/activerecord package is free software.
It is released under the terms of the following BSD License.

Copyright (c) 2007-2023 by Olivier Laviale
Copyright (c) 2007-present by Olivier Laviale
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
Expand Down
2 changes: 1 addition & 1 deletion MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

### New Requirements

- PHP 8.1+
- PHP 8.2+

### New features

Expand Down
15 changes: 7 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# customization

PACKAGE_NAME = icanboogie/activerecord
PHPUNIT = vendor/bin/phpunit

# do not edit the following lines
Expand All @@ -25,7 +24,7 @@ test: test-dependencies
.PHONY: test-coverage
test-coverage: test-dependencies
@mkdir -p build/coverage
@XDEBUG_MODE=coverage $(PHPUNIT) --coverage-html build/coverage $(ARGS)
@XDEBUG_MODE=coverage $(PHPUNIT) --coverage-html build/coverage

.PHONY: test-coveralls
test-coveralls: test-dependencies
Expand All @@ -37,18 +36,18 @@ test-cleanup:
@rm -rf tests/sandbox/*

.PHONY: test-container
test-container: test-container-81

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

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

.PHONY: test-container-83
test-container-83:
@-docker-compose run --rm app83 bash
@docker-compose down -v

.PHONY: lint
lint:
@XDEBUG_MODE=off phpcs -s
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"php": ">=8.1",
"php": ">=8.2",
"ext-pdo": "*",
"icanboogie/common": "^6.0",
"icanboogie/datetime": "^6.0",
Expand All @@ -38,7 +38,7 @@
"require-dev": {
"ext-pdo_mysql": "*",
"phpstan/phpstan": "^1.10",
"phpunit/phpunit": "^10.2"
"phpunit/phpunit": "^10.5"
},
"autoload": {
"psr-4": {
Expand Down
8 changes: 4 additions & 4 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
---
version: "3.2"
services:
app81:
app82:
build:
context: .
args:
PHP_VERSION: "8.1"
PHP_VERSION: "8.2"
environment:
PHP_IDE_CONFIG: 'serverName=icanboogie-activerecord'
volumes:
- .:/app:delegated
- ~/.composer:/root/.composer:delegated
working_dir: /app
app82:
app83:
build:
context: .
args:
PHP_VERSION: "8.2"
PHP_VERSION: "8.3"
environment:
PHP_IDE_CONFIG: 'serverName=icanboogie-activerecord'
volumes:
Expand Down
6 changes: 3 additions & 3 deletions lib/ActiveRecord/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
use ICanBoogie\ActiveRecord\Config\ConnectionDefinition;
use ICanBoogie\ActiveRecord\Config\ModelDefinition;

final class Config
final readonly class Config
{
public const DEFAULT_CONNECTION_ID = 'primary';

Expand All @@ -36,8 +36,8 @@ public static function __set_state(array $an_array): self
* @param array<class-string<ActiveRecord>, ModelDefinition> $models
*/
public function __construct(
public readonly array $connections,
public readonly array $models,
public array $connections,
public array $models,
) {
}
}
3 changes: 0 additions & 3 deletions lib/ActiveRecord/Config/Assert.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
use ICanBoogie\ActiveRecord\Model;
use LogicException;

use Test\ICanBoogie\Acme\ArticleModel;

use function get_parent_class;
use function is_subclass_of;

final class Assert
Expand Down
6 changes: 3 additions & 3 deletions lib/ActiveRecord/Config/Association.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/**
* @internal
*/
final class Association
final readonly class Association
{
/**
* @param array{
Expand All @@ -25,8 +25,8 @@ public static function __set_state(array $an_array): self
* @param array<HasManyAssociation> $has_many
*/
public function __construct(
public readonly array $belongs_to,
public readonly array $has_many,
public array $belongs_to,
public array $has_many,
) {
}
}
10 changes: 5 additions & 5 deletions lib/ActiveRecord/Config/BelongsToAssociation.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*
* @internal
*/
final class BelongsToAssociation
final readonly class BelongsToAssociation
{
/**
* @param array{
Expand All @@ -31,10 +31,10 @@ public static function __set_state(array $an_array): self
* @param non-empty-string $as
*/
public function __construct(
public readonly string $associate,
public readonly string $local_key,
public readonly string $foreign_key,
public readonly string $as,
public string $associate,
public string $local_key,
public string $foreign_key,
public string $as,
) {
}
}
16 changes: 8 additions & 8 deletions lib/ActiveRecord/Config/ConnectionDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use SensitiveParameter;

final class ConnectionDefinition
final readonly class ConnectionDefinition
{
public const DEFAULT_CHARSET_AND_COLLATE = "utf8/general_ci";

Expand Down Expand Up @@ -36,15 +36,15 @@ public static function __set_state(array $an_array): self
* @param non-empty-string $time_zone
*/
public function __construct(
public readonly string $id,
public readonly string $dsn,
public string $id,
public string $dsn,
#[SensitiveParameter]
public readonly ?string $username = null,
public ?string $username = null,
#[SensitiveParameter]
public readonly ?string $password = null,
public readonly ?string $table_name_prefix = null,
public readonly string $charset_and_collate = self::DEFAULT_CHARSET_AND_COLLATE,
public readonly string $time_zone = self::DEFAULT_TIMEZONE,
public ?string $password = null,
public ?string $table_name_prefix = null,
public string $charset_and_collate = self::DEFAULT_CHARSET_AND_COLLATE,
public string $time_zone = self::DEFAULT_TIMEZONE,
) {
}
}
10 changes: 5 additions & 5 deletions lib/ActiveRecord/Config/HasManyAssociation.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*
* @internal
*/
final class HasManyAssociation
final readonly class HasManyAssociation
{
/**
* @param array{
Expand All @@ -31,10 +31,10 @@ public static function __set_state(array $an_array): self
* @param class-string<ActiveRecord>|null $through
*/
public function __construct(
public readonly string $associate,
public readonly string $foreign_key,
public readonly string $as,
public readonly string|null $through,
public string $associate,
public string $foreign_key,
public string $as,
public string|null $through,
) {
}
}
Loading

0 comments on commit 97697b4

Please sign in to comment.