diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 1099922..b6b6b03 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -1,43 +1,39 @@ -name: Unit Testing +name: Unit Tests on: - pull_request: - branches: '**' push: - branches: '**' + branches: + - master jobs: - phpinsights: - name: PHP-Insights - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@master - - name: PHP-Insights - uses: docker://tienvx/phpinsights-action - - unit-test: name: Unit runs-on: ubuntu-latest container: - image: atk4/image:${{ matrix.php }} # https://github.com/atk4/image + image: ghcr.io/mvorisek/image-php:${{ matrix.php }} strategy: fail-fast: false matrix: - php: ['7.4', '8.0'] + php: ['8.2'] type: ['Phpunit'] - + env: + LOG_COVERAGE: "${{ fromJSON('{true: \"1\", false: \"\"}')[matrix.php == '8.0' && matrix.type == 'Phpunit' && (github.event_name == 'pull_request' || (github.event_name == 'push' && (github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/master')))] }}" steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 + + - name: Configure PHP + run: | + if [ -n "$LOG_COVERAGE" ]; then echo "xdebug.mode=coverage" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini; else rm /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini; fi + php --version - name: Setup cache 1/2 id: composer-cache run: | - echo "::set-output name=dir::$(composer config cache-files-dir)" + echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT - name: Setup cache 2/2 - uses: actions/cache@v1 + uses: actions/cache@v3 with: path: ${{ steps.composer-cache.outputs.dir }} key: ${{ runner.os }}-composer-${{ matrix.php }}-${{ matrix.type }}-${{ hashFiles('composer.json') }} @@ -46,13 +42,32 @@ jobs: - name: Install PHP dependencies run: | - if [ "${{ matrix.php }}" == "8.0" ]; then composer config platform.php 7.4.5 ; fi - composer install --no-suggest --ansi --prefer-dist --no-interaction --no-progress --optimize-autoloader + if [ "${{ matrix.type }}" != "Phpunit" ] && [ "${{ matrix.type }}" != "Phpunit Lowest" ] && [ "${{ matrix.type }}" != "Phpunit Burn" ]; then composer remove --no-interaction --no-update phpunit/phpunit johnkary/phpunit-speedtrap --dev; fi + if [ "${{ matrix.type }}" != "CodingStyle" ]; then composer remove --no-interaction --no-update friendsofphp/php-cs-fixer --dev; fi + if [ "${{ matrix.type }}" != "StaticAnalysis" ]; then composer remove --no-interaction --no-update phpstan/\* --dev; fi + if [ -n "$LOG_COVERAGE" ]; then composer require --no-interaction --no-update phpunit/phpcov; fi + composer update --ansi --prefer-dist --no-interaction --no-progress --optimize-autoloader + if [ "${{ matrix.type }}" = "Phpunit Lowest" ]; then composer update --ansi --prefer-dist --prefer-lowest --prefer-stable --no-interaction --no-progress --optimize-autoloader; fi + if [ "${{ matrix.type }}" = "Phpunit Burn" ]; then sed -i 's~ *public function runBare(): void~public function runBare(): void { gc_collect_cycles(); gc_collect_cycles(); $memDiffs = array_fill(0, '"$(if [ \"$GITHUB_EVENT_NAME\" == \"schedule\" ]; then echo 1024; else echo 64; fi)"', 0); for ($i = -1; $i < count($memDiffs); ++$i) { $this->_runBare(); gc_collect_cycles(); gc_collect_cycles(); $mem = memory_get_usage(); if ($i !== -1) { $memDiffs[$i] = $mem - $memPrev; } $memPrev = $mem; rsort($memDiffs); if (array_sum($memDiffs) >= 4096 * 1024 || $memDiffs[2] > 0) { $this->onNotSuccessfulTest(new AssertionFailedError( "Memory leak detected! (" . implode(" + ", array_map(fn ($v) => number_format($v / 1024, 3, ".", " "), array_filter($memDiffs))) . " KB, " . ($i + 2) . " iterations)" )); } } } private function _runBare(): void~' vendor/phpunit/phpunit/src/Framework/TestCase.php && cat vendor/phpunit/phpunit/src/Framework/TestCase.php | grep '_runBare('; fi + + - name: Init + run: | + if [ -n "$LOG_COVERAGE" ]; then mkdir coverage; fi - name: "Run tests" - if: matrix.type == 'Phpunit' - run: vendor/bin/phpunit tests --whitelist src --coverage-clover tests/coverage.xml -v - - - name: Codecov - uses: codecov/codecov-action@v1 + run: | + php -d opcache.enable_cli=1 vendor/bin/phpunit --exclude-group none $(if [ -n "$LOG_COVERAGE" ]; then echo --coverage-text; else echo --no-coverage; fi) -v + - name: Upload coverage logs 1/2 (only for coverage) + if: env.LOG_COVERAGE + run: | + ls -l coverage | wc -l + php -d memory_limit=2G vendor/bin/phpcov merge coverage/ --clover coverage/merged.xml + + - name: Upload coverage logs 2/2 (only for coverage) + if: env.LOG_COVERAGE + uses: codecov/codecov-action@v3 + with: + token: ${{ secrets.CODECOV_TOKEN }} + fail_ci_if_error: true + files: coverage/merged.xml diff --git a/.gitignore b/.gitignore index 8c8076f..c8632cb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .idea vendor -.phpunit.result.cache \ No newline at end of file +.phpunit.result.cache +/coverage \ No newline at end of file diff --git a/composer.json b/composer.json index d26200d..4af4b6a 100644 --- a/composer.json +++ b/composer.json @@ -5,15 +5,16 @@ "prefer-stable": true, "config": { "platform": { - "php": "7.4" + "php": "8.2" } }, "require": { - "atk4/data": "2.4.*", - "philippgrashoff/traitsforatkdata": "2.4.*" + "atk4/data": "4.*", + "philippgrashoff/atkextendedtestcase": "4.*" }, "require-dev": { - "phpunit/phpunit": ">8" + "phpunit/phpunit": "^9.5.5", + "phpstan/phpstan": "1.*" }, "autoload": { "psr-4": { diff --git a/composer.lock b/composer.lock index 325d059..76a9843 100644 --- a/composer.lock +++ b/composer.lock @@ -4,39 +4,39 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "58867a7ef25d5d039cb2e0ea0bba33c8", + "content-hash": "b08f1af6097b06c3ef2243781e426657", "packages": [ { "name": "atk4/core", - "version": "2.4.1", + "version": "4.0", "source": { "type": "git", "url": "https://github.com/atk4/core.git", - "reference": "79aad002e126fecf7c4c50d57edcd13b105235d4" + "reference": "8043b4de15999f382d54e391a5c427f7f7c45979" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/atk4/core/zipball/79aad002e126fecf7c4c50d57edcd13b105235d4", - "reference": "79aad002e126fecf7c4c50d57edcd13b105235d4", + "url": "https://api.github.com/repos/atk4/core/zipball/8043b4de15999f382d54e391a5c427f7f7c45979", + "reference": "8043b4de15999f382d54e391a5c427f7f7c45979", "shasum": "" }, "require": { - "ext-json": "*", - "php": ">=7.3.0", - "psr/log": "~1.0", - "symfony/polyfill-php74": "^1.17", + "php": ">=7.4 <8.3", + "psr/log": "^1.0", "symfony/polyfill-php80": "^1.17", "symfony/polyfill-php81": "^1.22", - "symfony/yaml": "^3.4 || ^4.4 || ^5.1" + "symfony/polyfill-php82": "^1.26", + "symfony/yaml": "^3.4 || ^4.4 || ^5.1 || ^6.0" }, "require-dev": { - "atk4/data": "~2.4.0", "ergebnis/composer-normalize": "^2.13", - "friendsofphp/php-cs-fixer": "^2.17", - "johnkary/phpunit-speedtrap": "^3.2", - "phpstan/phpstan": "^0.12.58", - "phpunit/phpunit": ">=9.1", - "symfony/contracts": ">=1.1" + "friendsofphp/php-cs-fixer": "^3.0", + "johnkary/phpunit-speedtrap": "^3.3", + "phpstan/extension-installer": "^1.1", + "phpstan/phpstan": "^1.0", + "phpstan/phpstan-deprecation-rules": "^1.0", + "phpstan/phpstan-strict-rules": "^1.3", + "phpunit/phpunit": "^9.5.5" }, "type": "library", "autoload": { @@ -77,48 +77,53 @@ ], "support": { "issues": "https://github.com/atk4/core/issues", - "source": "https://github.com/atk4/core/tree/2.4.1" + "source": "https://github.com/atk4/core/tree/4.0" }, - "time": "2021-04-17T06:05:03+00:00" + "time": "2022-11-26T14:16:25+00:00" }, { "name": "atk4/data", - "version": "2.4.0", + "version": "4.0.0", "source": { "type": "git", "url": "https://github.com/atk4/data.git", - "reference": "ad0b35ea92b65495f3ba4e799b1bc329eea1c980" + "reference": "6194456ccd7af490fe2586eb183fa3471e8a6f5a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/atk4/data/zipball/ad0b35ea92b65495f3ba4e799b1bc329eea1c980", - "reference": "ad0b35ea92b65495f3ba4e799b1bc329eea1c980", + "url": "https://api.github.com/repos/atk4/data/zipball/6194456ccd7af490fe2586eb183fa3471e8a6f5a", + "reference": "6194456ccd7af490fe2586eb183fa3471e8a6f5a", "shasum": "" }, "require": { - "atk4/dsql": "~2.4.0", - "ext-intl": "*", - "mahalux/atk4-hintable": "~1.2.1", - "php": ">=7.3.0" + "atk4/core": "~4.0.0", + "doctrine/dbal": "~3.4.5", + "mvorisek/atk4-hintable": "~1.9.0", + "php": ">=7.4 <8.3" }, "conflict": { - "atk4/schema": "*" + "jdorn/sql-formatter": "<1.2.9" }, "require-dev": { - "friendsofphp/php-cs-fixer": "^2.17", - "johnkary/phpunit-speedtrap": "^3.2", - "phpstan/phpstan": "^0.12.58", - "phpunit/phpcov": "*", - "phpunit/phpunit": ">=9.0" + "ergebnis/composer-normalize": "^2.13", + "friendsofphp/php-cs-fixer": "^3.0", + "johnkary/phpunit-speedtrap": "^3.3", + "phpstan/extension-installer": "^1.1", + "phpstan/phpstan": "^1.6", + "phpstan/phpstan-deprecation-rules": "^1.0", + "phpstan/phpstan-strict-rules": "^1.3", + "phpunit/phpunit": "^9.5.25" + }, + "suggest": { + "jdorn/sql-formatter": "*" }, "type": "library", "autoload": { "files": [ - "bootstrap-atk-types.php" + "bootstrap-types.php" ], "psr-4": { - "Atk4\\Data\\": "src/", - "Atk4\\Schema\\": "src-schema/" + "Atk4\\Data\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", @@ -157,179 +162,9 @@ ], "support": { "issues": "https://github.com/atk4/data/issues", - "source": "https://github.com/atk4/data/tree/2.4.0" - }, - "time": "2021-04-16T10:39:06+00:00" - }, - { - "name": "atk4/dsql", - "version": "2.4.0", - "source": { - "type": "git", - "url": "https://github.com/atk4/dsql.git", - "reference": "a0e57c79898ad439c2314ee2b55fd7032995385a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/atk4/dsql/zipball/a0e57c79898ad439c2314ee2b55fd7032995385a", - "reference": "a0e57c79898ad439c2314ee2b55fd7032995385a", - "shasum": "" - }, - "require": { - "atk4/core": "~2.4.0", - "doctrine/dbal": "^2.10 || ^3.0", - "ext-pdo": "*", - "php": ">=7.3.0" - }, - "require-dev": { - "ergebnis/composer-normalize": "^2.13", - "friendsofphp/php-cs-fixer": "^2.17", - "johnkary/phpunit-speedtrap": "^3.2", - "phpstan/phpstan": "^0.12.58", - "phpunit/phpcov": "*", - "phpunit/phpunit": ">=9.1" - }, - "suggest": { - "jdorn/sql-formatter": "*" - }, - "type": "library", - "autoload": { - "psr-4": { - "Atk4\\Dsql\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Romans Malinovskis", - "email": "romans@agiletoolkit.org", - "homepage": "https://nearly.guru/" - }, - { - "name": "Imants Horsts", - "homepage": "https://darkside.lv/" - }, - { - "name": "Michael Voříšek", - "homepage": "https://mvorisek.cz/" - } - ], - "description": "Dynamic SQL Builder in PHP", - "homepage": "http://agiletoolkit.org/", - "keywords": [ - "builder", - "framework", - "orm", - "sql" - ], - "support": { - "issues": "https://github.com/atk4/dsql/issues", - "source": "https://github.com/atk4/dsql/tree/2.4.0" + "source": "https://github.com/atk4/data/tree/4.0.0" }, - "abandoned": true, - "time": "2021-04-16T10:36:06+00:00" - }, - { - "name": "atk4/ui", - "version": "2.4.0", - "source": { - "type": "git", - "url": "https://github.com/atk4/ui.git", - "reference": "f94d3c19d893476603193061932c8779de1d0230" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/atk4/ui/zipball/f94d3c19d893476603193061932c8779de1d0230", - "reference": "f94d3c19d893476603193061932c8779de1d0230", - "shasum": "" - }, - "require": { - "atk4/data": "~2.4.0", - "php": ">=7.3.0" - }, - "require-dev": { - "behat/behat": "^3.8", - "behat/mink": "^1.8", - "behat/mink-extension": "^2.3.1", - "behat/mink-selenium2-driver": "^1.4", - "ergebnis/composer-normalize": "^2.13", - "friendsofphp/php-cs-fixer": "^2.17", - "fzaninotto/faker": "^1.6", - "guzzlehttp/guzzle": "^6.3", - "instaclick/php-webdriver": "^1.4.7", - "johnkary/phpunit-speedtrap": "^3.2", - "phpstan/phpstan": "^0.12.82", - "phpunit/phpcov": "*", - "phpunit/phpunit": ">=9.3", - "symfony/process": "^4.4 || ^5.0" - }, - "type": "library", - "autoload": { - "psr-4": { - "Atk4\\Ui\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Romans Malinovskis", - "email": "romans@agiletoolkit.org", - "homepage": "https://nearly.guru/" - }, - { - "name": "Alain Belair", - "homepage": "https://agiletoolkit.org/" - }, - { - "name": "Imants Horsts", - "homepage": "https://darkside.lv/" - }, - { - "name": "Francesco Danti", - "homepage": "https://oracoltech.com/" - }, - { - "name": "Michael Voříšek", - "homepage": "https://mvorisek.cz/" - }, - { - "name": "Philipp Grashoff" - }, - { - "name": "Alex Cicovic", - "homepage": "https://alexcicovic.com/" - }, - { - "name": "Georgi Hristov", - "homepage": "https://xsystems.io/" - } - ], - "description": "Agile UI - Web Component Framework written in PHP", - "homepage": "https://github.com/atk4/ui", - "keywords": [ - "button", - "component", - "crud", - "form", - "framework", - "gadget", - "grid", - "render", - "ui", - "web", - "widget" - ], - "support": { - "issues": "https://github.com/atk4/ui/issues", - "source": "https://github.com/atk4/ui/tree/2.4.0" - }, - "time": "2021-04-16T11:03:39+00:00" + "time": "2022-11-26T14:21:06+00:00" }, { "name": "doctrine/cache", @@ -426,16 +261,16 @@ }, { "name": "doctrine/dbal", - "version": "3.4.1", + "version": "3.4.6", "source": { "type": "git", "url": "https://github.com/doctrine/dbal.git", - "reference": "94e016428884227245fb1219e0de7d8b86ca16d7" + "reference": "3ce132f7c0b83d33b26ab6ed308e9e9260699bc4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/dbal/zipball/94e016428884227245fb1219e0de7d8b86ca16d7", - "reference": "94e016428884227245fb1219e0de7d8b86ca16d7", + "url": "https://api.github.com/repos/doctrine/dbal/zipball/3ce132f7c0b83d33b26ab6ed308e9e9260699bc4", + "reference": "3ce132f7c0b83d33b26ab6ed308e9e9260699bc4", "shasum": "" }, "require": { @@ -448,16 +283,16 @@ "psr/log": "^1|^2|^3" }, "require-dev": { - "doctrine/coding-standard": "9.0.0", - "jetbrains/phpstorm-stubs": "2022.1", - "phpstan/phpstan": "1.8.2", - "phpstan/phpstan-strict-rules": "^1.3", - "phpunit/phpunit": "9.5.21", + "doctrine/coding-standard": "10.0.0", + "jetbrains/phpstorm-stubs": "2022.2", + "phpstan/phpstan": "1.8.10", + "phpstan/phpstan-strict-rules": "^1.4", + "phpunit/phpunit": "9.5.25", "psalm/plugin-phpunit": "0.17.0", "squizlabs/php_codesniffer": "3.7.1", "symfony/cache": "^5.4|^6.0", "symfony/console": "^4.4|^5.4|^6.0", - "vimeo/psalm": "4.24.0" + "vimeo/psalm": "4.29.0" }, "suggest": { "symfony/console": "For helpful console commands such as SQL execution and import of files." @@ -517,7 +352,7 @@ ], "support": { "issues": "https://github.com/doctrine/dbal/issues", - "source": "https://github.com/doctrine/dbal/tree/3.4.1" + "source": "https://github.com/doctrine/dbal/tree/3.4.6" }, "funding": [ { @@ -533,29 +368,33 @@ "type": "tidelift" } ], - "time": "2022-08-16T18:37:46+00:00" + "time": "2022-10-21T14:38:43+00:00" }, { "name": "doctrine/deprecations", - "version": "v1.0.0", + "version": "v1.1.1", "source": { "type": "git", "url": "https://github.com/doctrine/deprecations.git", - "reference": "0e2a4f1f8cdfc7a92ec3b01c9334898c806b30de" + "reference": "612a3ee5ab0d5dd97b7cf3874a6efe24325efac3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/deprecations/zipball/0e2a4f1f8cdfc7a92ec3b01c9334898c806b30de", - "reference": "0e2a4f1f8cdfc7a92ec3b01c9334898c806b30de", + "url": "https://api.github.com/repos/doctrine/deprecations/zipball/612a3ee5ab0d5dd97b7cf3874a6efe24325efac3", + "reference": "612a3ee5ab0d5dd97b7cf3874a6efe24325efac3", "shasum": "" }, "require": { - "php": "^7.1|^8.0" + "php": "^7.1 || ^8.0" }, "require-dev": { "doctrine/coding-standard": "^9", - "phpunit/phpunit": "^7.5|^8.5|^9.5", - "psr/log": "^1|^2|^3" + "phpstan/phpstan": "1.4.10 || 1.10.15", + "phpstan/phpstan-phpunit": "^1.0", + "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", + "psalm/plugin-phpunit": "0.18.4", + "psr/log": "^1 || ^2 || ^3", + "vimeo/psalm": "4.30.0 || 5.12.0" }, "suggest": { "psr/log": "Allows logging deprecations via PSR-3 logger implementation" @@ -574,40 +413,41 @@ "homepage": "https://www.doctrine-project.org/", "support": { "issues": "https://github.com/doctrine/deprecations/issues", - "source": "https://github.com/doctrine/deprecations/tree/v1.0.0" + "source": "https://github.com/doctrine/deprecations/tree/v1.1.1" }, - "time": "2022-05-02T15:47:09+00:00" + "time": "2023-06-03T09:27:29+00:00" }, { "name": "doctrine/event-manager", - "version": "1.1.2", + "version": "1.2.0", "source": { "type": "git", "url": "https://github.com/doctrine/event-manager.git", - "reference": "eb2ecf80e3093e8f3c2769ac838e27d8ede8e683" + "reference": "95aa4cb529f1e96576f3fda9f5705ada4056a520" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/event-manager/zipball/eb2ecf80e3093e8f3c2769ac838e27d8ede8e683", - "reference": "eb2ecf80e3093e8f3c2769ac838e27d8ede8e683", + "url": "https://api.github.com/repos/doctrine/event-manager/zipball/95aa4cb529f1e96576f3fda9f5705ada4056a520", + "reference": "95aa4cb529f1e96576f3fda9f5705ada4056a520", "shasum": "" }, "require": { + "doctrine/deprecations": "^0.5.3 || ^1", "php": "^7.1 || ^8.0" }, "conflict": { "doctrine/common": "<2.9" }, "require-dev": { - "doctrine/coding-standard": "^9", - "phpstan/phpstan": "~1.4.10 || ^1.5.4", + "doctrine/coding-standard": "^9 || ^10", + "phpstan/phpstan": "~1.4.10 || ^1.8.8", "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", - "vimeo/psalm": "^4.22" + "vimeo/psalm": "^4.24" }, "type": "library", "autoload": { "psr-4": { - "Doctrine\\Common\\": "lib/Doctrine/Common" + "Doctrine\\Common\\": "src" } }, "notification-url": "https://packagist.org/downloads/", @@ -651,7 +491,7 @@ ], "support": { "issues": "https://github.com/doctrine/event-manager/issues", - "source": "https://github.com/doctrine/event-manager/tree/1.1.2" + "source": "https://github.com/doctrine/event-manager/tree/1.2.0" }, "funding": [ { @@ -667,33 +507,46 @@ "type": "tidelift" } ], - "time": "2022-07-27T22:18:11+00:00" + "time": "2022-10-12T20:51:15+00:00" }, { - "name": "mahalux/atk4-hintable", - "version": "1.2.1", + "name": "mvorisek/atk4-hintable", + "version": "1.9.5", "source": { "type": "git", "url": "https://github.com/mvorisek/atk4-hintable-mirror.git", - "reference": "ff9fb1502d6b95d8fccf920a26ab47981f1e5782" + "reference": "b2be11d0d4bc3c1827e9e03b53be570040a6a27b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/mvorisek/atk4-hintable-mirror/zipball/ff9fb1502d6b95d8fccf920a26ab47981f1e5782", - "reference": "ff9fb1502d6b95d8fccf920a26ab47981f1e5782", + "url": "https://api.github.com/repos/mvorisek/atk4-hintable-mirror/zipball/b2be11d0d4bc3c1827e9e03b53be570040a6a27b", + "reference": "b2be11d0d4bc3c1827e9e03b53be570040a6a27b", "shasum": "" }, "require": { - "atk4/data": "^2.4 || dev-develop", - "php": ">=7.3" + "atk4/data": "~4.0.0 || dev-develop", + "php": ">=7.4 <8.3" + }, + "conflict": { + "phpstan/phpstan": "<1.0" }, "require-dev": { - "friendsofphp/php-cs-fixer": "^2.16", + "friendsofphp/php-cs-fixer": "^3.0", "johnkary/phpunit-speedtrap": "^3.2", - "phpstan/phpstan": "^0.12.82", + "phpstan/extension-installer": "^1.1", + "phpstan/phpstan": "^1.0", + "phpstan/phpstan-deprecation-rules": "^1.0", + "phpstan/phpstan-strict-rules": "^1.3", "phpunit/phpunit": "^9.3" }, "type": "library", + "extra": { + "phpstan": { + "includes": [ + "phpstan-ext.neon" + ] + } + }, "autoload": { "psr-4": { "Mvorisek\\Atk4\\Hintable\\": "src/" @@ -710,65 +563,64 @@ } ], "description": "Hintable extension for atk4 libraries", - "homepage": "https://www.mahalux.com/", + "homepage": "https://www.mvorisek.com/", "support": { "issues": "https://github.com/mvorisek/atk4-hintable-mirror/issues", - "source": "https://github.com/mvorisek/atk4-hintable-mirror/tree/1.2.1" + "source": "https://github.com/mvorisek/atk4-hintable-mirror/tree/1.9.5" }, - "abandoned": "mvorisek/atk4-hintable", - "time": "2021-04-15T15:10:36+00:00" + "time": "2023-02-09T19:48:05+00:00" }, { - "name": "philippgrashoff/traitsforatkdata", - "version": "2.4", + "name": "philippgrashoff/atkextendedtestcase", + "version": "4.0.0", "source": { "type": "git", - "url": "https://github.com/PhilippGrashoff/traitsforatkdata.git", - "reference": "e40c76bd6a2c1a4d6d729b87f481bddf6ee22eed" + "url": "https://github.com/PhilippGrashoff/atkextendedtestcase.git", + "reference": "61b2cc1c790d72fe69009ec95c6549ec525d5636" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PhilippGrashoff/traitsforatkdata/zipball/e40c76bd6a2c1a4d6d729b87f481bddf6ee22eed", - "reference": "e40c76bd6a2c1a4d6d729b87f481bddf6ee22eed", + "url": "https://api.github.com/repos/PhilippGrashoff/atkextendedtestcase/zipball/61b2cc1c790d72fe69009ec95c6549ec525d5636", + "reference": "61b2cc1c790d72fe69009ec95c6549ec525d5636", "shasum": "" }, "require": { - "atk4/ui": "2.4.*", - "ext-mbstring": "*", - "ext-sodium": "*" + "atk4/data": "4.*" }, "require-dev": { - "phpunit/phpunit": ">8" + "phpstan/phpstan": "1.*", + "phpunit/phpunit": "^9.5.5" }, "type": "library", "autoload": { "psr-4": { - "traitsforatkdata\\": "src" + "atkextendedtestcase\\": "src" } }, "notification-url": "https://packagist.org/downloads/", + "description": "TestCase with SQLite persistence", "support": { - "issues": "https://github.com/PhilippGrashoff/traitsforatkdata/issues", - "source": "https://github.com/PhilippGrashoff/traitsforatkdata/tree/2.4" + "issues": "https://github.com/PhilippGrashoff/atkextendedtestcase/issues", + "source": "https://github.com/PhilippGrashoff/atkextendedtestcase/tree/4.0.0" }, - "time": "2022-08-20T12:00:07+00:00" + "time": "2023-07-29T19:10:42+00:00" }, { "name": "psr/cache", - "version": "1.0.1", + "version": "3.0.0", "source": { "type": "git", "url": "https://github.com/php-fig/cache.git", - "reference": "d11b50ad223250cf17b86e38383413f5a6764bf8" + "reference": "aa5030cfa5405eccfdcb1083ce040c2cb8d253bf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/cache/zipball/d11b50ad223250cf17b86e38383413f5a6764bf8", - "reference": "d11b50ad223250cf17b86e38383413f5a6764bf8", + "url": "https://api.github.com/repos/php-fig/cache/zipball/aa5030cfa5405eccfdcb1083ce040c2cb8d253bf", + "reference": "aa5030cfa5405eccfdcb1083ce040c2cb8d253bf", "shasum": "" }, "require": { - "php": ">=5.3.0" + "php": ">=8.0.0" }, "type": "library", "extra": { @@ -788,7 +640,7 @@ "authors": [ { "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" + "homepage": "https://www.php-fig.org/" } ], "description": "Common interface for caching libraries", @@ -798,9 +650,9 @@ "psr-6" ], "support": { - "source": "https://github.com/php-fig/cache/tree/master" + "source": "https://github.com/php-fig/cache/tree/3.0.0" }, - "time": "2016-08-06T20:24:11+00:00" + "time": "2021-02-03T23:26:27+00:00" }, { "name": "psr/log", @@ -854,25 +706,25 @@ }, { "name": "symfony/deprecation-contracts", - "version": "v2.5.2", + "version": "v3.3.0", "source": { "type": "git", "url": "https://github.com/symfony/deprecation-contracts.git", - "reference": "e8b495ea28c1d97b5e0c121748d6f9b53d075c66" + "reference": "7c3aff79d10325257a001fcf92d991f24fc967cf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/e8b495ea28c1d97b5e0c121748d6f9b53d075c66", - "reference": "e8b495ea28c1d97b5e0c121748d6f9b53d075c66", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/7c3aff79d10325257a001fcf92d991f24fc967cf", + "reference": "7c3aff79d10325257a001fcf92d991f24fc967cf", "shasum": "" }, "require": { - "php": ">=7.1" + "php": ">=8.1" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "2.5-dev" + "dev-main": "3.4-dev" }, "thanks": { "name": "symfony/contracts", @@ -901,7 +753,7 @@ "description": "A generic function and convention to trigger deprecation notices", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/deprecation-contracts/tree/v2.5.2" + "source": "https://github.com/symfony/deprecation-contracts/tree/v3.3.0" }, "funding": [ { @@ -917,20 +769,20 @@ "type": "tidelift" } ], - "time": "2022-01-02T09:53:40+00:00" + "time": "2023-05-23T14:45:45+00:00" }, { "name": "symfony/polyfill-ctype", - "version": "v1.26.0", + "version": "v1.27.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "6fd1b9a79f6e3cf65f9e679b23af304cd9e010d4" + "reference": "5bbc823adecdae860bb64756d639ecfec17b050a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/6fd1b9a79f6e3cf65f9e679b23af304cd9e010d4", - "reference": "6fd1b9a79f6e3cf65f9e679b23af304cd9e010d4", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/5bbc823adecdae860bb64756d639ecfec17b050a", + "reference": "5bbc823adecdae860bb64756d639ecfec17b050a", "shasum": "" }, "require": { @@ -945,7 +797,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.26-dev" + "dev-main": "1.27-dev" }, "thanks": { "name": "symfony/polyfill", @@ -983,7 +835,7 @@ "portable" ], "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/v1.26.0" + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.27.0" }, "funding": [ { @@ -999,20 +851,20 @@ "type": "tidelift" } ], - "time": "2022-05-24T11:49:31+00:00" + "time": "2022-11-03T14:55:06+00:00" }, { - "name": "symfony/polyfill-php74", - "version": "v1.26.0", + "name": "symfony/polyfill-php80", + "version": "v1.27.0", "source": { "type": "git", - "url": "https://github.com/symfony/polyfill-php74.git", - "reference": "ad4f7d62a17b1187d9f381f0a662aab19ff3c033" + "url": "https://github.com/symfony/polyfill-php80.git", + "reference": "7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php74/zipball/ad4f7d62a17b1187d9f381f0a662aab19ff3c033", - "reference": "ad4f7d62a17b1187d9f381f0a662aab19ff3c033", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936", + "reference": "7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936", "shasum": "" }, "require": { @@ -1021,7 +873,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.26-dev" + "dev-main": "1.27-dev" }, "thanks": { "name": "symfony/polyfill", @@ -1033,8 +885,11 @@ "bootstrap.php" ], "psr-4": { - "Symfony\\Polyfill\\Php74\\": "" - } + "Symfony\\Polyfill\\Php80\\": "" + }, + "classmap": [ + "Resources/stubs" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -1054,7 +909,7 @@ "homepage": "https://symfony.com/contributors" } ], - "description": "Symfony polyfill backporting some PHP 7.4+ features to lower PHP versions", + "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", "homepage": "https://symfony.com", "keywords": [ "compatibility", @@ -1063,7 +918,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php74/tree/v1.26.0" + "source": "https://github.com/symfony/polyfill-php80/tree/v1.27.0" }, "funding": [ { @@ -1079,20 +934,20 @@ "type": "tidelift" } ], - "time": "2022-05-24T11:49:31+00:00" + "time": "2022-11-03T14:55:06+00:00" }, { - "name": "symfony/polyfill-php80", - "version": "v1.26.0", + "name": "symfony/polyfill-php81", + "version": "v1.27.0", "source": { "type": "git", - "url": "https://github.com/symfony/polyfill-php80.git", - "reference": "cfa0ae98841b9e461207c13ab093d76b0fa7bace" + "url": "https://github.com/symfony/polyfill-php81.git", + "reference": "707403074c8ea6e2edaf8794b0157a0bfa52157a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/cfa0ae98841b9e461207c13ab093d76b0fa7bace", - "reference": "cfa0ae98841b9e461207c13ab093d76b0fa7bace", + "url": "https://api.github.com/repos/symfony/polyfill-php81/zipball/707403074c8ea6e2edaf8794b0157a0bfa52157a", + "reference": "707403074c8ea6e2edaf8794b0157a0bfa52157a", "shasum": "" }, "require": { @@ -1101,7 +956,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.26-dev" + "dev-main": "1.27-dev" }, "thanks": { "name": "symfony/polyfill", @@ -1113,7 +968,7 @@ "bootstrap.php" ], "psr-4": { - "Symfony\\Polyfill\\Php80\\": "" + "Symfony\\Polyfill\\Php81\\": "" }, "classmap": [ "Resources/stubs" @@ -1124,10 +979,6 @@ "MIT" ], "authors": [ - { - "name": "Ion Bazan", - "email": "ion.bazan@gmail.com" - }, { "name": "Nicolas Grekas", "email": "p@tchwork.com" @@ -1137,7 +988,7 @@ "homepage": "https://symfony.com/contributors" } ], - "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", + "description": "Symfony polyfill backporting some PHP 8.1+ features to lower PHP versions", "homepage": "https://symfony.com", "keywords": [ "compatibility", @@ -1146,7 +997,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php80/tree/v1.26.0" + "source": "https://github.com/symfony/polyfill-php81/tree/v1.27.0" }, "funding": [ { @@ -1162,20 +1013,20 @@ "type": "tidelift" } ], - "time": "2022-05-10T07:21:04+00:00" + "time": "2022-11-03T14:55:06+00:00" }, { - "name": "symfony/polyfill-php81", - "version": "v1.26.0", + "name": "symfony/polyfill-php82", + "version": "v1.27.0", "source": { "type": "git", - "url": "https://github.com/symfony/polyfill-php81.git", - "reference": "13f6d1271c663dc5ae9fb843a8f16521db7687a1" + "url": "https://github.com/symfony/polyfill-php82.git", + "reference": "80ddf7bfa17ef7b06db4e6d007a95bf584e07b44" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php81/zipball/13f6d1271c663dc5ae9fb843a8f16521db7687a1", - "reference": "13f6d1271c663dc5ae9fb843a8f16521db7687a1", + "url": "https://api.github.com/repos/symfony/polyfill-php82/zipball/80ddf7bfa17ef7b06db4e6d007a95bf584e07b44", + "reference": "80ddf7bfa17ef7b06db4e6d007a95bf584e07b44", "shasum": "" }, "require": { @@ -1184,7 +1035,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.26-dev" + "dev-main": "1.27-dev" }, "thanks": { "name": "symfony/polyfill", @@ -1196,7 +1047,7 @@ "bootstrap.php" ], "psr-4": { - "Symfony\\Polyfill\\Php81\\": "" + "Symfony\\Polyfill\\Php82\\": "" }, "classmap": [ "Resources/stubs" @@ -1216,7 +1067,7 @@ "homepage": "https://symfony.com/contributors" } ], - "description": "Symfony polyfill backporting some PHP 8.1+ features to lower PHP versions", + "description": "Symfony polyfill backporting some PHP 8.2+ features to lower PHP versions", "homepage": "https://symfony.com", "keywords": [ "compatibility", @@ -1225,7 +1076,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php81/tree/v1.26.0" + "source": "https://github.com/symfony/polyfill-php82/tree/v1.27.0" }, "funding": [ { @@ -1241,35 +1092,32 @@ "type": "tidelift" } ], - "time": "2022-05-24T11:49:31+00:00" + "time": "2022-11-10T10:10:54+00:00" }, { "name": "symfony/yaml", - "version": "v5.4.11", + "version": "v6.3.3", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "05d4ea560f3402c6c116afd99fdc66e60eda227e" + "reference": "e23292e8c07c85b971b44c1c4b87af52133e2add" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/05d4ea560f3402c6c116afd99fdc66e60eda227e", - "reference": "05d4ea560f3402c6c116afd99fdc66e60eda227e", + "url": "https://api.github.com/repos/symfony/yaml/zipball/e23292e8c07c85b971b44c1c4b87af52133e2add", + "reference": "e23292e8c07c85b971b44c1c4b87af52133e2add", "shasum": "" }, "require": { - "php": ">=7.2.5", - "symfony/deprecation-contracts": "^2.1|^3", + "php": ">=8.1", + "symfony/deprecation-contracts": "^2.5|^3", "symfony/polyfill-ctype": "^1.8" }, "conflict": { - "symfony/console": "<5.3" + "symfony/console": "<5.4" }, "require-dev": { - "symfony/console": "^5.3|^6.0" - }, - "suggest": { - "symfony/console": "For validating YAML files using the lint command" + "symfony/console": "^5.4|^6.0" }, "bin": [ "Resources/bin/yaml-lint" @@ -1300,7 +1148,7 @@ "description": "Loads and dumps YAML files", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/yaml/tree/v5.4.11" + "source": "https://github.com/symfony/yaml/tree/v6.3.3" }, "funding": [ { @@ -1316,36 +1164,36 @@ "type": "tidelift" } ], - "time": "2022-06-27T16:58:25+00:00" + "time": "2023-07-31T07:08:24+00:00" } ], "packages-dev": [ { "name": "doctrine/instantiator", - "version": "1.4.1", + "version": "2.0.0", "source": { "type": "git", "url": "https://github.com/doctrine/instantiator.git", - "reference": "10dcfce151b967d20fde1b34ae6640712c3891bc" + "reference": "c6222283fa3f4ac679f8b9ced9a4e23f163e80d0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/10dcfce151b967d20fde1b34ae6640712c3891bc", - "reference": "10dcfce151b967d20fde1b34ae6640712c3891bc", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/c6222283fa3f4ac679f8b9ced9a4e23f163e80d0", + "reference": "c6222283fa3f4ac679f8b9ced9a4e23f163e80d0", "shasum": "" }, "require": { - "php": "^7.1 || ^8.0" + "php": "^8.1" }, "require-dev": { - "doctrine/coding-standard": "^9", + "doctrine/coding-standard": "^11", "ext-pdo": "*", "ext-phar": "*", - "phpbench/phpbench": "^0.16 || ^1", - "phpstan/phpstan": "^1.4", - "phpstan/phpstan-phpunit": "^1", - "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", - "vimeo/psalm": "^4.22" + "phpbench/phpbench": "^1.2", + "phpstan/phpstan": "^1.9.4", + "phpstan/phpstan-phpunit": "^1.3", + "phpunit/phpunit": "^9.5.27", + "vimeo/psalm": "^5.4" }, "type": "library", "autoload": { @@ -1372,7 +1220,7 @@ ], "support": { "issues": "https://github.com/doctrine/instantiator/issues", - "source": "https://github.com/doctrine/instantiator/tree/1.4.1" + "source": "https://github.com/doctrine/instantiator/tree/2.0.0" }, "funding": [ { @@ -1388,20 +1236,20 @@ "type": "tidelift" } ], - "time": "2022-03-03T08:28:38+00:00" + "time": "2022-12-30T00:23:10+00:00" }, { "name": "myclabs/deep-copy", - "version": "1.11.0", + "version": "1.11.1", "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "14daed4296fae74d9e3201d2c4925d1acb7aa614" + "reference": "7284c22080590fb39f2ffa3e9057f10a4ddd0e0c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/14daed4296fae74d9e3201d2c4925d1acb7aa614", - "reference": "14daed4296fae74d9e3201d2c4925d1acb7aa614", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/7284c22080590fb39f2ffa3e9057f10a4ddd0e0c", + "reference": "7284c22080590fb39f2ffa3e9057f10a4ddd0e0c", "shasum": "" }, "require": { @@ -1439,7 +1287,7 @@ ], "support": { "issues": "https://github.com/myclabs/DeepCopy/issues", - "source": "https://github.com/myclabs/DeepCopy/tree/1.11.0" + "source": "https://github.com/myclabs/DeepCopy/tree/1.11.1" }, "funding": [ { @@ -1447,20 +1295,20 @@ "type": "tidelift" } ], - "time": "2022-03-03T13:19:32+00:00" + "time": "2023-03-08T13:26:56+00:00" }, { "name": "nikic/php-parser", - "version": "v4.14.0", + "version": "v4.16.0", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "34bea19b6e03d8153165d8f30bba4c3be86184c1" + "reference": "19526a33fb561ef417e822e85f08a00db4059c17" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/34bea19b6e03d8153165d8f30bba4c3be86184c1", - "reference": "34bea19b6e03d8153165d8f30bba4c3be86184c1", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/19526a33fb561ef417e822e85f08a00db4059c17", + "reference": "19526a33fb561ef417e822e85f08a00db4059c17", "shasum": "" }, "require": { @@ -1501,9 +1349,9 @@ ], "support": { "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/v4.14.0" + "source": "https://github.com/nikic/PHP-Parser/tree/v4.16.0" }, - "time": "2022-05-31T20:59:12+00:00" + "time": "2023-06-25T14:52:30+00:00" }, { "name": "phar-io/manifest", @@ -1617,251 +1465,86 @@ "time": "2022-02-21T01:04:05+00:00" }, { - "name": "phpdocumentor/reflection-common", - "version": "2.2.0", + "name": "phpstan/phpstan", + "version": "1.10.28", "source": { "type": "git", - "url": "https://github.com/phpDocumentor/ReflectionCommon.git", - "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b" + "url": "https://github.com/phpstan/phpstan.git", + "reference": "e4545b55904ebef470423d3ddddb74fa7325497a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/1d01c49d4ed62f25aa84a747ad35d5a16924662b", - "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/e4545b55904ebef470423d3ddddb74fa7325497a", + "reference": "e4545b55904ebef470423d3ddddb74fa7325497a", "shasum": "" }, "require": { - "php": "^7.2 || ^8.0" + "php": "^7.2|^8.0" }, - "type": "library", - "extra": { - "branch-alias": { - "dev-2.x": "2.x-dev" - } + "conflict": { + "phpstan/phpstan-shim": "*" }, + "bin": [ + "phpstan", + "phpstan.phar" + ], + "type": "library", "autoload": { - "psr-4": { - "phpDocumentor\\Reflection\\": "src/" - } + "files": [ + "bootstrap.php" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], - "authors": [ - { - "name": "Jaap van Otterdijk", - "email": "opensource@ijaap.nl" - } - ], - "description": "Common reflection classes used by phpdocumentor to reflect the code structure", - "homepage": "http://www.phpdoc.org", + "description": "PHPStan - PHP Static Analysis Tool", "keywords": [ - "FQSEN", - "phpDocumentor", - "phpdoc", - "reflection", + "dev", "static analysis" ], "support": { - "issues": "https://github.com/phpDocumentor/ReflectionCommon/issues", - "source": "https://github.com/phpDocumentor/ReflectionCommon/tree/2.x" - }, - "time": "2020-06-27T09:03:43+00:00" - }, - { - "name": "phpdocumentor/reflection-docblock", - "version": "5.3.0", - "source": { - "type": "git", - "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "622548b623e81ca6d78b721c5e029f4ce664f170" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/622548b623e81ca6d78b721c5e029f4ce664f170", - "reference": "622548b623e81ca6d78b721c5e029f4ce664f170", - "shasum": "" + "docs": "https://phpstan.org/user-guide/getting-started", + "forum": "https://github.com/phpstan/phpstan/discussions", + "issues": "https://github.com/phpstan/phpstan/issues", + "security": "https://github.com/phpstan/phpstan/security/policy", + "source": "https://github.com/phpstan/phpstan-src" }, - "require": { - "ext-filter": "*", - "php": "^7.2 || ^8.0", - "phpdocumentor/reflection-common": "^2.2", - "phpdocumentor/type-resolver": "^1.3", - "webmozart/assert": "^1.9.1" - }, - "require-dev": { - "mockery/mockery": "~1.3.2", - "psalm/phar": "^4.8" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "5.x-dev" - } - }, - "autoload": { - "psr-4": { - "phpDocumentor\\Reflection\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ + "funding": [ { - "name": "Mike van Riel", - "email": "me@mikevanriel.com" + "url": "https://github.com/ondrejmirtes", + "type": "github" }, { - "name": "Jaap van Otterdijk", - "email": "account@ijaap.nl" - } - ], - "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", - "support": { - "issues": "https://github.com/phpDocumentor/ReflectionDocBlock/issues", - "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/5.3.0" - }, - "time": "2021-10-19T17:43:47+00:00" - }, - { - "name": "phpdocumentor/type-resolver", - "version": "1.6.1", - "source": { - "type": "git", - "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "77a32518733312af16a44300404e945338981de3" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/77a32518733312af16a44300404e945338981de3", - "reference": "77a32518733312af16a44300404e945338981de3", - "shasum": "" - }, - "require": { - "php": "^7.2 || ^8.0", - "phpdocumentor/reflection-common": "^2.0" - }, - "require-dev": { - "ext-tokenizer": "*", - "psalm/phar": "^4.8" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-1.x": "1.x-dev" - } - }, - "autoload": { - "psr-4": { - "phpDocumentor\\Reflection\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Mike van Riel", - "email": "me@mikevanriel.com" - } - ], - "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", - "support": { - "issues": "https://github.com/phpDocumentor/TypeResolver/issues", - "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.6.1" - }, - "time": "2022-03-15T21:29:03+00:00" - }, - { - "name": "phpspec/prophecy", - "version": "v1.15.0", - "source": { - "type": "git", - "url": "https://github.com/phpspec/prophecy.git", - "reference": "bbcd7380b0ebf3961ee21409db7b38bc31d69a13" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/bbcd7380b0ebf3961ee21409db7b38bc31d69a13", - "reference": "bbcd7380b0ebf3961ee21409db7b38bc31d69a13", - "shasum": "" - }, - "require": { - "doctrine/instantiator": "^1.2", - "php": "^7.2 || ~8.0, <8.2", - "phpdocumentor/reflection-docblock": "^5.2", - "sebastian/comparator": "^3.0 || ^4.0", - "sebastian/recursion-context": "^3.0 || ^4.0" - }, - "require-dev": { - "phpspec/phpspec": "^6.0 || ^7.0", - "phpunit/phpunit": "^8.0 || ^9.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.x-dev" - } - }, - "autoload": { - "psr-4": { - "Prophecy\\": "src/Prophecy" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Konstantin Kudryashov", - "email": "ever.zet@gmail.com", - "homepage": "http://everzet.com" + "url": "https://github.com/phpstan", + "type": "github" }, { - "name": "Marcello Duarte", - "email": "marcello.duarte@gmail.com" + "url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan", + "type": "tidelift" } ], - "description": "Highly opinionated mocking framework for PHP 5.3+", - "homepage": "https://github.com/phpspec/prophecy", - "keywords": [ - "Double", - "Dummy", - "fake", - "mock", - "spy", - "stub" - ], - "support": { - "issues": "https://github.com/phpspec/prophecy/issues", - "source": "https://github.com/phpspec/prophecy/tree/v1.15.0" - }, - "time": "2021-12-08T12:19:24+00:00" + "time": "2023-08-08T12:33:42+00:00" }, { "name": "phpunit/php-code-coverage", - "version": "9.2.16", + "version": "9.2.27", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "2593003befdcc10db5e213f9f28814f5aa8ac073" + "reference": "b0a88255cb70d52653d80c890bd7f38740ea50d1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/2593003befdcc10db5e213f9f28814f5aa8ac073", - "reference": "2593003befdcc10db5e213f9f28814f5aa8ac073", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/b0a88255cb70d52653d80c890bd7f38740ea50d1", + "reference": "b0a88255cb70d52653d80c890bd7f38740ea50d1", "shasum": "" }, "require": { "ext-dom": "*", "ext-libxml": "*", "ext-xmlwriter": "*", - "nikic/php-parser": "^4.14", + "nikic/php-parser": "^4.15", "php": ">=7.3", "phpunit/php-file-iterator": "^3.0.3", "phpunit/php-text-template": "^2.0.2", @@ -1876,8 +1559,8 @@ "phpunit/phpunit": "^9.3" }, "suggest": { - "ext-pcov": "*", - "ext-xdebug": "*" + "ext-pcov": "PHP extension that provides line coverage", + "ext-xdebug": "PHP extension that provides line coverage as well as branch and path coverage" }, "type": "library", "extra": { @@ -1910,7 +1593,8 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.16" + "security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy", + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.27" }, "funding": [ { @@ -1918,7 +1602,7 @@ "type": "github" } ], - "time": "2022-08-20T05:26:47+00:00" + "time": "2023-07-26T13:44:30+00:00" }, { "name": "phpunit/php-file-iterator", @@ -2163,20 +1847,20 @@ }, { "name": "phpunit/phpunit", - "version": "9.5.22", + "version": "9.6.10", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "e329ac6e8744f461518272612a479fde958752fe" + "reference": "a6d351645c3fe5a30f5e86be6577d946af65a328" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/e329ac6e8744f461518272612a479fde958752fe", - "reference": "e329ac6e8744f461518272612a479fde958752fe", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/a6d351645c3fe5a30f5e86be6577d946af65a328", + "reference": "a6d351645c3fe5a30f5e86be6577d946af65a328", "shasum": "" }, "require": { - "doctrine/instantiator": "^1.3.1", + "doctrine/instantiator": "^1.3.1 || ^2", "ext-dom": "*", "ext-json": "*", "ext-libxml": "*", @@ -2187,7 +1871,6 @@ "phar-io/manifest": "^2.0.3", "phar-io/version": "^3.0.2", "php": ">=7.3", - "phpspec/prophecy": "^1.12.1", "phpunit/php-code-coverage": "^9.2.13", "phpunit/php-file-iterator": "^3.0.5", "phpunit/php-invoker": "^3.1.1", @@ -2195,22 +1878,19 @@ "phpunit/php-timer": "^5.0.2", "sebastian/cli-parser": "^1.0.1", "sebastian/code-unit": "^1.0.6", - "sebastian/comparator": "^4.0.5", + "sebastian/comparator": "^4.0.8", "sebastian/diff": "^4.0.3", "sebastian/environment": "^5.1.3", - "sebastian/exporter": "^4.0.3", + "sebastian/exporter": "^4.0.5", "sebastian/global-state": "^5.0.1", "sebastian/object-enumerator": "^4.0.3", "sebastian/resource-operations": "^3.0.3", - "sebastian/type": "^3.0", + "sebastian/type": "^3.2", "sebastian/version": "^3.0.2" }, - "require-dev": { - "phpspec/prophecy-phpunit": "^2.0.1" - }, "suggest": { - "ext-soap": "*", - "ext-xdebug": "*" + "ext-soap": "To be able to generate mocks based on WSDL files", + "ext-xdebug": "PHP extension that provides line coverage as well as branch and path coverage" }, "bin": [ "phpunit" @@ -2218,7 +1898,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "9.5-dev" + "dev-master": "9.6-dev" } }, "autoload": { @@ -2249,7 +1929,8 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", - "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.22" + "security": "https://github.com/sebastianbergmann/phpunit/security/policy", + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.10" }, "funding": [ { @@ -2259,9 +1940,13 @@ { "url": "https://github.com/sebastianbergmann", "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpunit/phpunit", + "type": "tidelift" } ], - "time": "2022-08-20T08:25:46+00:00" + "time": "2023-07-10T04:04:23+00:00" }, { "name": "sebastian/cli-parser", @@ -2432,16 +2117,16 @@ }, { "name": "sebastian/comparator", - "version": "4.0.6", + "version": "4.0.8", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "55f4261989e546dc112258c7a75935a81a7ce382" + "reference": "fa0f136dd2334583309d32b62544682ee972b51a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/55f4261989e546dc112258c7a75935a81a7ce382", - "reference": "55f4261989e546dc112258c7a75935a81a7ce382", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/fa0f136dd2334583309d32b62544682ee972b51a", + "reference": "fa0f136dd2334583309d32b62544682ee972b51a", "shasum": "" }, "require": { @@ -2494,7 +2179,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/comparator/issues", - "source": "https://github.com/sebastianbergmann/comparator/tree/4.0.6" + "source": "https://github.com/sebastianbergmann/comparator/tree/4.0.8" }, "funding": [ { @@ -2502,7 +2187,7 @@ "type": "github" } ], - "time": "2020-10-26T15:49:45+00:00" + "time": "2022-09-14T12:41:17+00:00" }, { "name": "sebastian/complexity", @@ -2563,16 +2248,16 @@ }, { "name": "sebastian/diff", - "version": "4.0.4", + "version": "4.0.5", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "3461e3fccc7cfdfc2720be910d3bd73c69be590d" + "reference": "74be17022044ebaaecfdf0c5cd504fc9cd5a7131" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/3461e3fccc7cfdfc2720be910d3bd73c69be590d", - "reference": "3461e3fccc7cfdfc2720be910d3bd73c69be590d", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/74be17022044ebaaecfdf0c5cd504fc9cd5a7131", + "reference": "74be17022044ebaaecfdf0c5cd504fc9cd5a7131", "shasum": "" }, "require": { @@ -2617,7 +2302,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/diff/issues", - "source": "https://github.com/sebastianbergmann/diff/tree/4.0.4" + "source": "https://github.com/sebastianbergmann/diff/tree/4.0.5" }, "funding": [ { @@ -2625,20 +2310,20 @@ "type": "github" } ], - "time": "2020-10-26T13:10:38+00:00" + "time": "2023-05-07T05:35:17+00:00" }, { "name": "sebastian/environment", - "version": "5.1.4", + "version": "5.1.5", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "1b5dff7bb151a4db11d49d90e5408e4e938270f7" + "reference": "830c43a844f1f8d5b7a1f6d6076b784454d8b7ed" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/1b5dff7bb151a4db11d49d90e5408e4e938270f7", - "reference": "1b5dff7bb151a4db11d49d90e5408e4e938270f7", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/830c43a844f1f8d5b7a1f6d6076b784454d8b7ed", + "reference": "830c43a844f1f8d5b7a1f6d6076b784454d8b7ed", "shasum": "" }, "require": { @@ -2680,7 +2365,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/environment/issues", - "source": "https://github.com/sebastianbergmann/environment/tree/5.1.4" + "source": "https://github.com/sebastianbergmann/environment/tree/5.1.5" }, "funding": [ { @@ -2688,20 +2373,20 @@ "type": "github" } ], - "time": "2022-04-03T09:37:03+00:00" + "time": "2023-02-03T06:03:51+00:00" }, { "name": "sebastian/exporter", - "version": "4.0.4", + "version": "4.0.5", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "65e8b7db476c5dd267e65eea9cab77584d3cfff9" + "reference": "ac230ed27f0f98f597c8a2b6eb7ac563af5e5b9d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/65e8b7db476c5dd267e65eea9cab77584d3cfff9", - "reference": "65e8b7db476c5dd267e65eea9cab77584d3cfff9", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/ac230ed27f0f98f597c8a2b6eb7ac563af5e5b9d", + "reference": "ac230ed27f0f98f597c8a2b6eb7ac563af5e5b9d", "shasum": "" }, "require": { @@ -2757,7 +2442,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/exporter/issues", - "source": "https://github.com/sebastianbergmann/exporter/tree/4.0.4" + "source": "https://github.com/sebastianbergmann/exporter/tree/4.0.5" }, "funding": [ { @@ -2765,20 +2450,20 @@ "type": "github" } ], - "time": "2021-11-11T14:18:36+00:00" + "time": "2022-09-14T06:03:37+00:00" }, { "name": "sebastian/global-state", - "version": "5.0.5", + "version": "5.0.6", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/global-state.git", - "reference": "0ca8db5a5fc9c8646244e629625ac486fa286bf2" + "reference": "bde739e7565280bda77be70044ac1047bc007e34" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/0ca8db5a5fc9c8646244e629625ac486fa286bf2", - "reference": "0ca8db5a5fc9c8646244e629625ac486fa286bf2", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/bde739e7565280bda77be70044ac1047bc007e34", + "reference": "bde739e7565280bda77be70044ac1047bc007e34", "shasum": "" }, "require": { @@ -2821,7 +2506,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/global-state/issues", - "source": "https://github.com/sebastianbergmann/global-state/tree/5.0.5" + "source": "https://github.com/sebastianbergmann/global-state/tree/5.0.6" }, "funding": [ { @@ -2829,7 +2514,7 @@ "type": "github" } ], - "time": "2022-02-14T08:28:10+00:00" + "time": "2023-08-02T09:26:13+00:00" }, { "name": "sebastian/lines-of-code", @@ -3002,16 +2687,16 @@ }, { "name": "sebastian/recursion-context", - "version": "4.0.4", + "version": "4.0.5", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/recursion-context.git", - "reference": "cd9d8cf3c5804de4341c283ed787f099f5506172" + "reference": "e75bd0f07204fec2a0af9b0f3cfe97d05f92efc1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/cd9d8cf3c5804de4341c283ed787f099f5506172", - "reference": "cd9d8cf3c5804de4341c283ed787f099f5506172", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/e75bd0f07204fec2a0af9b0f3cfe97d05f92efc1", + "reference": "e75bd0f07204fec2a0af9b0f3cfe97d05f92efc1", "shasum": "" }, "require": { @@ -3050,10 +2735,10 @@ } ], "description": "Provides functionality to recursively process PHP variables", - "homepage": "http://www.github.com/sebastianbergmann/recursion-context", + "homepage": "https://github.com/sebastianbergmann/recursion-context", "support": { "issues": "https://github.com/sebastianbergmann/recursion-context/issues", - "source": "https://github.com/sebastianbergmann/recursion-context/tree/4.0.4" + "source": "https://github.com/sebastianbergmann/recursion-context/tree/4.0.5" }, "funding": [ { @@ -3061,7 +2746,7 @@ "type": "github" } ], - "time": "2020-10-26T13:17:30+00:00" + "time": "2023-02-03T06:07:39+00:00" }, { "name": "sebastian/resource-operations", @@ -3120,16 +2805,16 @@ }, { "name": "sebastian/type", - "version": "3.0.0", + "version": "3.2.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/type.git", - "reference": "b233b84bc4465aff7b57cf1c4bc75c86d00d6dad" + "reference": "75e2c2a32f5e0b3aef905b9ed0b179b953b3d7c7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/b233b84bc4465aff7b57cf1c4bc75c86d00d6dad", - "reference": "b233b84bc4465aff7b57cf1c4bc75c86d00d6dad", + "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/75e2c2a32f5e0b3aef905b9ed0b179b953b3d7c7", + "reference": "75e2c2a32f5e0b3aef905b9ed0b179b953b3d7c7", "shasum": "" }, "require": { @@ -3141,7 +2826,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-master": "3.2-dev" } }, "autoload": { @@ -3164,7 +2849,7 @@ "homepage": "https://github.com/sebastianbergmann/type", "support": { "issues": "https://github.com/sebastianbergmann/type/issues", - "source": "https://github.com/sebastianbergmann/type/tree/3.0.0" + "source": "https://github.com/sebastianbergmann/type/tree/3.2.1" }, "funding": [ { @@ -3172,7 +2857,7 @@ "type": "github" } ], - "time": "2022-03-15T09:54:48+00:00" + "time": "2023-02-03T06:13:03+00:00" }, { "name": "sebastian/version", @@ -3276,64 +2961,6 @@ } ], "time": "2021-07-28T10:34:58+00:00" - }, - { - "name": "webmozart/assert", - "version": "1.11.0", - "source": { - "type": "git", - "url": "https://github.com/webmozarts/assert.git", - "reference": "11cb2199493b2f8a3b53e7f19068fc6aac760991" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/webmozarts/assert/zipball/11cb2199493b2f8a3b53e7f19068fc6aac760991", - "reference": "11cb2199493b2f8a3b53e7f19068fc6aac760991", - "shasum": "" - }, - "require": { - "ext-ctype": "*", - "php": "^7.2 || ^8.0" - }, - "conflict": { - "phpstan/phpstan": "<0.12.20", - "vimeo/psalm": "<4.6.1 || 4.6.2" - }, - "require-dev": { - "phpunit/phpunit": "^8.5.13" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.10-dev" - } - }, - "autoload": { - "psr-4": { - "Webmozart\\Assert\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Bernhard Schussek", - "email": "bschussek@gmail.com" - } - ], - "description": "Assertions to validate method input/output with nice error messages.", - "keywords": [ - "assert", - "check", - "validate" - ], - "support": { - "issues": "https://github.com/webmozarts/assert/issues", - "source": "https://github.com/webmozarts/assert/tree/1.11.0" - }, - "time": "2022-06-03T18:03:27+00:00" } ], "aliases": [], @@ -3344,7 +2971,7 @@ "platform": [], "platform-dev": [], "platform-overrides": { - "php": "7.4" + "php": "8.2" }, "plugin-api-version": "2.0.0" } diff --git a/src/MToMModel.php b/src/MToMModel.php index bd489e9..e4b6360 100644 --- a/src/MToMModel.php +++ b/src/MToMModel.php @@ -10,17 +10,20 @@ abstract class MToMModel extends Model { /** - * array with 2 keys and 2 values. Set these four strings child classes. + * @param array $fieldNamesForReferencedClasses + * with 2 keys and 2 values. Set these four strings child classes. * Will be used to create hasOne Reference Fields in init() * e.g. [ * 'student_id' => Student::class, * 'lesson_id' => Lesson::class * ] */ - protected $fieldNamesForReferencedClasses = []; + protected array $fieldNamesForReferencedClasses = []; - //array containing instances of the two linked models. Useful for re-using them and saving DB requests - protected $referenceObjects = []; + /** + * @param array $referenceObjects containing instances of the two linked models. Useful for re-using them and saving DB requests + */ + protected array $referenceObjects = []; /** @@ -44,6 +47,7 @@ protected function init(): void } foreach ($this->fieldNamesForReferencedClasses as $fieldName => $className) { + /** @var class-string $className */ $this->hasOne($fieldName, ['model' => [$className]]); $this->referenceObjects[$className] = null; } @@ -51,11 +55,15 @@ protected function init(): void /** - * Shortcut to get a record from each of the linked classes. e.g. - * $studentToLesson = $student->addLesson(4); //add Lesson by id, no lesson object yet - * $lesson = $studentToLesson->getObject(Lesson::class); //will return Lesson record with Id 4 + * + * Shortcut to get a record from each of the linked classes. e.g. + * $studentToLesson = $student->addLesson(4); //add Lesson by ID, no lesson object yet + * $lesson = $studentToLesson->getObject(Lesson::class); //will return Lesson record with ID 4 + * + * @param string $className + * @return Model|null */ - public function getObject(string $className): ?Model + public function getReferenceEntity(string $className): ?Model { if (!array_key_exists($className, $this->referenceObjects)) { throw new Exception('Invalid className passed in ' . __FUNCTION__); @@ -75,9 +83,13 @@ public function getObject(string $className): ?Model /** - * used by ModelWithMToMTrait to make records available in getObject() without extra DB request + * used by ModelWithMToMTrait to make records available in getObject() without extra DB request + * + * @param Model $model + * @return void */ - public function addLoadedObject(Model $model): void + + public function addReferenceEntity(Model $model): void { $modelClass = get_class($model); if (!array_key_exists($modelClass, $this->referenceObjects)) { @@ -89,7 +101,10 @@ public function addLoadedObject(Model $model): void /** - * used by ModelWithMToMTrait to get the correct + * used by ModelWithMToMTrait to get the correct field name that corresponds to one of the linked Models + * + * @param Model $model + * @return string */ public function getFieldNameForModel(Model $model): string { @@ -106,16 +121,22 @@ public function getFieldNameForModel(Model $model): string /** * results ín e.g. $this->addCondition('student_id', 5); + * + * @param Model $model + * @return void */ - public function addConditionForModel(Model $model) + public function addConditionForModel(Model $model): void { $this->addCondition($this->getFieldNameForModel($model), $model->get($model->id_field)); } /** - * We will have 2 Model classes defined which the MToMmodel will connect. This function returns the class name of + * We will have 2 Model classes defined which the MToMModel will connect. This function returns the class name of * the other class if one is passed + * + * @param Model $model + * @return string */ public function getOtherModelClass(Model $model): string { diff --git a/src/ModelWithMToMTrait.php b/src/ModelWithMToMTrait.php index 536239c..bd74175 100644 --- a/src/ModelWithMToMTrait.php +++ b/src/ModelWithMToMTrait.php @@ -2,26 +2,32 @@ namespace mtomforatk; -use Atk4\Data\Exception; use Atk4\Data\Model; use Atk4\Data\Reference; /** - * Trait MToMTrait + * @extends Model */ trait ModelWithMToMTrait { /** - * Create a new MToM relation, e.g. a new StudentToLesson record. Called from either Student or Lesson class. - * First checks if record does exist already, and only then adds new relation. + * Create a new MToM relation, e.g. a new StudentToLesson record. Called from either Student or Lesson class. + * First checks if record does exist already, and only then adds new relation. + * + * @param MToMModel $mToMModel + * @param $otherModel + * @param array $additionalFields + * @return MToMModel + * @throws \Atk4\Data\Exception + * @throws \Atk4\Core\Exception */ public function addMToMRelation(MToMModel $mToMModel, $otherModel, array $additionalFields = []): MToMModel { //$this needs to be loaded to get ID - $this->checkThisIsLoaded(); - $otherModel = $this->getOtherModelRecord($otherModel, $mToMModel); + $this->assertIsLoaded(); + $otherModel = $this->getOtherEntity($otherModel, $mToMModel); //check if reference already exists, if so update existing record only $mToMModel->addConditionForModel($this); $mToMModel->addConditionForModel($otherModel); @@ -40,22 +46,26 @@ public function addMToMRelation(MToMModel $mToMModel, $otherModel, array $additi $mToMModel->reload_after_save = false; //if that record already exists mysql will throw an error if unique index is set, catch here $mToMModel->save(); - $mToMModel->addLoadedObject($this); - $mToMModel->addLoadedObject($otherModel); + $mToMModel->addReferenceEntity($this); + $mToMModel->addReferenceEntity($otherModel); return $mToMModel; } /** - * function used to remove a MToMModel record like StudentToLesson. Either used from Student or Lesson class. - * GuestToGroup etc. + * method used to remove a MToMModel record like StudentToLesson. Either used from Student or Lesson class. + * GuestToGroup etc. + * + * @param MToMModel $mToMModel + * @param $otherModel + * @return MToMModel */ public function removeMToMRelation(MToMModel $mToMModel, $otherModel): MToMModel { //$this needs to be loaded to get ID - $this->checkThisIsLoaded(); - $otherModel = $this->getOtherModelRecord($otherModel, $mToMModel); + $this->assertIsLoaded(); + $otherModel = $this->getOtherEntity($otherModel, $mToMModel); $mToMModel->addConditionForModel($this); $mToMModel->addConditionForModel($otherModel); @@ -70,11 +80,15 @@ public function removeMToMRelation(MToMModel $mToMModel, $otherModel): MToMModel /** * checks if a MtoM reference to the given object exists or not, e.g. if a StudentToLesson record exists for a * specific student and lesson + * + * @param MToMModel $mToMModel + * @param $otherModel + * @return bool */ public function hasMToMRelation(MToMModel $mToMModel, $otherModel): bool { - $this->checkThisIsLoaded(); - $otherModel = $this->getOtherModelRecord($otherModel, $mToMModel); + $this->assertIsLoaded(); + $otherModel = $this->getOtherEntity($otherModel, $mToMModel); $mToMModel->addConditionForModel($this); $mToMModel->addConditionForModel($otherModel); @@ -83,25 +97,17 @@ public function hasMToMRelation(MToMModel $mToMModel, $otherModel): bool return $mToMModel->loaded(); } - - /** - * In each MToM operation, $this needs to be loaded to pull id. This function throws an exception if its not. - */ - protected function checkThisIsLoaded(): void - { - if (!$this->loaded()) { - throw new Exception( - '$this needs to be loaded in ' . debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2)[1]['function'] - ); - } - } - - /** * 1) adds HasMany Reference to intermediate model. * 2) adds after delete hook which deletes any intermediate model linked to the deleted "main" model. - * This way, no outdated intermediate models exist. + * This way, no outdated intermediate models exist. * Returns HasMany reference for further modifying reference if needed. + * + * @param string $mtomClassName + * @param string $referenceName + * @param array $referenceDefaults + * @param array $mtomClassDefaults + * @return Reference\HasMany */ protected function addMToMReferenceAndDeleteHook( string $mtomClassName, @@ -136,15 +142,19 @@ function ($model) use ($referenceName): void { /** - * Used to load the other model if only Id was passed. + * Used to load the other model if only ID was passed. * Make sure passed model is of the correct class. * Check other model is loaded so id can be gotten. + * + * @param $otherModel + * @param MToMModel $mToMModel + * @return Model */ - protected function getOtherModelRecord($otherModel, MToMModel $mToMModel): Model + protected function getOtherEntity($otherModel, MToMModel $mToMModel): Model { $otherModelClass = $mToMModel->getOtherModelClass($this); if (is_object($otherModel)) { - //only check if its a model of the correct class; also check if accidently $this was passed + //only check if it's a model of the correct class; also check if accidentally $this was passed if (get_class($otherModel) !== $otherModelClass) { throw new Exception( 'Object of wrong class was passed: ' . $mToMModel->getOtherModelClass($this) diff --git a/tests/MToMModelTest.php b/tests/MToMModelTest.php index 0b88460..9178df7 100644 --- a/tests/MToMModelTest.php +++ b/tests/MToMModelTest.php @@ -86,7 +86,7 @@ public function testAddLoadedObject() $student = new Student($persistence); $student->save(); $studentToLesson = new StudentToLesson($persistence); - $studentToLesson->addLoadedObject($student); + $studentToLesson->addReferenceEntity($student); $props = (new \ReflectionClass($studentToLesson))->getProperty( 'referenceObjects' );//getProperties(\ReflectionProperty::IS_PROTECTED); @@ -107,7 +107,7 @@ public function testAddLoadedObjectExceptionWrongClassPassed() $model = new $otherClass($persistence); $studentToLesson = new StudentToLesson($persistence); self::expectException(Exception::class); - $studentToLesson->addLoadedObject($model); + $studentToLesson->addReferenceEntity($model); } public function testgetObject() @@ -121,14 +121,14 @@ public function testgetObject() //gets loaded from DB $studentToLesson->set('student_id', $student->get('id')); - $resA = $studentToLesson->getObject(Student::class); + $resA = $studentToLesson->getReferenceEntity(Student::class); //different Object but same ID self::assertNotSame($student, $resA); self::assertSame($student->get('id'), $resA->get('id')); //is put in referenceObjects Array, should return same object - $studentToLesson->addLoadedObject($lesson); - $resB = $studentToLesson->getObject(Lesson::class); + $studentToLesson->addReferenceEntity($lesson); + $resB = $studentToLesson->getReferenceEntity(Lesson::class); self::assertSame($lesson, $resB); } @@ -137,7 +137,7 @@ public function testgetObjectExceptionInvalidClass() $persistence = $this->getSqliteTestPersistence(); $studentToLesson = new StudentToLesson($persistence); self::expectException(Exception::class); - $resA = $studentToLesson->getObject('SomeNonSetClass'); + $resA = $studentToLesson->getReferenceEntity('SomeNonSetClass'); } public function testgetFieldNameForModel()