From abc67cf6342a85978de5464582ac47c0398896c8 Mon Sep 17 00:00:00 2001 From: Henrique Silva Date: Wed, 29 Mar 2023 15:19:35 -0300 Subject: [PATCH] chore: add compatibility with PHP 8.2 - remove compatibility with php 7.4 - remove compatibility with illuminate packages 5.4, 6.0 and 7.0 - remove compatibility with mongodb 3.6, 4.0 and 4.2 - add compatibility with illuminate packages 9.0 and 10.0 - bump php container to version 8.0 - bump xdebug to version 3.2.1 --- .github/workflows/continuous-integration.yml | 9 +- composer.json | 13 +- composer.lock | 579 ++++++++----------- docker-compose.yml | 2 +- docker/php/Dockerfile | 4 +- phpunit.xml.dist | 3 +- src/Cursor/Cursor.php | 27 +- src/Cursor/EmbeddedCursor.php | 26 +- src/Cursor/SchemaCursor.php | 36 +- src/Cursor/SchemaEmbeddedCursor.php | 30 +- src/LegacyRecord.php | 13 +- src/Model/AbstractModel.php | 8 +- tests/Unit/Cursor/CursorTest.php | 11 +- tests/Unit/Cursor/SchemaCursorTest.php | 6 +- 14 files changed, 314 insertions(+), 453 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 5dc32bcd..3109f982 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -9,13 +9,10 @@ jobs: strategy: matrix: php: - - "7.4" - "8.0" - "8.1" + - "8.2" mongo: - - "3.6" - - "4.0" - - "4.2" - "4.4" services: mongodb: @@ -24,7 +21,7 @@ jobs: - "27017:27017" steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: PHP setup uses: shivammathur/setup-php@v2 @@ -32,7 +29,7 @@ jobs: php-version: ${{ matrix.php }} - name: Composer - uses: ramsey/composer-install@v1 + uses: ramsey/composer-install@v2 - name: Running tests run: vendor/bin/phpunit -c phpunit.xml.dist --coverage-clover=./coverage/clover.xml diff --git a/composer.json b/composer.json index bf369b62..d82a28fe 100644 --- a/composer.json +++ b/composer.json @@ -18,17 +18,16 @@ } ], "require": { - "php": ">=7.4", + "php": ">=8.0", "ext-mongodb": "*", - "illuminate/container": "^5.4 || ^6.0 || ^7.0 || ^8.0", - "illuminate/support": "^5.4 || ^6.0 || ^7.0 || ^8.0", + "illuminate/container": "^8.0 || ^9.0 || ^10.0", + "illuminate/support": "^8.0 || ^9.0 || ^10.0", "mongodb/mongodb": "^1.15" }, "require-dev": { - "leroy-merlin-br/coding-standard": "^3.1.0", - "mockery/mockery": "^1.5.1", - "phpunit/phpunit": "^9.5.27", - "symfony/var-dumper": "^5.4.14" + "leroy-merlin-br/coding-standard": "^v3.1.0", + "mockery/mockery": "^1.2", + "phpunit/phpunit": "^9.0" }, "autoload": { "psr-4": { diff --git a/composer.lock b/composer.lock index c5ad4155..c3bbd42b 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": "f2560bf716b48a9a0f9e6cfb90b76ea1", + "content-hash": "7328dc36b1a6971e2e5e6958c337fc32", "packages": [ { "name": "doctrine/inflector", @@ -99,30 +99,31 @@ }, { "name": "illuminate/collections", - "version": "v8.83.27", + "version": "v9.52.5", "source": { "type": "git", "url": "https://github.com/illuminate/collections.git", - "reference": "705a4e1ef93cd492c45b9b3e7911cccc990a07f4" + "reference": "0168d0e44ea0c4fe5451fe08cde7049b9e9f9741" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/collections/zipball/705a4e1ef93cd492c45b9b3e7911cccc990a07f4", - "reference": "705a4e1ef93cd492c45b9b3e7911cccc990a07f4", + "url": "https://api.github.com/repos/illuminate/collections/zipball/0168d0e44ea0c4fe5451fe08cde7049b9e9f9741", + "reference": "0168d0e44ea0c4fe5451fe08cde7049b9e9f9741", "shasum": "" }, "require": { - "illuminate/contracts": "^8.0", - "illuminate/macroable": "^8.0", - "php": "^7.3|^8.0" + "illuminate/conditionable": "^9.0", + "illuminate/contracts": "^9.0", + "illuminate/macroable": "^9.0", + "php": "^8.0.2" }, "suggest": { - "symfony/var-dumper": "Required to use the dump method (^5.4)." + "symfony/var-dumper": "Required to use the dump method (^6.0)." }, "type": "library", "extra": { "branch-alias": { - "dev-master": "8.x-dev" + "dev-master": "9.x-dev" } }, "autoload": { @@ -149,34 +150,80 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2022-06-23T15:29:49+00:00" + "time": "2023-02-22T11:32:27+00:00" + }, + { + "name": "illuminate/conditionable", + "version": "v9.52.5", + "source": { + "type": "git", + "url": "https://github.com/illuminate/conditionable.git", + "reference": "bea24daa0fa84b7e7b0d5b84f62c71b7e2dc3364" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/illuminate/conditionable/zipball/bea24daa0fa84b7e7b0d5b84f62c71b7e2dc3364", + "reference": "bea24daa0fa84b7e7b0d5b84f62c71b7e2dc3364", + "shasum": "" + }, + "require": { + "php": "^8.0.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "9.x-dev" + } + }, + "autoload": { + "psr-4": { + "Illuminate\\Support\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylor@laravel.com" + } + ], + "description": "The Illuminate Conditionable package.", + "homepage": "https://laravel.com", + "support": { + "issues": "https://github.com/laravel/framework/issues", + "source": "https://github.com/laravel/framework" + }, + "time": "2023-02-01T21:42:32+00:00" }, { "name": "illuminate/container", - "version": "v8.83.27", + "version": "v9.52.5", "source": { "type": "git", "url": "https://github.com/illuminate/container.git", - "reference": "14062628d05f75047c5a1360b9350028427d568e" + "reference": "1641dda2d0750b68bb1264a3b37ff3973f2e6265" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/container/zipball/14062628d05f75047c5a1360b9350028427d568e", - "reference": "14062628d05f75047c5a1360b9350028427d568e", + "url": "https://api.github.com/repos/illuminate/container/zipball/1641dda2d0750b68bb1264a3b37ff3973f2e6265", + "reference": "1641dda2d0750b68bb1264a3b37ff3973f2e6265", "shasum": "" }, "require": { - "illuminate/contracts": "^8.0", - "php": "^7.3|^8.0", - "psr/container": "^1.0" + "illuminate/contracts": "^9.0", + "php": "^8.0.2", + "psr/container": "^1.1.1|^2.0.1" }, "provide": { - "psr/container-implementation": "1.0" + "psr/container-implementation": "1.1|2.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "8.x-dev" + "dev-master": "9.x-dev" } }, "autoload": { @@ -200,31 +247,31 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2022-02-02T21:03:35+00:00" + "time": "2023-01-24T16:54:18+00:00" }, { "name": "illuminate/contracts", - "version": "v8.83.27", + "version": "v9.52.5", "source": { "type": "git", "url": "https://github.com/illuminate/contracts.git", - "reference": "5e0fd287a1b22a6b346a9f7cd484d8cf0234585d" + "reference": "44f65d723b13823baa02ff69751a5948bde60c22" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/contracts/zipball/5e0fd287a1b22a6b346a9f7cd484d8cf0234585d", - "reference": "5e0fd287a1b22a6b346a9f7cd484d8cf0234585d", + "url": "https://api.github.com/repos/illuminate/contracts/zipball/44f65d723b13823baa02ff69751a5948bde60c22", + "reference": "44f65d723b13823baa02ff69751a5948bde60c22", "shasum": "" }, "require": { - "php": "^7.3|^8.0", - "psr/container": "^1.0", - "psr/simple-cache": "^1.0" + "php": "^8.0.2", + "psr/container": "^1.1.1|^2.0.1", + "psr/simple-cache": "^1.0|^2.0|^3.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "8.x-dev" + "dev-master": "9.x-dev" } }, "autoload": { @@ -248,29 +295,29 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2022-01-13T14:47:47+00:00" + "time": "2023-02-08T14:36:30+00:00" }, { "name": "illuminate/macroable", - "version": "v8.83.27", + "version": "v9.52.5", "source": { "type": "git", "url": "https://github.com/illuminate/macroable.git", - "reference": "aed81891a6e046fdee72edd497f822190f61c162" + "reference": "e3bfaf6401742a9c6abca61b9b10e998e5b6449a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/macroable/zipball/aed81891a6e046fdee72edd497f822190f61c162", - "reference": "aed81891a6e046fdee72edd497f822190f61c162", + "url": "https://api.github.com/repos/illuminate/macroable/zipball/e3bfaf6401742a9c6abca61b9b10e998e5b6449a", + "reference": "e3bfaf6401742a9c6abca61b9b10e998e5b6449a", "shasum": "" }, "require": { - "php": "^7.3|^8.0" + "php": "^8.0.2" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "8.x-dev" + "dev-master": "9.x-dev" } }, "autoload": { @@ -294,48 +341,51 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2021-11-16T13:57:03+00:00" + "time": "2022-08-09T13:29:29+00:00" }, { "name": "illuminate/support", - "version": "v8.83.27", + "version": "v9.52.5", "source": { "type": "git", "url": "https://github.com/illuminate/support.git", - "reference": "1c79242468d3bbd9a0f7477df34f9647dde2a09b" + "reference": "199e5250735d0c49fe0385360451659690ff71a3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/support/zipball/1c79242468d3bbd9a0f7477df34f9647dde2a09b", - "reference": "1c79242468d3bbd9a0f7477df34f9647dde2a09b", + "url": "https://api.github.com/repos/illuminate/support/zipball/199e5250735d0c49fe0385360451659690ff71a3", + "reference": "199e5250735d0c49fe0385360451659690ff71a3", "shasum": "" }, "require": { - "doctrine/inflector": "^1.4|^2.0", - "ext-json": "*", + "doctrine/inflector": "^2.0", + "ext-ctype": "*", + "ext-filter": "*", "ext-mbstring": "*", - "illuminate/collections": "^8.0", - "illuminate/contracts": "^8.0", - "illuminate/macroable": "^8.0", - "nesbot/carbon": "^2.53.1", - "php": "^7.3|^8.0", - "voku/portable-ascii": "^1.6.1" + "illuminate/collections": "^9.0", + "illuminate/conditionable": "^9.0", + "illuminate/contracts": "^9.0", + "illuminate/macroable": "^9.0", + "nesbot/carbon": "^2.62.1", + "php": "^8.0.2", + "voku/portable-ascii": "^2.0" }, "conflict": { "tightenco/collect": "<5.5.33" }, "suggest": { - "illuminate/filesystem": "Required to use the composer class (^8.0).", - "league/commonmark": "Required to use Str::markdown() and Stringable::markdown() (^1.3|^2.0.2).", - "ramsey/uuid": "Required to use Str::uuid() (^4.2.2).", - "symfony/process": "Required to use the composer class (^5.4).", - "symfony/var-dumper": "Required to use the dd function (^5.4).", + "illuminate/filesystem": "Required to use the composer class (^9.0).", + "league/commonmark": "Required to use Str::markdown() and Stringable::markdown() (^2.0.2).", + "ramsey/uuid": "Required to use Str::uuid() (^4.7).", + "symfony/process": "Required to use the composer class (^6.0).", + "symfony/uid": "Required to use Str::ulid() (^6.0).", + "symfony/var-dumper": "Required to use the dd function (^6.0).", "vlucas/phpdotenv": "Required to use the Env class and env helper (^5.4.1)." }, "type": "library", "extra": { "branch-alias": { - "dev-master": "8.x-dev" + "dev-master": "9.x-dev" } }, "autoload": { @@ -362,7 +412,7 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2022-09-21T21:30:03+00:00" + "time": "2023-03-13T01:37:31+00:00" }, { "name": "jean85/pretty-package-versions", @@ -495,16 +545,16 @@ }, { "name": "nesbot/carbon", - "version": "2.64.0", + "version": "2.66.0", "source": { "type": "git", "url": "https://github.com/briannesbitt/Carbon.git", - "reference": "889546413c97de2d05063b8cb7b193c2531ea211" + "reference": "496712849902241f04902033b0441b269effe001" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/889546413c97de2d05063b8cb7b193c2531ea211", - "reference": "889546413c97de2d05063b8cb7b193c2531ea211", + "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/496712849902241f04902033b0441b269effe001", + "reference": "496712849902241f04902033b0441b269effe001", "shasum": "" }, "require": { @@ -593,26 +643,31 @@ "type": "tidelift" } ], - "time": "2022-11-26T17:36:00+00:00" + "time": "2023-01-29T18:53:47+00:00" }, { "name": "psr/container", - "version": "1.1.2", + "version": "2.0.2", "source": { "type": "git", "url": "https://github.com/php-fig/container.git", - "reference": "513e0666f7216c7459170d56df27dfcefe1689ea" + "reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/container/zipball/513e0666f7216c7459170d56df27dfcefe1689ea", - "reference": "513e0666f7216c7459170d56df27dfcefe1689ea", + "url": "https://api.github.com/repos/php-fig/container/zipball/c71ecc56dfe541dbd90c5360474fbc405f8d5963", + "reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963", "shasum": "" }, "require": { "php": ">=7.4.0" }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, "autoload": { "psr-4": { "Psr\\Container\\": "src/" @@ -639,31 +694,31 @@ ], "support": { "issues": "https://github.com/php-fig/container/issues", - "source": "https://github.com/php-fig/container/tree/1.1.2" + "source": "https://github.com/php-fig/container/tree/2.0.2" }, - "time": "2021-11-05T16:50:12+00:00" + "time": "2021-11-05T16:47:00+00:00" }, { "name": "psr/simple-cache", - "version": "1.0.1", + "version": "3.0.0", "source": { "type": "git", "url": "https://github.com/php-fig/simple-cache.git", - "reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b" + "reference": "764e0b3939f5ca87cb904f570ef9be2d78a07865" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/simple-cache/zipball/408d5eafb83c57f6365a3ca330ff23aa4a5fa39b", - "reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b", + "url": "https://api.github.com/repos/php-fig/simple-cache/zipball/764e0b3939f5ca87cb904f570ef9be2d78a07865", + "reference": "764e0b3939f5ca87cb904f570ef9be2d78a07865", "shasum": "" }, "require": { - "php": ">=5.3.0" + "php": ">=8.0.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "3.0.x-dev" } }, "autoload": { @@ -678,7 +733,7 @@ "authors": [ { "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" + "homepage": "https://www.php-fig.org/" } ], "description": "Common interfaces for simple caching", @@ -690,76 +745,9 @@ "simple-cache" ], "support": { - "source": "https://github.com/php-fig/simple-cache/tree/master" - }, - "time": "2017-10-23T01:57:42+00:00" - }, - { - "name": "symfony/deprecation-contracts", - "version": "v2.5.2", - "source": { - "type": "git", - "url": "https://github.com/symfony/deprecation-contracts.git", - "reference": "e8b495ea28c1d97b5e0c121748d6f9b53d075c66" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/e8b495ea28c1d97b5e0c121748d6f9b53d075c66", - "reference": "e8b495ea28c1d97b5e0c121748d6f9b53d075c66", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "2.5-dev" - }, - "thanks": { - "name": "symfony/contracts", - "url": "https://github.com/symfony/contracts" - } - }, - "autoload": { - "files": [ - "function.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "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/php-fig/simple-cache/tree/3.0.0" }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2022-01-02T09:53:40+00:00" + "time": "2021-10-29T13:26:27+00:00" }, { "name": "symfony/polyfill-mbstring", @@ -929,48 +917,46 @@ }, { "name": "symfony/translation", - "version": "v5.4.14", + "version": "v6.0.19", "source": { "type": "git", "url": "https://github.com/symfony/translation.git", - "reference": "f0ed07675863aa6e3939df8b1bc879450b585cab" + "reference": "9c24b3fdbbe9fb2ef3a6afd8bbaadfd72dad681f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/translation/zipball/f0ed07675863aa6e3939df8b1bc879450b585cab", - "reference": "f0ed07675863aa6e3939df8b1bc879450b585cab", + "url": "https://api.github.com/repos/symfony/translation/zipball/9c24b3fdbbe9fb2ef3a6afd8bbaadfd72dad681f", + "reference": "9c24b3fdbbe9fb2ef3a6afd8bbaadfd72dad681f", "shasum": "" }, "require": { - "php": ">=7.2.5", - "symfony/deprecation-contracts": "^2.1|^3", + "php": ">=8.0.2", "symfony/polyfill-mbstring": "~1.0", - "symfony/polyfill-php80": "^1.16", - "symfony/translation-contracts": "^2.3" + "symfony/translation-contracts": "^2.3|^3.0" }, "conflict": { - "symfony/config": "<4.4", - "symfony/console": "<5.3", - "symfony/dependency-injection": "<5.0", - "symfony/http-kernel": "<5.0", - "symfony/twig-bundle": "<5.0", - "symfony/yaml": "<4.4" + "symfony/config": "<5.4", + "symfony/console": "<5.4", + "symfony/dependency-injection": "<5.4", + "symfony/http-kernel": "<5.4", + "symfony/twig-bundle": "<5.4", + "symfony/yaml": "<5.4" }, "provide": { - "symfony/translation-implementation": "2.3" + "symfony/translation-implementation": "2.3|3.0" }, "require-dev": { "psr/log": "^1|^2|^3", - "symfony/config": "^4.4|^5.0|^6.0", + "symfony/config": "^5.4|^6.0", "symfony/console": "^5.4|^6.0", - "symfony/dependency-injection": "^5.0|^6.0", - "symfony/finder": "^4.4|^5.0|^6.0", + "symfony/dependency-injection": "^5.4|^6.0", + "symfony/finder": "^5.4|^6.0", "symfony/http-client-contracts": "^1.1|^2.0|^3.0", - "symfony/http-kernel": "^5.0|^6.0", - "symfony/intl": "^4.4|^5.0|^6.0", + "symfony/http-kernel": "^5.4|^6.0", + "symfony/intl": "^5.4|^6.0", "symfony/polyfill-intl-icu": "^1.21", "symfony/service-contracts": "^1.1.2|^2|^3", - "symfony/yaml": "^4.4|^5.0|^6.0" + "symfony/yaml": "^5.4|^6.0" }, "suggest": { "psr/log-implementation": "To use logging capability in translator", @@ -1006,7 +992,7 @@ "description": "Provides tools to internationalize your application", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/translation/tree/v5.4.14" + "source": "https://github.com/symfony/translation/tree/v6.0.19" }, "funding": [ { @@ -1022,24 +1008,24 @@ "type": "tidelift" } ], - "time": "2022-10-07T08:01:20+00:00" + "time": "2023-01-01T08:36:10+00:00" }, { "name": "symfony/translation-contracts", - "version": "v2.5.2", + "version": "v3.0.2", "source": { "type": "git", "url": "https://github.com/symfony/translation-contracts.git", - "reference": "136b19dd05cdf0709db6537d058bcab6dd6e2dbe" + "reference": "acbfbb274e730e5a0236f619b6168d9dedb3e282" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/translation-contracts/zipball/136b19dd05cdf0709db6537d058bcab6dd6e2dbe", - "reference": "136b19dd05cdf0709db6537d058bcab6dd6e2dbe", + "url": "https://api.github.com/repos/symfony/translation-contracts/zipball/acbfbb274e730e5a0236f619b6168d9dedb3e282", + "reference": "acbfbb274e730e5a0236f619b6168d9dedb3e282", "shasum": "" }, "require": { - "php": ">=7.2.5" + "php": ">=8.0.2" }, "suggest": { "symfony/translation-implementation": "" @@ -1047,7 +1033,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "2.5-dev" + "dev-main": "3.0-dev" }, "thanks": { "name": "symfony/contracts", @@ -1084,7 +1070,7 @@ "standards" ], "support": { - "source": "https://github.com/symfony/translation-contracts/tree/v2.5.2" + "source": "https://github.com/symfony/translation-contracts/tree/v3.0.2" }, "funding": [ { @@ -1100,20 +1086,20 @@ "type": "tidelift" } ], - "time": "2022-06-27T16:58:25+00:00" + "time": "2022-06-27T17:10:44+00:00" }, { "name": "voku/portable-ascii", - "version": "1.6.1", + "version": "2.0.1", "source": { "type": "git", "url": "https://github.com/voku/portable-ascii.git", - "reference": "87337c91b9dfacee02452244ee14ab3c43bc485a" + "reference": "b56450eed252f6801410d810c8e1727224ae0743" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/voku/portable-ascii/zipball/87337c91b9dfacee02452244ee14ab3c43bc485a", - "reference": "87337c91b9dfacee02452244ee14ab3c43bc485a", + "url": "https://api.github.com/repos/voku/portable-ascii/zipball/b56450eed252f6801410d810c8e1727224ae0743", + "reference": "b56450eed252f6801410d810c8e1727224ae0743", "shasum": "" }, "require": { @@ -1150,7 +1136,7 @@ ], "support": { "issues": "https://github.com/voku/portable-ascii/issues", - "source": "https://github.com/voku/portable-ascii/tree/1.6.1" + "source": "https://github.com/voku/portable-ascii/tree/2.0.1" }, "funding": [ { @@ -1174,7 +1160,7 @@ "type": "tidelift" } ], - "time": "2022-01-24T18:55:24+00:00" + "time": "2022-03-08T17:03:00+00:00" } ], "packages-dev": [ @@ -1255,30 +1241,30 @@ }, { "name": "doctrine/instantiator", - "version": "1.4.1", + "version": "1.5.0", "source": { "type": "git", "url": "https://github.com/doctrine/instantiator.git", - "reference": "10dcfce151b967d20fde1b34ae6640712c3891bc" + "reference": "0a0fa9780f5d4e507415a065172d26a98d02047b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/10dcfce151b967d20fde1b34ae6640712c3891bc", - "reference": "10dcfce151b967d20fde1b34ae6640712c3891bc", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/0a0fa9780f5d4e507415a065172d26a98d02047b", + "reference": "0a0fa9780f5d4e507415a065172d26a98d02047b", "shasum": "" }, "require": { "php": "^7.1 || ^8.0" }, "require-dev": { - "doctrine/coding-standard": "^9", + "doctrine/coding-standard": "^9 || ^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" + "vimeo/psalm": "^4.30 || ^5.4" }, "type": "library", "autoload": { @@ -1305,7 +1291,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/1.5.0" }, "funding": [ { @@ -1321,7 +1307,7 @@ "type": "tidelift" } ], - "time": "2022-03-03T08:28:38+00:00" + "time": "2022-12-30T00:15:36+00:00" }, { "name": "hamcrest/hamcrest-php", @@ -1495,16 +1481,16 @@ }, { "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": { @@ -1542,7 +1528,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": [ { @@ -1550,20 +1536,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.15.2", + "version": "v4.15.4", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "f59bbe44bf7d96f24f3e2b4ddc21cd52c1d2adbc" + "reference": "6bb5176bc4af8bcb7d926f88718db9b96a2d4290" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/f59bbe44bf7d96f24f3e2b4ddc21cd52c1d2adbc", - "reference": "f59bbe44bf7d96f24f3e2b4ddc21cd52c1d2adbc", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/6bb5176bc4af8bcb7d926f88718db9b96a2d4290", + "reference": "6bb5176bc4af8bcb7d926f88718db9b96a2d4290", "shasum": "" }, "require": { @@ -1604,9 +1590,9 @@ ], "support": { "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/v4.15.2" + "source": "https://github.com/nikic/PHP-Parser/tree/v4.15.4" }, - "time": "2022-11-12T15:38:23+00:00" + "time": "2023-03-05T19:49:14+00:00" }, { "name": "phar-io/manifest", @@ -1721,16 +1707,16 @@ }, { "name": "phpstan/phpdoc-parser", - "version": "1.15.2", + "version": "1.16.1", "source": { "type": "git", "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "5941477f100993652218928039d530b75a13a9ca" + "reference": "e27e92d939e2e3636f0a1f0afaba59692c0bf571" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/5941477f100993652218928039d530b75a13a9ca", - "reference": "5941477f100993652218928039d530b75a13a9ca", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/e27e92d939e2e3636f0a1f0afaba59692c0bf571", + "reference": "e27e92d939e2e3636f0a1f0afaba59692c0bf571", "shasum": "" }, "require": { @@ -1760,29 +1746,29 @@ "description": "PHPDoc parser with support for nullable, intersection and generic types", "support": { "issues": "https://github.com/phpstan/phpdoc-parser/issues", - "source": "https://github.com/phpstan/phpdoc-parser/tree/1.15.2" + "source": "https://github.com/phpstan/phpdoc-parser/tree/1.16.1" }, - "time": "2022-12-16T06:42:48+00:00" + "time": "2023-02-07T18:11:17+00:00" }, { "name": "phpunit/php-code-coverage", - "version": "9.2.22", + "version": "9.2.26", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "e4bf60d2220b4baaa0572986b5d69870226b06df" + "reference": "443bc6912c9bd5b409254a40f4b0f4ced7c80ea1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/e4bf60d2220b4baaa0572986b5d69870226b06df", - "reference": "e4bf60d2220b4baaa0572986b5d69870226b06df", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/443bc6912c9bd5b409254a40f4b0f4ced7c80ea1", + "reference": "443bc6912c9bd5b409254a40f4b0f4ced7c80ea1", "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", @@ -1797,8 +1783,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": { @@ -1831,7 +1817,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.22" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.26" }, "funding": [ { @@ -1839,7 +1825,7 @@ "type": "github" } ], - "time": "2022-12-18T16:40:55+00:00" + "time": "2023-03-06T12:58:08+00:00" }, { "name": "phpunit/php-file-iterator", @@ -2084,20 +2070,20 @@ }, { "name": "phpunit/phpunit", - "version": "9.5.27", + "version": "9.6.6", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "a2bc7ffdca99f92d959b3f2270529334030bba38" + "reference": "b65d59a059d3004a040c16a82e07bbdf6cfdd115" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/a2bc7ffdca99f92d959b3f2270529334030bba38", - "reference": "a2bc7ffdca99f92d959b3f2270529334030bba38", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/b65d59a059d3004a040c16a82e07bbdf6cfdd115", + "reference": "b65d59a059d3004a040c16a82e07bbdf6cfdd115", "shasum": "" }, "require": { - "doctrine/instantiator": "^1.3.1", + "doctrine/instantiator": "^1.3.1 || ^2", "ext-dom": "*", "ext-json": "*", "ext-libxml": "*", @@ -2126,8 +2112,8 @@ "sebastian/version": "^3.0.2" }, "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" @@ -2135,7 +2121,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "9.5-dev" + "dev-master": "9.6-dev" } }, "autoload": { @@ -2166,7 +2152,8 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", - "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.27" + "security": "https://github.com/sebastianbergmann/phpunit/security/policy", + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.6" }, "funding": [ { @@ -2182,7 +2169,7 @@ "type": "tidelift" } ], - "time": "2022-12-09T07:31:23+00:00" + "time": "2023-03-27T11:43:46+00:00" }, { "name": "sebastian/cli-parser", @@ -2550,16 +2537,16 @@ }, { "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": { @@ -2601,7 +2588,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": [ { @@ -2609,7 +2596,7 @@ "type": "github" } ], - "time": "2022-04-03T09:37:03+00:00" + "time": "2023-02-03T06:03:51+00:00" }, { "name": "sebastian/exporter", @@ -2923,16 +2910,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": { @@ -2971,10 +2958,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": [ { @@ -2982,7 +2969,7 @@ "type": "github" } ], - "time": "2020-10-26T13:17:30+00:00" + "time": "2023-02-03T06:07:39+00:00" }, { "name": "sebastian/resource-operations", @@ -3041,16 +3028,16 @@ }, { "name": "sebastian/type", - "version": "3.2.0", + "version": "3.2.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/type.git", - "reference": "fb3fe09c5f0bae6bc27ef3ce933a1e0ed9464b6e" + "reference": "75e2c2a32f5e0b3aef905b9ed0b179b953b3d7c7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/fb3fe09c5f0bae6bc27ef3ce933a1e0ed9464b6e", - "reference": "fb3fe09c5f0bae6bc27ef3ce933a1e0ed9464b6e", + "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/75e2c2a32f5e0b3aef905b9ed0b179b953b3d7c7", + "reference": "75e2c2a32f5e0b3aef905b9ed0b179b953b3d7c7", "shasum": "" }, "require": { @@ -3085,7 +3072,7 @@ "homepage": "https://github.com/sebastianbergmann/type", "support": { "issues": "https://github.com/sebastianbergmann/type/issues", - "source": "https://github.com/sebastianbergmann/type/tree/3.2.0" + "source": "https://github.com/sebastianbergmann/type/tree/3.2.1" }, "funding": [ { @@ -3093,7 +3080,7 @@ "type": "github" } ], - "time": "2022-09-12T14:47:03+00:00" + "time": "2023-02-03T06:13:03+00:00" }, { "name": "sebastian/version", @@ -3211,16 +3198,16 @@ }, { "name": "squizlabs/php_codesniffer", - "version": "3.7.1", + "version": "3.7.2", "source": { "type": "git", "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "1359e176e9307e906dc3d890bcc9603ff6d90619" + "reference": "ed8e00df0a83aa96acf703f8c2979ff33341f879" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/1359e176e9307e906dc3d890bcc9603ff6d90619", - "reference": "1359e176e9307e906dc3d890bcc9603ff6d90619", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/ed8e00df0a83aa96acf703f8c2979ff33341f879", + "reference": "ed8e00df0a83aa96acf703f8c2979ff33341f879", "shasum": "" }, "require": { @@ -3256,103 +3243,15 @@ "homepage": "https://github.com/squizlabs/PHP_CodeSniffer", "keywords": [ "phpcs", - "standards" + "standards", + "static analysis" ], "support": { "issues": "https://github.com/squizlabs/PHP_CodeSniffer/issues", "source": "https://github.com/squizlabs/PHP_CodeSniffer", "wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki" }, - "time": "2022-06-18T07:21:10+00:00" - }, - { - "name": "symfony/var-dumper", - "version": "v5.4.14", - "source": { - "type": "git", - "url": "https://github.com/symfony/var-dumper.git", - "reference": "6894d06145fefebd9a4c7272baa026a1c394a430" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/var-dumper/zipball/6894d06145fefebd9a4c7272baa026a1c394a430", - "reference": "6894d06145fefebd9a4c7272baa026a1c394a430", - "shasum": "" - }, - "require": { - "php": ">=7.2.5", - "symfony/polyfill-mbstring": "~1.0", - "symfony/polyfill-php80": "^1.16" - }, - "conflict": { - "phpunit/phpunit": "<5.4.3", - "symfony/console": "<4.4" - }, - "require-dev": { - "ext-iconv": "*", - "symfony/console": "^4.4|^5.0|^6.0", - "symfony/process": "^4.4|^5.0|^6.0", - "symfony/uid": "^5.1|^6.0", - "twig/twig": "^2.13|^3.0.4" - }, - "suggest": { - "ext-iconv": "To convert non-UTF-8 strings to UTF-8 (or symfony/polyfill-iconv in case ext-iconv cannot be used).", - "ext-intl": "To show region name in time zone dump", - "symfony/console": "To use the ServerDumpCommand and/or the bin/var-dump-server script" - }, - "bin": [ - "Resources/bin/var-dump-server" - ], - "type": "library", - "autoload": { - "files": [ - "Resources/functions/dump.php" - ], - "psr-4": { - "Symfony\\Component\\VarDumper\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Provides mechanisms for walking through any arbitrary PHP variable", - "homepage": "https://symfony.com", - "keywords": [ - "debug", - "dump" - ], - "support": { - "source": "https://github.com/symfony/var-dumper/tree/v5.4.14" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2022-10-07T08:01:20+00:00" + "time": "2023-02-22T23:07:41+00:00" }, { "name": "theseer/tokenizer", @@ -3411,7 +3310,7 @@ "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": ">=7.4", + "php": ">=8.0", "ext-mongodb": "*" }, "platform-dev": [], diff --git a/docker-compose.yml b/docker-compose.yml index 88b551fe..d1f8e3f7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -11,7 +11,7 @@ services: - DB_HOST=db db: - image: mongo:4.2 + image: mongo:4.4 command: mongod --wiredTigerCacheSizeGB 0.25 deploy: resources: diff --git a/docker/php/Dockerfile b/docker/php/Dockerfile index 222bec61..e641729f 100644 --- a/docker/php/Dockerfile +++ b/docker/php/Dockerfile @@ -1,4 +1,4 @@ -FROM php:7.4-fpm +FROM php:8.0-fpm USER root:root @@ -11,7 +11,7 @@ RUN apt-get update -qq \ zlib1g-dev libicu-dev \ && apt-get clean -RUN pecl install xdebug-3.1.6 mongodb \ +RUN pecl install xdebug-3.2.1 mongodb \ && docker-php-ext-enable \ mongodb xdebug \ && docker-php-ext-configure \ diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 58543519..7894f283 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,7 +1,6 @@ diff --git a/src/Cursor/Cursor.php b/src/Cursor/Cursor.php index 8f850d0d..6006f45e 100644 --- a/src/Cursor/Cursor.php +++ b/src/Cursor/Cursor.php @@ -18,7 +18,7 @@ * 'where'. Because the mongodb library's MongoDB\Cursor is much more * limited (in that regard) than the old driver MongoCursor. */ -class Cursor implements CursorInterface, Serializable +class Cursor implements CursorInterface { /** * @var Collection @@ -159,7 +159,7 @@ public function count(): int /** * Iterator interface rewind (used in foreach). */ - public function rewind() + public function rewind(): void { try { $this->getCursor()->rewind(); @@ -174,10 +174,8 @@ public function rewind() /** * Iterator interface current. Return a model object * with cursor document. (used in foreach). - * - * @return mixed */ - public function current() + public function current(): mixed { $cursor = $this->getCursor(); @@ -186,10 +184,8 @@ public function current() /** * Returns the first element of the cursor. - * - * @return mixed */ - public function first() + public function first(): mixed { $this->rewind(); @@ -208,10 +204,8 @@ public function fresh() /** * Iterator key method (used in foreach). - * - * @return int */ - public function key() + public function key(): int { return $this->position; } @@ -219,7 +213,7 @@ public function key() /** * Iterator next method (used in foreach). */ - public function next() + public function next(): void { ++$this->position; $this->getCursor()->next(); @@ -265,15 +259,14 @@ public function toArray(): array * Serializes this object storing the collection name instead of the actual * MongoDb\Collection (which is unserializable). * - * @return string serialized object */ - public function serialize() + public function __serialize(): array { $properties = get_object_vars($this); $properties['collection'] = $this->collection->getCollectionName(); unset($properties['cursor']); - return serialize($properties); + return $properties; } /** @@ -281,10 +274,8 @@ public function serialize() * * @param mixed $serialized serialized cursor */ - public function unserialize($serialized) + public function __unserialize($attributes): void { - $attributes = unserialize($serialized); - $connection = Container::make(Connection::class); $db = $connection->defaultDatabase; $collectionObject = $connection->getClient()->$db->{$attributes['collection']}; diff --git a/src/Cursor/EmbeddedCursor.php b/src/Cursor/EmbeddedCursor.php index 7bd9e1ad..e2f06b85 100644 --- a/src/Cursor/EmbeddedCursor.php +++ b/src/Cursor/EmbeddedCursor.php @@ -95,9 +95,9 @@ public function skip(int $amount): CursorInterface /** * Counts the number of results for this cursor. * - * @return int the number of documents returned by this cursor's query + * returns the number of documents returned by this cursor's query */ - public function count() + public function count(): int { return count($this->items); } @@ -105,7 +105,7 @@ public function count() /** * Iterator interface rewind (used in foreach). */ - public function rewind() + public function rewind(): void { $this->position = 0; } @@ -116,17 +116,15 @@ public function rewind() * * @return mixed */ - public function current() + public function current(): mixed { return $this->items[$this->position] ?? null; } /** * Returns the first element of the cursor. - * - * @return mixed */ - public function first() + public function first(): mixed { $this->rewind(); @@ -135,10 +133,8 @@ public function first() /** * Iterator key method (used in foreach). - * - * @return int */ - public function key() + public function key(): int { return $this->position; } @@ -146,25 +142,21 @@ public function key() /** * Iterator next method (used in foreach). */ - public function next() + public function next(): void { ++$this->position; } /** * Iterator valid method (used in foreach). - * - * @return bool */ - public function valid() + public function valid(): bool { return isset($this->items[$this->position]); } /** * Convert the cursor instance to an array of Items. - * - * @return array */ public function all(): array { @@ -177,8 +169,6 @@ public function all(): array /** * Return the raw cursor items. - * - * @return array */ public function toArray(): array { diff --git a/src/Cursor/SchemaCursor.php b/src/Cursor/SchemaCursor.php index eb000cd6..ea956852 100644 --- a/src/Cursor/SchemaCursor.php +++ b/src/Cursor/SchemaCursor.php @@ -22,7 +22,7 @@ * 'where'. Because the mongodb library's MongoDB\Cursor is much more * limited (in that regard) than the old driver MongoCursor. */ -class SchemaCursor implements CursorInterface, Serializable +class SchemaCursor implements CursorInterface { /** * Schema that describes the entity that will be retrieved when iterating through the cursor. @@ -185,7 +185,7 @@ public function params(): array /** * Iterator interface rewind (used in foreach). */ - public function rewind() + public function rewind(): void { try { $this->getCursor()->rewind(); @@ -200,10 +200,8 @@ public function rewind() /** * Iterator interface current. Return a model object * with cursor document. (used in foreach). - * - * @return mixed */ - public function current() + public function current(): mixed { $document = $this->getCursor()->current(); @@ -222,16 +220,14 @@ public function current() /** * Returns the first element of the cursor. - * - * @return mixed */ - public function first() + public function first(): mixed { $this->rewind(); $document = $this->getCursor()->current(); if (!$document) { - return; + return null; } return $this->getAssembler()->assemble($document, $this->entitySchema); @@ -242,17 +238,15 @@ public function first() * through it again. A new request to the database will be made in the next * iteration. */ - public function fresh() + public function fresh(): void { $this->cursor = null; } /** * Iterator key method (used in foreach). - * - * @return int */ - public function key() + public function key(): int { return $this->position; } @@ -260,7 +254,7 @@ public function key() /** * Iterator next method (used in foreach). */ - public function next() + public function next(): void { ++$this->position; $this->getCursor()->next(); @@ -268,8 +262,6 @@ public function next() /** * Iterator valid method (used in foreach). - * - * @return bool */ public function valid(): bool { @@ -278,8 +270,6 @@ public function valid(): bool /** * Convert the cursor instance to an array of Objects. - * - * @return array */ public function all(): array { @@ -292,8 +282,6 @@ public function all(): array /** * Convert the cursor instance to a full associative array. - * - * @return array */ public function toArray(): array { @@ -342,12 +330,12 @@ protected function getAssembler() * * @return string serialized object */ - public function serialize() + public function __serialize(): array { $properties = get_object_vars($this); $properties['collection'] = $this->collection->getCollectionName(); - return serialize($properties); + return $properties; } /** @@ -355,10 +343,8 @@ public function serialize() * * @param mixed $serialized serialized cursor */ - public function unserialize($serialized) + public function __unserialize($attributes): void { - $attributes = unserialize($serialized); - $connection = Container::make(Connection::class); $client = $connection->getClient(); diff --git a/src/Cursor/SchemaEmbeddedCursor.php b/src/Cursor/SchemaEmbeddedCursor.php index 28c7c6f2..19232b75 100644 --- a/src/Cursor/SchemaEmbeddedCursor.php +++ b/src/Cursor/SchemaEmbeddedCursor.php @@ -111,9 +111,9 @@ public function skip(int $amount): CursorInterface /** * Counts the number of results for this cursor. * - * @return int the number of documents returned by this cursor's query + * returns the number of documents returned by this cursor's query */ - public function count() + public function count(): int { return count($this->items); } @@ -121,7 +121,7 @@ public function count() /** * Iterator interface rewind (used in foreach). */ - public function rewind() + public function rewind(): void { $this->position = 0; } @@ -129,13 +129,11 @@ public function rewind() /** * Iterator interface current. Return a model object * with cursor document. (used in foreach). - * - * @return mixed */ - public function current() + public function current(): mixed { if (!$this->valid()) { - return; + return null; } $document = $this->items[$this->position]; @@ -172,10 +170,8 @@ protected function getSchemaForEntity(): Schema /** * Returns the first element of the cursor. - * - * @return mixed */ - public function first() + public function first(): mixed { $this->rewind(); @@ -184,10 +180,8 @@ public function first() /** * Iterator key method (used in foreach). - * - * @return int */ - public function key() + public function key(): int { return $this->position; } @@ -195,25 +189,21 @@ public function key() /** * Iterator next method (used in foreach). */ - public function next() + public function next(): void { ++$this->position; } /** * Iterator valid method (used in foreach). - * - * @return bool */ - public function valid() + public function valid(): bool { return isset($this->items[$this->position]); } /** * Convert the cursor instance to an array of Items. - * - * @return array */ public function all(): array { @@ -226,8 +216,6 @@ public function all(): array /** * Return the raw cursor items. - * - * @return array */ public function toArray(): array { diff --git a/src/LegacyRecord.php b/src/LegacyRecord.php index 3e766cb3..fa78499e 100644 --- a/src/LegacyRecord.php +++ b/src/LegacyRecord.php @@ -1,6 +1,7 @@ getCollection(); } - public function bsonSerialize() + /** + * @return array|object + * @throws BindingResolutionException + */ + public function bsonSerialize(): object|array { return Container::make(ModelMapper::class) ->map($this, array_merge($this->fillable, $this->guarded), $this->dynamic, $this->timestamps); } - public function bsonUnserialize(array $data) + /** + * @param array $data + * @return void + */ + public function bsonUnserialize(array $data): void { $this->fill($data, true); diff --git a/src/Model/AbstractModel.php b/src/Model/AbstractModel.php index ec1e025d..93f47c6f 100644 --- a/src/Model/AbstractModel.php +++ b/src/Model/AbstractModel.php @@ -1,6 +1,7 @@ writeConcern = $writeConcern; } - public function bsonSerialize() + /** + * @throws BindingResolutionException + */ + public function bsonSerialize(): object|array { return Container::make(ModelMapper::class) ->map($this, array_merge($this->fillable, $this->guarded), $this->dynamic, $this->timestamps); } - public function bsonUnserialize(array $data) + public function bsonUnserialize(array $data): void { unset($data['__pclass']); static::fill($data, $this, true); diff --git a/tests/Unit/Cursor/CursorTest.php b/tests/Unit/Cursor/CursorTest.php index 0f75035f..d10b4660 100644 --- a/tests/Unit/Cursor/CursorTest.php +++ b/tests/Unit/Cursor/CursorTest.php @@ -499,23 +499,22 @@ protected function getCursor( * Since the MongoDB\Collection is not serializable. This method will * emulate an unserializable collection from mongoDb driver. */ - protected function getDriverCollection(): Serializable + protected function getDriverCollection() { /* * Emulates a MongoDB\Collection non serializable behavior. */ - return new class() implements Serializable - { - public function serialize() + return new class() { + public function __serialize() { throw new Exception('Unable to serialize', 1); } - public function unserialize($serialized) + public function __unserialize($serialized) { } - public function getCollectionName(): string + public function getCollectionName() { return 'my_collection'; } diff --git a/tests/Unit/Cursor/SchemaCursorTest.php b/tests/Unit/Cursor/SchemaCursorTest.php index ade8e910..1933e6a2 100644 --- a/tests/Unit/Cursor/SchemaCursorTest.php +++ b/tests/Unit/Cursor/SchemaCursorTest.php @@ -394,13 +394,13 @@ protected function getDriverCollection() /* * Emulates a MongoDB\Collection non serializable behavior. */ - return new class() implements \Serializable { - public function serialize() + return new class() { + public function __serialize() { throw new Exception('Unable to serialize', 1); } - public function unserialize($serialized) + public function __unserialize($serialized) { }