From 942fff013d992497dce24d2e904df37d9e5e7553 Mon Sep 17 00:00:00 2001 From: SmetDenis Date: Sun, 19 Jul 2026 20:03:44 +0400 Subject: [PATCH 1/2] build: PHP 8.3 floor, major 8.0, jbzoo/* ^8.0, toolchain 8.0 --- .github/workflows/main.yml | 32 +++++++++------ README.md | 12 +++++- composer.json | 8 ++-- phpunit.xml.dist | 34 +++++++++------ src/Type/AbstractType.php | 41 +++++++------------ tests/InstancesTest.php | 4 +- ...tTypeTest.php => AbstractTypeTestCase.php} | 2 +- tests/Types/AreaTypeTest.php | 2 +- tests/Types/DegreeTypeTest.php | 2 +- tests/Types/InfoTypeTest.php | 2 +- tests/Types/LengthTypeTest.php | 2 +- tests/Types/TempTypeTest.php | 2 +- tests/Types/TimeTypeTest.php | 2 +- tests/Types/VolumeTypeTest.php | 2 +- tests/Types/WeightTypeTest.php | 2 +- 15 files changed, 80 insertions(+), 69 deletions(-) rename tests/Types/{AbstractTypeTest.php => AbstractTypeTestCase.php} (94%) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c8e25b2..a20ba7d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -15,12 +15,15 @@ permissions: contents: read on: + schedule: + - cron: '0 4 * * *' # daily 04:00 UTC canary keepalive pull_request: branches: - "*" push: branches: - 'master' + workflow_dispatch: {} env: COLUMNS: 120 @@ -34,20 +37,20 @@ jobs: JBZOO_COMPOSER_UPDATE_FLAGS: ${{ matrix.composer_flags }} strategy: matrix: - php-version: [ 8.2, 8.3, 8.4 ] + php-version: [ 8.3, 8.4, 8.5 ] coverage: [ xdebug, none ] composer_flags: [ "--prefer-lowest", "" ] steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v7 with: fetch-depth: 0 - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: '${{ matrix.php-version }}' - coverage: '${{ matrix.coverage }}' + php-version: ${{ matrix.php-version }} + coverage: ${{ matrix.coverage }} tools: composer extensions: ast @@ -58,18 +61,19 @@ jobs: run: make test --no-print-directory - name: Uploading coverage to coveralls - if: "${{ matrix.coverage == 'xdebug' }}" + if: '${{ matrix.coverage == ''xdebug'' }}' continue-on-error: true env: - COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} + COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: make report-coveralls --no-print-directory || true - name: Upload Artifacts - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v7 continue-on-error: true with: name: PHPUnit - ${{ matrix.php-version }} - ${{ matrix.coverage }} path: build/ + overwrite: true linters: @@ -77,10 +81,10 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php-version: [ 8.2, 8.3, 8.4 ] + php-version: [ 8.3, 8.4, 8.5 ] steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v7 with: fetch-depth: 0 @@ -99,11 +103,12 @@ jobs: run: make codestyle --no-print-directory - name: Upload Artifacts - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v7 continue-on-error: true with: name: Linters - ${{ matrix.php-version }} path: build/ + overwrite: true report: @@ -111,10 +116,10 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php-version: [ 8.2, 8.3, 8.4 ] + php-version: [ 8.3, 8.4, 8.5 ] steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v7 with: fetch-depth: 0 @@ -133,8 +138,9 @@ jobs: run: make report-all --no-print-directory - name: Upload Artifacts - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v7 continue-on-error: true with: name: Reports - ${{ matrix.php-version }} path: build/ + overwrite: true diff --git a/README.md b/README.md index 0d759a6..cd7664e 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,15 @@ # JBZoo / SimpleTypes -[![CI](https://github.com/JBZoo/SimpleTypes/actions/workflows/main.yml/badge.svg?branch=master)](https://github.com/JBZoo/SimpleTypes/actions/workflows/main.yml?query=branch%3Amaster) [![Coverage Status](https://coveralls.io/repos/github/JBZoo/SimpleTypes/badge.svg?branch=master)](https://coveralls.io/github/JBZoo/SimpleTypes?branch=master) [![Psalm Coverage](https://shepherd.dev/github/JBZoo/SimpleTypes/coverage.svg)](https://shepherd.dev/github/JBZoo/SimpleTypes) [![Psalm Level](https://shepherd.dev/github/JBZoo/SimpleTypes/level.svg)](https://shepherd.dev/github/JBZoo/SimpleTypes) [![CodeFactor](https://www.codefactor.io/repository/github/jbzoo/simpletypes/badge)](https://www.codefactor.io/repository/github/jbzoo/simpletypes/issues) -[![Stable Version](https://poser.pugx.org/jbzoo/simpletypes/version)](https://packagist.org/packages/jbzoo/simpletypes/) [![Total Downloads](https://poser.pugx.org/jbzoo/simpletypes/downloads)](https://packagist.org/packages/jbzoo/simpletypes/stats) [![Dependents](https://poser.pugx.org/jbzoo/simpletypes/dependents)](https://packagist.org/packages/jbzoo/simpletypes/dependents?order_by=downloads) [![GitHub License](https://img.shields.io/github/license/jbzoo/simpletypes)](https://github.com/JBZoo/SimpleTypes/blob/master/LICENSE) +[![CI](https://github.com/JBZoo/SimpleTypes/actions/workflows/main.yml/badge.svg?branch=master)](https://github.com/JBZoo/SimpleTypes/actions/workflows/main.yml?query=branch%3Amaster) +[![Coverage Status](https://coveralls.io/repos/github/JBZoo/SimpleTypes/badge.svg?branch=master)](https://coveralls.io/github/JBZoo/SimpleTypes?branch=master) +[![Psalm Coverage](https://shepherd.dev/github/JBZoo/SimpleTypes/coverage.svg)](https://shepherd.dev/github/JBZoo/SimpleTypes) +[![Psalm Level](https://shepherd.dev/github/JBZoo/SimpleTypes/level.svg)](https://shepherd.dev/github/JBZoo/SimpleTypes) +[![CodeFactor](https://www.codefactor.io/repository/github/jbzoo/simpletypes/badge)](https://www.codefactor.io/repository/github/jbzoo/simpletypes/issues) + +[![Stable Version](https://poser.pugx.org/jbzoo/simpletypes/version)](https://packagist.org/packages/jbzoo/simpletypes/) +[![Total Downloads](https://poser.pugx.org/jbzoo/simpletypes/downloads)](https://packagist.org/packages/jbzoo/simpletypes/stats) +[![Dependents](https://poser.pugx.org/jbzoo/simpletypes/dependents)](https://packagist.org/packages/jbzoo/simpletypes/dependents?order_by=downloads) +[![GitHub License](https://img.shields.io/github/license/jbzoo/simpletypes)](https://github.com/JBZoo/SimpleTypes/blob/master/LICENSE) diff --git a/composer.json b/composer.json index 6edb381..6488746 100644 --- a/composer.json +++ b/composer.json @@ -31,12 +31,12 @@ "prefer-stable" : true, "require" : { - "php" : "^8.2", - "jbzoo/utils" : "^7.3" + "php" : "^8.3", + "jbzoo/utils" : "^8.0" }, "require-dev" : { - "jbzoo/toolbox-dev" : "^7.2" + "jbzoo/toolbox-dev" : "^8.0" }, "autoload" : { @@ -55,7 +55,7 @@ "extra" : { "branch-alias" : { - "dev-master" : "7.x-dev" + "dev-master" : "8.x-dev" } } } diff --git a/phpunit.xml.dist b/phpunit.xml.dist index b277450..ac70c04 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -10,24 +10,34 @@ @copyright Copyright (C) JBZoo.com, All rights reserved. @see https://github.com/JBZoo/SimpleTypes --> - + + + + + + + + + - + tests - - - src - - - - - - - + + + + src + + diff --git a/src/Type/AbstractType.php b/src/Type/AbstractType.php index 52b1b73..daaa583 100644 --- a/src/Type/AbstractType.php +++ b/src/Type/AbstractType.php @@ -60,34 +60,30 @@ public function __toString() } /** - * Serialize. - * @return array + * Serialize the object state (modern replacement for __sleep()). + * + * The whole object graph (config, formatter, parser, ids) is rebuilt from the scalar dump + * on wake-up via prepareObject() - exactly as the previous __sleep()/__wakeup() pair did - + * so only that dump has to be stored. + * + * @return array */ - public function __sleep() + public function __serialize(): array { - $result = []; - $reflect = new \ReflectionClass($this); - $propList = $reflect->getProperties(); - - foreach ($propList as $prop) { - if ($prop->isStatic()) { - continue; - } - $result[] = $prop->name; - } - $this->log('Serialized'); - return $result; + return ['dump' => $this->dump(false)]; } /** - * Wake up after serialize. + * Wake up after serialize (modern replacement for __wakeup()). + * + * @param array $data */ - public function __wakeup(): void + public function __unserialize(array $data): void { $this->log('--> wakeup start'); - $this->prepareObject($this->dump(false)); + $this->prepareObject($data['dump'] ?? ''); $this->log('<-- Wakeup finish'); } @@ -140,7 +136,6 @@ public function __set(string $name, mixed $value): void /** * Experimental! Methods aliases. * @deprecated - * @psalm-suppress PossiblyUnusedReturnValue */ public function __call(string $name, array $arguments): mixed { @@ -337,17 +332,11 @@ public function setEmpty(bool $getClone = false): self return $this->modifier(0.0, 'Set empty', $getClone); } - /** - * @psalm-suppress PossiblyUnusedReturnValue - */ public function add(array|float|int|self|string|null $value, bool $getClone = false): self { return $this->customAdd($value, $getClone); } - /** - * @psalm-suppress PossiblyUnusedReturnValue - */ public function subtract(array|float|int|self|string|null $value, bool $getClone = false): self { return $this->customAdd($value, $getClone, true); @@ -684,7 +673,7 @@ private function prepareObject(array|float|int|string|null $value = null, ?Abstr // check that default rule $rules = $this->formatter->getList(true); - if (!\array_key_exists($this->default, $rules) || \count($rules) === 0) { + if (!\array_key_exists($this->default, $rules)) { throw new Exception("{$this->type}: Default rule not found!"); } diff --git a/tests/InstancesTest.php b/tests/InstancesTest.php index 328b466..9a5a0f3 100644 --- a/tests/InstancesTest.php +++ b/tests/InstancesTest.php @@ -50,9 +50,7 @@ public function testCreateTypes(): int return $count; } - /** - * @depends testCreateTypes - */ + #[\PHPUnit\Framework\Attributes\Depends('testCreateTypes')] public function testCreateConfigs(int $typeCount): void { $files = \scandir(\realpath(__DIR__ . '/../src/Config')); diff --git a/tests/Types/AbstractTypeTest.php b/tests/Types/AbstractTypeTestCase.php similarity index 94% rename from tests/Types/AbstractTypeTest.php rename to tests/Types/AbstractTypeTestCase.php index 7fad48e..96067f4 100644 --- a/tests/Types/AbstractTypeTest.php +++ b/tests/Types/AbstractTypeTestCase.php @@ -20,7 +20,7 @@ use JBZoo\SimpleTypes\Config\AbstractConfig; use JBZoo\SimpleTypes\Type\AbstractType; -abstract class AbstractTypeTest extends PHPUnit +abstract class AbstractTypeTestCase extends PHPUnit { protected string $type; diff --git a/tests/Types/AreaTypeTest.php b/tests/Types/AreaTypeTest.php index 8a59229..07fc699 100644 --- a/tests/Types/AreaTypeTest.php +++ b/tests/Types/AreaTypeTest.php @@ -18,7 +18,7 @@ use function JBZoo\PHPUnit\isSame; -final class AreaTypeTest extends AbstractTypeTest +final class AreaTypeTest extends AbstractTypeTestCase { protected string $type = 'Area'; diff --git a/tests/Types/DegreeTypeTest.php b/tests/Types/DegreeTypeTest.php index e569989..a0f821e 100644 --- a/tests/Types/DegreeTypeTest.php +++ b/tests/Types/DegreeTypeTest.php @@ -19,7 +19,7 @@ use function JBZoo\PHPUnit\is; use function JBZoo\PHPUnit\isSame; -final class DegreeTypeTest extends AbstractTypeTest +final class DegreeTypeTest extends AbstractTypeTestCase { protected string $type = 'Degree'; diff --git a/tests/Types/InfoTypeTest.php b/tests/Types/InfoTypeTest.php index ac7b573..a4177b3 100644 --- a/tests/Types/InfoTypeTest.php +++ b/tests/Types/InfoTypeTest.php @@ -19,7 +19,7 @@ use function JBZoo\PHPUnit\isSame; use function JBZoo\PHPUnit\isTrue; -final class InfoTypeTest extends AbstractTypeTest +final class InfoTypeTest extends AbstractTypeTestCase { protected string $type = 'Info'; diff --git a/tests/Types/LengthTypeTest.php b/tests/Types/LengthTypeTest.php index ccd6f84..b68d25a 100644 --- a/tests/Types/LengthTypeTest.php +++ b/tests/Types/LengthTypeTest.php @@ -18,7 +18,7 @@ use function JBZoo\PHPUnit\isSame; -final class LengthTypeTest extends AbstractTypeTest +final class LengthTypeTest extends AbstractTypeTestCase { protected string $type = 'Length'; diff --git a/tests/Types/TempTypeTest.php b/tests/Types/TempTypeTest.php index 092d387..60503cc 100644 --- a/tests/Types/TempTypeTest.php +++ b/tests/Types/TempTypeTest.php @@ -18,7 +18,7 @@ use function JBZoo\PHPUnit\isSame; -final class TempTypeTest extends AbstractTypeTest +final class TempTypeTest extends AbstractTypeTestCase { protected string $type = 'Temp'; diff --git a/tests/Types/TimeTypeTest.php b/tests/Types/TimeTypeTest.php index 18cb53c..22d7664 100644 --- a/tests/Types/TimeTypeTest.php +++ b/tests/Types/TimeTypeTest.php @@ -18,7 +18,7 @@ use function JBZoo\PHPUnit\isSame; -final class TimeTypeTest extends AbstractTypeTest +final class TimeTypeTest extends AbstractTypeTestCase { protected string $type = 'Time'; diff --git a/tests/Types/VolumeTypeTest.php b/tests/Types/VolumeTypeTest.php index 6593f93..c869948 100644 --- a/tests/Types/VolumeTypeTest.php +++ b/tests/Types/VolumeTypeTest.php @@ -18,7 +18,7 @@ use function JBZoo\PHPUnit\isSame; -final class VolumeTypeTest extends AbstractTypeTest +final class VolumeTypeTest extends AbstractTypeTestCase { protected string $type = 'Volume'; diff --git a/tests/Types/WeightTypeTest.php b/tests/Types/WeightTypeTest.php index 9e2c01b..774c9d5 100644 --- a/tests/Types/WeightTypeTest.php +++ b/tests/Types/WeightTypeTest.php @@ -18,7 +18,7 @@ use function JBZoo\PHPUnit\isSame; -final class WeightTypeTest extends AbstractTypeTest +final class WeightTypeTest extends AbstractTypeTestCase { protected string $type = 'Weight'; From d5e024367b77ee809e2b150b967c1d2ac361a1f1 Mon Sep 17 00:00:00 2001 From: SmetDenis Date: Mon, 20 Jul 2026 10:01:26 +0400 Subject: [PATCH 2/2] docs: refresh PHP floor and dependency versions for the 8.0 line --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index cd7664e..e8d7e3c 100644 --- a/README.md +++ b/README.md @@ -388,8 +388,8 @@ echo $value->rule(); // "eur" ## Requirements -- PHP 8.2 or higher -- jbzoo/utils ^7.3 +- PHP 8.3 or higher +- jbzoo/utils ^8.0 ## License