From 39923ab167737fb6bd877dcb1a91470f0f8beb25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Mi=C5=A1o=20=C4=8Cerve=C5=88=C3=A1k?= Date: Tue, 29 Jul 2025 17:59:42 +0200 Subject: [PATCH 1/5] add Attribute --- src/Attributes/ReferencedFollow.php | 15 +++++++++++++++ src/ModelRelationsParser.php | 8 ++++++++ 2 files changed, 23 insertions(+) create mode 100644 src/Attributes/ReferencedFollow.php diff --git a/src/Attributes/ReferencedFollow.php b/src/Attributes/ReferencedFollow.php new file mode 100644 index 0000000..3e0fc56 --- /dev/null +++ b/src/Attributes/ReferencedFollow.php @@ -0,0 +1,15 @@ +getAttributes() as $attribute) { + $instance = $attribute->newInstance(); + if ($instance instanceof ReferencedFollow) { + if (!$instance->follow) { + continue 2; + } + } + } $type = Type::fromString($returnType->getName()); if (!$type->isClass()) { continue; From a102740607e563b8c28fa781960a3ad24123ade2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Mi=C5=A1o=20=C4=8Cerve=C5=88=C3=A1k?= Date: Tue, 29 Jul 2025 18:02:51 +0200 Subject: [PATCH 2/5] fix attributes --- src/Exceptions/CannotAccessModelException.php | 12 ++++++------ src/ModelRelationsParser.php | 1 + 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/Exceptions/CannotAccessModelException.php b/src/Exceptions/CannotAccessModelException.php index 82be75a..27a8c22 100644 --- a/src/Exceptions/CannotAccessModelException.php +++ b/src/Exceptions/CannotAccessModelException.php @@ -13,16 +13,16 @@ class CannotAccessModelException extends RuntimeException * @phpstan-param class-string $modelClassName * @phpstan-param Model $model */ - public function __construct(string $modelClassName, Model $model, int $code = 0, ?\Throwable $previous = null) - { + public function __construct( + public readonly string $modelClassName, + public readonly Model $model, + ) { parent::__construct( sprintf( - _('Can not access model %s from %s'), + 'Can not access model %s from %s', $modelClassName, get_class($model) - ), - $code, - $previous + ) ); } } diff --git a/src/ModelRelationsParser.php b/src/ModelRelationsParser.php index c7a6243..7d79ec0 100644 --- a/src/ModelRelationsParser.php +++ b/src/ModelRelationsParser.php @@ -4,6 +4,7 @@ namespace Fykosak\NetteORM; +use Fykosak\NetteORM\Attributes\ReferencedFollow; use Fykosak\NetteORM\Model\Model; use Nette\Utils\Reflection; use Nette\Utils\Type; From ff046c3b02bb8c10ee529cd5971035a98845fbad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Mi=C5=A1o=20=C4=8Cerve=C5=88=C3=A1k?= Date: Tue, 29 Jul 2025 18:07:21 +0200 Subject: [PATCH 3/5] update PHP version --- .github/workflows/php-psr.yml | 2 +- .github/workflows/php-stan.yml | 2 +- .github/workflows/php.yml | 2 +- composer.json | 2 +- composer.lock | 85 ++++++++++++++++++---------------- 5 files changed, 48 insertions(+), 45 deletions(-) diff --git a/.github/workflows/php-psr.yml b/.github/workflows/php-psr.yml index 46000d2..9fb9bff 100644 --- a/.github/workflows/php-psr.yml +++ b/.github/workflows/php-psr.yml @@ -9,7 +9,7 @@ jobs: strategy: fail-fast: false matrix: - php: [ '8.1' ] + php: [ '8.3' ] steps: - uses: actions/checkout@v2 name: Checkout diff --git a/.github/workflows/php-stan.yml b/.github/workflows/php-stan.yml index 131ffa9..06c98a6 100644 --- a/.github/workflows/php-stan.yml +++ b/.github/workflows/php-stan.yml @@ -9,7 +9,7 @@ jobs: strategy: fail-fast: false matrix: - php: [ '8.1' ] + php: [ '8.3' ] steps: - uses: actions/checkout@v2 name: Checkout diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index d76ac49..4fa1306 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -9,7 +9,7 @@ jobs: strategy: fail-fast: false matrix: - php: [ '8.1' ] + php: [ '8.3' ] database: [ 'mysql' ] steps: # MariaDB container has to be started in advance to initialize itself before using it. diff --git a/composer.json b/composer.json index bb64721..34a10e2 100644 --- a/composer.json +++ b/composer.json @@ -4,7 +4,7 @@ "type": "library", "license": "GPL-3.0-or-later", "require": { - "php": ">=8.1", + "php": ">=8.3", "nette/di": "v3.*", "nette/database": "v3.*", "ext-pdo": "*", diff --git a/composer.lock b/composer.lock index 2a4443d..490aad3 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "1f56f97a613d24887d02d0599d20aaf3", + "content-hash": "6e557c8e71dd8ad7a6f196945d2dec41", "packages": [ { "name": "nette/caching", @@ -82,16 +82,16 @@ }, { "name": "nette/database", - "version": "v3.2.4", + "version": "v3.2.7", "source": { "type": "git", "url": "https://github.com/nette/database.git", - "reference": "8e9a427d98ec0929102ee037016bb47eb7e8b75c" + "reference": "10a7c76e314a06bb5f92d447d82170b5dde7392f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nette/database/zipball/8e9a427d98ec0929102ee037016bb47eb7e8b75c", - "reference": "8e9a427d98ec0929102ee037016bb47eb7e8b75c", + "url": "https://api.github.com/repos/nette/database/zipball/10a7c76e314a06bb5f92d447d82170b5dde7392f", + "reference": "10a7c76e314a06bb5f92d447d82170b5dde7392f", "shasum": "" }, "require": { @@ -151,22 +151,22 @@ ], "support": { "issues": "https://github.com/nette/database/issues", - "source": "https://github.com/nette/database/tree/v3.2.4" + "source": "https://github.com/nette/database/tree/v3.2.7" }, - "time": "2024-08-28T01:03:21+00:00" + "time": "2025-06-03T05:00:20+00:00" }, { "name": "nette/di", - "version": "v3.2.3", + "version": "v3.2.4", "source": { "type": "git", "url": "https://github.com/nette/di.git", - "reference": "9b9bfb43dac31c7804b2c8900217046cc0ca3307" + "reference": "57f923a7af32435b6e4921c0adbc70c619625a17" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nette/di/zipball/9b9bfb43dac31c7804b2c8900217046cc0ca3307", - "reference": "9b9bfb43dac31c7804b2c8900217046cc0ca3307", + "url": "https://api.github.com/repos/nette/di/zipball/57f923a7af32435b6e4921c0adbc70c619625a17", + "reference": "57f923a7af32435b6e4921c0adbc70c619625a17", "shasum": "" }, "require": { @@ -224,9 +224,9 @@ ], "support": { "issues": "https://github.com/nette/di/issues", - "source": "https://github.com/nette/di/tree/v3.2.3" + "source": "https://github.com/nette/di/tree/v3.2.4" }, - "time": "2024-10-05T03:14:33+00:00" + "time": "2025-01-10T04:57:37+00:00" }, { "name": "nette/neon", @@ -298,16 +298,16 @@ }, { "name": "nette/php-generator", - "version": "v4.1.6", + "version": "v4.1.8", "source": { "type": "git", "url": "https://github.com/nette/php-generator.git", - "reference": "c90961e782ae86e517fe5ed732eb2b512945565b" + "reference": "42806049a7774a2bd316c958f5dcf01c6b5c56fa" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nette/php-generator/zipball/c90961e782ae86e517fe5ed732eb2b512945565b", - "reference": "c90961e782ae86e517fe5ed732eb2b512945565b", + "url": "https://api.github.com/repos/nette/php-generator/zipball/42806049a7774a2bd316c958f5dcf01c6b5c56fa", + "reference": "42806049a7774a2bd316c958f5dcf01c6b5c56fa", "shasum": "" }, "require": { @@ -351,7 +351,7 @@ "homepage": "https://nette.org/contributors" } ], - "description": "🐘 Nette PHP Generator: generates neat PHP code for you. Supports new PHP 8.3 features.", + "description": "🐘 Nette PHP Generator: generates neat PHP code for you. Supports new PHP 8.4 features.", "homepage": "https://nette.org", "keywords": [ "code", @@ -361,28 +361,28 @@ ], "support": { "issues": "https://github.com/nette/php-generator/issues", - "source": "https://github.com/nette/php-generator/tree/v4.1.6" + "source": "https://github.com/nette/php-generator/tree/v4.1.8" }, - "time": "2024-09-10T09:31:55+00:00" + "time": "2025-03-31T00:29:29+00:00" }, { "name": "nette/robot-loader", - "version": "v4.0.2", + "version": "v4.0.3", "source": { "type": "git", "url": "https://github.com/nette/robot-loader.git", - "reference": "6a921e88345fc7263b89ed878c927efc7c5e6092" + "reference": "45d67753fb4865bb718e9a6c9be69cc9470137b7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nette/robot-loader/zipball/6a921e88345fc7263b89ed878c927efc7c5e6092", - "reference": "6a921e88345fc7263b89ed878c927efc7c5e6092", + "url": "https://api.github.com/repos/nette/robot-loader/zipball/45d67753fb4865bb718e9a6c9be69cc9470137b7", + "reference": "45d67753fb4865bb718e9a6c9be69cc9470137b7", "shasum": "" }, "require": { "ext-tokenizer": "*", "nette/utils": "^4.0", - "php": "8.0 - 8.3" + "php": "8.0 - 8.4" }, "require-dev": { "nette/tester": "^2.4", @@ -427,9 +427,9 @@ ], "support": { "issues": "https://github.com/nette/robot-loader/issues", - "source": "https://github.com/nette/robot-loader/tree/v4.0.2" + "source": "https://github.com/nette/robot-loader/tree/v4.0.3" }, - "time": "2024-06-18T20:19:22+00:00" + "time": "2024-06-18T20:26:39+00:00" }, { "name": "nette/schema", @@ -495,16 +495,16 @@ }, { "name": "nette/utils", - "version": "v4.0.5", + "version": "v4.0.7", "source": { "type": "git", "url": "https://github.com/nette/utils.git", - "reference": "736c567e257dbe0fcf6ce81b4d6dbe05c6899f96" + "reference": "e67c4061eb40b9c113b218214e42cb5a0dda28f2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nette/utils/zipball/736c567e257dbe0fcf6ce81b4d6dbe05c6899f96", - "reference": "736c567e257dbe0fcf6ce81b4d6dbe05c6899f96", + "url": "https://api.github.com/repos/nette/utils/zipball/e67c4061eb40b9c113b218214e42cb5a0dda28f2", + "reference": "e67c4061eb40b9c113b218214e42cb5a0dda28f2", "shasum": "" }, "require": { @@ -575,24 +575,24 @@ ], "support": { "issues": "https://github.com/nette/utils/issues", - "source": "https://github.com/nette/utils/tree/v4.0.5" + "source": "https://github.com/nette/utils/tree/v4.0.7" }, - "time": "2024-08-07T15:39:19+00:00" + "time": "2025-06-03T04:55:08+00:00" } ], "packages-dev": [ { "name": "nette/tester", - "version": "v2.5.4", + "version": "v2.5.5", "source": { "type": "git", "url": "https://github.com/nette/tester.git", - "reference": "c11863785779e87b40adebf150364f2e5938c111" + "reference": "4b8a8519307598b56142ea0567b2cedb474af3fc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nette/tester/zipball/c11863785779e87b40adebf150364f2e5938c111", - "reference": "c11863785779e87b40adebf150364f2e5938c111", + "url": "https://api.github.com/repos/nette/tester/zipball/4b8a8519307598b56142ea0567b2cedb474af3fc", + "reference": "4b8a8519307598b56142ea0567b2cedb474af3fc", "shasum": "" }, "require": { @@ -600,7 +600,7 @@ }, "require-dev": { "ext-simplexml": "*", - "phpstan/phpstan": "^1.0" + "phpstan/phpstan-nette": "^2.0@stable" }, "bin": [ "src/tester" @@ -612,6 +612,9 @@ } }, "autoload": { + "psr-4": { + "Tester\\": "src" + }, "classmap": [ "src/" ] @@ -652,9 +655,9 @@ ], "support": { "issues": "https://github.com/nette/tester/issues", - "source": "https://github.com/nette/tester/tree/v2.5.4" + "source": "https://github.com/nette/tester/tree/v2.5.5" }, - "time": "2024-10-23T23:57:10+00:00" + "time": "2025-06-19T17:58:04+00:00" }, { "name": "phpstan/phpstan", @@ -795,7 +798,7 @@ "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": ">=8.1", + "php": ">=8.3", "ext-pdo": "*", "ext-gettext": "*" }, From 1260383994bcb0563b5481e992814ef18a020003 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Mi=C5=A1o=20=C4=8Cerve=C5=88=C3=A1k?= Date: Tue, 29 Jul 2025 18:21:25 +0200 Subject: [PATCH 4/5] update ubuntu --- .github/workflows/php-psr.yml | 2 +- .github/workflows/php-stan.yml | 2 +- .github/workflows/php.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/php-psr.yml b/.github/workflows/php-psr.yml index 9fb9bff..43c72ea 100644 --- a/.github/workflows/php-psr.yml +++ b/.github/workflows/php-psr.yml @@ -5,7 +5,7 @@ on: [ push, pull_request ] jobs: test: name: deafult with ${{ matrix.php }} - runs-on: ubuntu-20.04 + runs-on: ubuntu-24.04 strategy: fail-fast: false matrix: diff --git a/.github/workflows/php-stan.yml b/.github/workflows/php-stan.yml index 06c98a6..ef90acb 100644 --- a/.github/workflows/php-stan.yml +++ b/.github/workflows/php-stan.yml @@ -5,7 +5,7 @@ on: [push, pull_request] jobs: test: name: PHP ${{ matrix.php }} with ${{ matrix.database }} - runs-on: ubuntu-20.04 + runs-on: ubuntu-24.04 strategy: fail-fast: false matrix: diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 4fa1306..0d01b67 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -5,7 +5,7 @@ on: [push, pull_request] jobs: test: name: PHP ${{ matrix.php }} with ${{ matrix.database }} - runs-on: ubuntu-20.04 + runs-on: ubuntu-24.04 strategy: fail-fast: false matrix: From fdb0765cc074dffbf068dd0d3b250fcd418c5273 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Mi=C5=A1o=20=C4=8Cerve=C5=88=C3=A1k?= Date: Tue, 29 Jul 2025 18:40:10 +0200 Subject: [PATCH 5/5] update PHPStan --- composer.json | 2 +- composer.lock | 18 +++++++----------- src/Selection/TypedSelection.php | 3 ++- tests/Tests/TestCase.php | 2 +- tests/temp/.gitignore | 1 - 5 files changed, 11 insertions(+), 15 deletions(-) delete mode 100644 tests/temp/.gitignore diff --git a/composer.json b/composer.json index 34a10e2..e1713d9 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,7 @@ "require-dev": { "nette/tester": "^2.4.0", "squizlabs/php_codesniffer": "3.6.0", - "phpstan/phpstan": "1.10.21" + "phpstan/phpstan": "2.1.21" }, "authors": [ { diff --git a/composer.lock b/composer.lock index 490aad3..495e72e 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "6e557c8e71dd8ad7a6f196945d2dec41", + "content-hash": "46a58639c5796aed8db357ef4eb98b7f", "packages": [ { "name": "nette/caching", @@ -661,20 +661,20 @@ }, { "name": "phpstan/phpstan", - "version": "1.10.21", + "version": "2.1.21", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "b2a30186be2e4d97dce754ae4e65eb0ec2f04eb5" + "reference": "1ccf445757458c06a04eb3f803603cb118fe5fa6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/b2a30186be2e4d97dce754ae4e65eb0ec2f04eb5", - "reference": "b2a30186be2e4d97dce754ae4e65eb0ec2f04eb5", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/1ccf445757458c06a04eb3f803603cb118fe5fa6", + "reference": "1ccf445757458c06a04eb3f803603cb118fe5fa6", "shasum": "" }, "require": { - "php": "^7.2|^8.0" + "php": "^7.4|^8.0" }, "conflict": { "phpstan/phpstan-shim": "*" @@ -713,13 +713,9 @@ { "url": "https://github.com/phpstan", "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan", - "type": "tidelift" } ], - "time": "2023-06-21T20:07:58+00:00" + "time": "2025-07-28T19:35:08+00:00" }, { "name": "squizlabs/php_codesniffer", diff --git a/src/Selection/TypedSelection.php b/src/Selection/TypedSelection.php index 5c981ad..6bd50fa 100644 --- a/src/Selection/TypedSelection.php +++ b/src/Selection/TypedSelection.php @@ -13,7 +13,8 @@ /** * @template TModel of Model - * @phpstan-extends Selection + * @phpstan-extends Selection + * @phpstan-ignore-next-line */ class TypedSelection extends Selection { diff --git a/tests/Tests/TestCase.php b/tests/Tests/TestCase.php index 204d37d..d44490f 100644 --- a/tests/Tests/TestCase.php +++ b/tests/Tests/TestCase.php @@ -12,7 +12,7 @@ use Nette\DI\ContainerLoader; use Tester\Environment; -define('TEMP_DIR', __DIR__ . '/../temp'); +define('TEMP_DIR', __DIR__ . '/../../temp'); require_once __DIR__ . '/../../vendor/autoload.php'; diff --git a/tests/temp/.gitignore b/tests/temp/.gitignore deleted file mode 100644 index b498fd4..0000000 --- a/tests/temp/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/