diff --git a/.gitattributes b/.gitattributes index b6773a3..bf1a390 100644 --- a/.gitattributes +++ b/.gitattributes @@ -15,5 +15,5 @@ /CHANGELOG.md export-ignore /phpunit.xml export-ignore /.php-cs-fixer.dist.php export-ignore -/phpstan.neon export-ignore +/psalm.xml export-ignore /docker-compose.yml export-ignore diff --git a/.github/workflows/phpunit.yml b/.github/workflows/check.yml similarity index 56% rename from .github/workflows/phpunit.yml rename to .github/workflows/check.yml index 54cf578..9fc7373 100644 --- a/.github/workflows/phpunit.yml +++ b/.github/workflows/check.yml @@ -1,4 +1,4 @@ -name: PHPUnit & PHPStan +name: PHPUnit & Psalm on: [push] @@ -9,8 +9,17 @@ jobs: phpunit: runs-on: ubuntu-latest + strategy: + matrix: + include: + - php: '8.0' + - php: '8.1' + - php: '8.2' steps: - - uses: actions/checkout@v3 + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 2 - name: Copy .env run: php -r "file_exists('.env') || copy('.env.example', '.env');" @@ -25,16 +34,9 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: 8.0 - - - name: Cache Composer packages - id: composer-cache - uses: actions/cache@v3 - with: - path: vendor - key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} - restore-keys: | - ${{ runner.os }}-php- + coverage: "none" + php-version: "${{ matrix.php }}" + tools: flex - name: Install dependencies run: composer install --prefer-dist --no-progress @@ -47,29 +49,30 @@ jobs: - name: PHPUnit run: ./vendor/bin/phpunit + psalm: + name: Psalm + runs-on: Ubuntu-20.04 - phpstan: - runs-on: ubuntu-latest - + env: + php-version: '8.0' steps: - - uses: actions/checkout@v3 - - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: 8.0 + php-version: ${{ env.php-version }} + ini-values: "memory_limit=-1" + coverage: none - - name: Cache Composer packages - id: composer-cache - uses: actions/cache@v3 + - name: Checkout target branch + uses: actions/checkout@v4 with: - path: vendor - key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} - restore-keys: | - ${{ runner.os }}-php- + ref: ${{ github.base_ref }} + + - name: Checkout PR + uses: actions/checkout@v4 - name: Install dependencies run: composer install --prefer-dist --no-progress - - name: PHPStan - run: ./vendor/bin/phpstan analyze --xdebug --memory-limit 512M + - name: Psalm + run: ./vendor/bin/psalm --output-format=github --no-progress diff --git a/composer.json b/composer.json index 3f87311..a9e26f4 100644 --- a/composer.json +++ b/composer.json @@ -39,8 +39,8 @@ "fakerphp/faker": "^1.9", "friendsofphp/php-cs-fixer": "^3.13", "orchestra/testbench": "^7.19", - "phpstan/phpstan": "^1.9", "phpunit/phpunit": "9.*", + "vimeo/psalm": "^5.13", "vlucas/phpdotenv": "5.5.x-dev" }, "extra": { diff --git a/composer.lock b/composer.lock index 9aaf57f..05bf2d1 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": "cf1e1280751396dc6e92e74c800a662b", + "content-hash": "a6486c6ab4e2d5f8e1e17e3bd65831f5", "packages": [ { "name": "brick/math", @@ -4703,6 +4703,166 @@ } ], "packages-dev": [ + { + "name": "amphp/amp", + "version": "v2.6.4", + "source": { + "type": "git", + "url": "https://github.com/amphp/amp.git", + "reference": "ded3d9be08f526089eb7ee8d9f16a9768f9dec2d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/amphp/amp/zipball/ded3d9be08f526089eb7ee8d9f16a9768f9dec2d", + "reference": "ded3d9be08f526089eb7ee8d9f16a9768f9dec2d", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "require-dev": { + "amphp/php-cs-fixer-config": "dev-master", + "amphp/phpunit-util": "^1", + "ext-json": "*", + "jetbrains/phpstorm-stubs": "^2019.3", + "phpunit/phpunit": "^7 | ^8 | ^9", + "react/promise": "^2", + "vimeo/psalm": "^3.12" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.x-dev" + } + }, + "autoload": { + "files": [ + "lib/functions.php", + "lib/Internal/functions.php" + ], + "psr-4": { + "Amp\\": "lib" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Daniel Lowrey", + "email": "rdlowrey@php.net" + }, + { + "name": "Aaron Piotrowski", + "email": "aaron@trowski.com" + }, + { + "name": "Bob Weinand", + "email": "bobwei9@hotmail.com" + }, + { + "name": "Niklas Keller", + "email": "me@kelunik.com" + } + ], + "description": "A non-blocking concurrency framework for PHP applications.", + "homepage": "https://amphp.org/amp", + "keywords": [ + "async", + "asynchronous", + "awaitable", + "concurrency", + "event", + "event-loop", + "future", + "non-blocking", + "promise" + ], + "support": { + "irc": "irc://irc.freenode.org/amphp", + "issues": "https://github.com/amphp/amp/issues", + "source": "https://github.com/amphp/amp/tree/v2.6.4" + }, + "funding": [ + { + "url": "https://github.com/amphp", + "type": "github" + } + ], + "time": "2024-03-21T18:52:26+00:00" + }, + { + "name": "amphp/byte-stream", + "version": "v1.8.2", + "source": { + "type": "git", + "url": "https://github.com/amphp/byte-stream.git", + "reference": "4f0e968ba3798a423730f567b1b50d3441c16ddc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/amphp/byte-stream/zipball/4f0e968ba3798a423730f567b1b50d3441c16ddc", + "reference": "4f0e968ba3798a423730f567b1b50d3441c16ddc", + "shasum": "" + }, + "require": { + "amphp/amp": "^2", + "php": ">=7.1" + }, + "require-dev": { + "amphp/php-cs-fixer-config": "dev-master", + "amphp/phpunit-util": "^1.4", + "friendsofphp/php-cs-fixer": "^2.3", + "jetbrains/phpstorm-stubs": "^2019.3", + "phpunit/phpunit": "^6 || ^7 || ^8", + "psalm/phar": "^3.11.4" + }, + "type": "library", + "autoload": { + "files": [ + "lib/functions.php" + ], + "psr-4": { + "Amp\\ByteStream\\": "lib" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Aaron Piotrowski", + "email": "aaron@trowski.com" + }, + { + "name": "Niklas Keller", + "email": "me@kelunik.com" + } + ], + "description": "A stream abstraction to make working with non-blocking I/O simple.", + "homepage": "https://amphp.org/byte-stream", + "keywords": [ + "amp", + "amphp", + "async", + "io", + "non-blocking", + "stream" + ], + "support": { + "issues": "https://github.com/amphp/byte-stream/issues", + "source": "https://github.com/amphp/byte-stream/tree/v1.8.2" + }, + "funding": [ + { + "url": "https://github.com/amphp", + "type": "github" + } + ], + "time": "2024-04-13T18:00:56+00:00" + }, { "name": "composer/pcre", "version": "3.1.0", @@ -4921,6 +5081,43 @@ ], "time": "2022-02-25T21:32:43+00:00" }, + { + "name": "dnoegel/php-xdg-base-dir", + "version": "v0.1.1", + "source": { + "type": "git", + "url": "https://github.com/dnoegel/php-xdg-base-dir.git", + "reference": "8f8a6e48c5ecb0f991c2fdcf5f154a47d85f9ffd" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/dnoegel/php-xdg-base-dir/zipball/8f8a6e48c5ecb0f991c2fdcf5f154a47d85f9ffd", + "reference": "8f8a6e48c5ecb0f991c2fdcf5f154a47d85f9ffd", + "shasum": "" + }, + "require": { + "php": ">=5.3.2" + }, + "require-dev": { + "phpunit/phpunit": "~7.0|~6.0|~5.0|~4.8.35" + }, + "type": "library", + "autoload": { + "psr-4": { + "XdgBaseDir\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "implementation of xdg base directory specification for php", + "support": { + "issues": "https://github.com/dnoegel/php-xdg-base-dir/issues", + "source": "https://github.com/dnoegel/php-xdg-base-dir/tree/v0.1.1" + }, + "time": "2019-12-04T15:06:13+00:00" + }, { "name": "doctrine/annotations", "version": "2.0.1", @@ -5135,6 +5332,168 @@ }, "time": "2022-12-13T13:54:32+00:00" }, + { + "name": "felixfbecker/advanced-json-rpc", + "version": "v3.2.1", + "source": { + "type": "git", + "url": "https://github.com/felixfbecker/php-advanced-json-rpc.git", + "reference": "b5f37dbff9a8ad360ca341f3240dc1c168b45447" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/felixfbecker/php-advanced-json-rpc/zipball/b5f37dbff9a8ad360ca341f3240dc1c168b45447", + "reference": "b5f37dbff9a8ad360ca341f3240dc1c168b45447", + "shasum": "" + }, + "require": { + "netresearch/jsonmapper": "^1.0 || ^2.0 || ^3.0 || ^4.0", + "php": "^7.1 || ^8.0", + "phpdocumentor/reflection-docblock": "^4.3.4 || ^5.0.0" + }, + "require-dev": { + "phpunit/phpunit": "^7.0 || ^8.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "AdvancedJsonRpc\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "ISC" + ], + "authors": [ + { + "name": "Felix Becker", + "email": "felix.b@outlook.com" + } + ], + "description": "A more advanced JSONRPC implementation", + "support": { + "issues": "https://github.com/felixfbecker/php-advanced-json-rpc/issues", + "source": "https://github.com/felixfbecker/php-advanced-json-rpc/tree/v3.2.1" + }, + "time": "2021-06-11T22:34:44+00:00" + }, + { + "name": "felixfbecker/language-server-protocol", + "version": "v1.5.2", + "source": { + "type": "git", + "url": "https://github.com/felixfbecker/php-language-server-protocol.git", + "reference": "6e82196ffd7c62f7794d778ca52b69feec9f2842" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/felixfbecker/php-language-server-protocol/zipball/6e82196ffd7c62f7794d778ca52b69feec9f2842", + "reference": "6e82196ffd7c62f7794d778ca52b69feec9f2842", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "require-dev": { + "phpstan/phpstan": "*", + "squizlabs/php_codesniffer": "^3.1", + "vimeo/psalm": "^4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "LanguageServerProtocol\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "ISC" + ], + "authors": [ + { + "name": "Felix Becker", + "email": "felix.b@outlook.com" + } + ], + "description": "PHP classes for the Language Server Protocol", + "keywords": [ + "language", + "microsoft", + "php", + "server" + ], + "support": { + "issues": "https://github.com/felixfbecker/php-language-server-protocol/issues", + "source": "https://github.com/felixfbecker/php-language-server-protocol/tree/v1.5.2" + }, + "time": "2022-03-02T22:36:06+00:00" + }, + { + "name": "fidry/cpu-core-counter", + "version": "0.5.1", + "source": { + "type": "git", + "url": "https://github.com/theofidry/cpu-core-counter.git", + "reference": "b58e5a3933e541dc286cc91fc4f3898bbc6f1623" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/theofidry/cpu-core-counter/zipball/b58e5a3933e541dc286cc91fc4f3898bbc6f1623", + "reference": "b58e5a3933e541dc286cc91fc4f3898bbc6f1623", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0" + }, + "require-dev": { + "fidry/makefile": "^0.2.0", + "phpstan/extension-installer": "^1.2.0", + "phpstan/phpstan": "^1.9.2", + "phpstan/phpstan-deprecation-rules": "^1.0.0", + "phpstan/phpstan-phpunit": "^1.2.2", + "phpstan/phpstan-strict-rules": "^1.4.4", + "phpunit/phpunit": "^9.5.26 || ^8.5.31", + "theofidry/php-cs-fixer-config": "^1.0", + "webmozarts/strict-phpunit": "^7.5" + }, + "type": "library", + "autoload": { + "psr-4": { + "Fidry\\CpuCoreCounter\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Théo FIDRY", + "email": "theo.fidry@gmail.com" + } + ], + "description": "Tiny utility to get the number of CPU cores.", + "keywords": [ + "CPU", + "core" + ], + "support": { + "issues": "https://github.com/theofidry/cpu-core-counter/issues", + "source": "https://github.com/theofidry/cpu-core-counter/tree/0.5.1" + }, + "funding": [ + { + "url": "https://github.com/theofidry", + "type": "github" + } + ], + "time": "2022-12-24T12:35:10+00:00" + }, { "name": "friendsofphp/php-cs-fixer", "version": "v3.16.0", @@ -5529,6 +5888,57 @@ ], "time": "2023-03-08T13:26:56+00:00" }, + { + "name": "netresearch/jsonmapper", + "version": "v4.4.1", + "source": { + "type": "git", + "url": "https://github.com/cweiske/jsonmapper.git", + "reference": "132c75c7dd83e45353ebb9c6c9f591952995bbf0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/cweiske/jsonmapper/zipball/132c75c7dd83e45353ebb9c6c9f591952995bbf0", + "reference": "132c75c7dd83e45353ebb9c6c9f591952995bbf0", + "shasum": "" + }, + "require": { + "ext-json": "*", + "ext-pcre": "*", + "ext-reflection": "*", + "ext-spl": "*", + "php": ">=7.1" + }, + "require-dev": { + "phpunit/phpunit": "~7.5 || ~8.0 || ~9.0 || ~10.0", + "squizlabs/php_codesniffer": "~3.5" + }, + "type": "library", + "autoload": { + "psr-0": { + "JsonMapper": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "OSL-3.0" + ], + "authors": [ + { + "name": "Christian Weiske", + "email": "cweiske@cweiske.de", + "homepage": "http://github.com/cweiske/jsonmapper/", + "role": "Developer" + } + ], + "description": "Map nested JSON structures onto PHP classes", + "support": { + "email": "cweiske@cweiske.de", + "issues": "https://github.com/cweiske/jsonmapper/issues", + "source": "https://github.com/cweiske/jsonmapper/tree/v4.4.1" + }, + "time": "2024-01-31T06:18:54+00:00" + }, { "name": "nikic/php-parser", "version": "v4.15.4", @@ -5842,66 +6252,219 @@ "time": "2022-02-21T01:04:05+00:00" }, { - "name": "phpstan/phpstan", - "version": "1.10.14", + "name": "phpdocumentor/reflection-common", + "version": "2.2.0", "source": { "type": "git", - "url": "https://github.com/phpstan/phpstan.git", - "reference": "d232901b09e67538e5c86a724be841bea5768a7c" + "url": "https://github.com/phpDocumentor/ReflectionCommon.git", + "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/d232901b09e67538e5c86a724be841bea5768a7c", - "reference": "d232901b09e67538e5c86a724be841bea5768a7c", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/1d01c49d4ed62f25aa84a747ad35d5a16924662b", + "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b", "shasum": "" }, "require": { - "php": "^7.2|^8.0" - }, - "conflict": { - "phpstan/phpstan-shim": "*" + "php": "^7.2 || ^8.0" }, - "bin": [ - "phpstan", - "phpstan.phar" - ], "type": "library", + "extra": { + "branch-alias": { + "dev-2.x": "2.x-dev" + } + }, "autoload": { - "files": [ - "bootstrap.php" - ] + "psr-4": { + "phpDocumentor\\Reflection\\": "src/" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], - "description": "PHPStan - PHP Static Analysis Tool", + "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", "keywords": [ - "dev", + "FQSEN", + "phpDocumentor", + "phpdoc", + "reflection", "static analysis" ], "support": { - "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" + "issues": "https://github.com/phpDocumentor/ReflectionCommon/issues", + "source": "https://github.com/phpDocumentor/ReflectionCommon/tree/2.x" }, - "funding": [ + "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": "" + }, + "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": [ { - "url": "https://github.com/ondrejmirtes", - "type": "github" + "name": "Mike van Riel", + "email": "me@mikevanriel.com" }, { - "url": "https://github.com/phpstan", - "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.8.2", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/TypeResolver.git", + "reference": "153ae662783729388a584b4361f2545e4d841e3c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/153ae662783729388a584b4361f2545e4d841e3c", + "reference": "153ae662783729388a584b4361f2545e4d841e3c", + "shasum": "" + }, + "require": { + "doctrine/deprecations": "^1.0", + "php": "^7.3 || ^8.0", + "phpdocumentor/reflection-common": "^2.0", + "phpstan/phpdoc-parser": "^1.13" + }, + "require-dev": { + "ext-tokenizer": "*", + "phpbench/phpbench": "^1.2", + "phpstan/extension-installer": "^1.1", + "phpstan/phpstan": "^1.8", + "phpstan/phpstan-phpunit": "^1.1", + "phpunit/phpunit": "^9.5", + "rector/rector": "^0.13.9", + "vimeo/psalm": "^4.25" + }, + "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": [ { - "url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan", - "type": "tidelift" + "name": "Mike van Riel", + "email": "me@mikevanriel.com" } ], - "time": "2023-04-19T13:47:27+00:00" + "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.8.2" + }, + "time": "2024-02-23T11:10:43+00:00" + }, + { + "name": "phpstan/phpdoc-parser", + "version": "1.29.0", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpdoc-parser.git", + "reference": "536889f2b340489d328f5ffb7b02bb6b183ddedc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/536889f2b340489d328f5ffb7b02bb6b183ddedc", + "reference": "536889f2b340489d328f5ffb7b02bb6b183ddedc", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0" + }, + "require-dev": { + "doctrine/annotations": "^2.0", + "nikic/php-parser": "^4.15", + "php-parallel-lint/php-parallel-lint": "^1.2", + "phpstan/extension-installer": "^1.0", + "phpstan/phpstan": "^1.5", + "phpstan/phpstan-phpunit": "^1.1", + "phpstan/phpstan-strict-rules": "^1.0", + "phpunit/phpunit": "^9.5", + "symfony/process": "^5.2" + }, + "type": "library", + "autoload": { + "psr-4": { + "PHPStan\\PhpDocParser\\": [ + "src/" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "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.29.0" + }, + "time": "2024-05-06T12:04:23+00:00" }, { "name": "phpunit/php-code-coverage", @@ -7542,6 +8105,74 @@ ], "time": "2020-09-28T06:39:44+00:00" }, + { + "name": "spatie/array-to-xml", + "version": "3.3.0", + "source": { + "type": "git", + "url": "https://github.com/spatie/array-to-xml.git", + "reference": "f56b220fe2db1ade4c88098d83413ebdfc3bf876" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/spatie/array-to-xml/zipball/f56b220fe2db1ade4c88098d83413ebdfc3bf876", + "reference": "f56b220fe2db1ade4c88098d83413ebdfc3bf876", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "php": "^8.0" + }, + "require-dev": { + "mockery/mockery": "^1.2", + "pestphp/pest": "^1.21", + "spatie/pest-plugin-snapshots": "^1.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.x-dev" + } + }, + "autoload": { + "psr-4": { + "Spatie\\ArrayToXml\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Freek Van der Herten", + "email": "freek@spatie.be", + "homepage": "https://freek.dev", + "role": "Developer" + } + ], + "description": "Convert an array to xml", + "homepage": "https://github.com/spatie/array-to-xml", + "keywords": [ + "array", + "convert", + "xml" + ], + "support": { + "source": "https://github.com/spatie/array-to-xml/tree/3.3.0" + }, + "funding": [ + { + "url": "https://spatie.be/open-source/support-us", + "type": "custom" + }, + { + "url": "https://github.com/spatie", + "type": "github" + } + ], + "time": "2024-05-01T10:20:27+00:00" + }, { "name": "spatie/backtrace", "version": "1.4.0", @@ -8214,6 +8845,112 @@ ], "time": "2021-07-28T10:34:58+00:00" }, + { + "name": "vimeo/psalm", + "version": "5.13.1", + "source": { + "type": "git", + "url": "https://github.com/vimeo/psalm.git", + "reference": "086b94371304750d1c673315321a55d15fc59015" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/vimeo/psalm/zipball/086b94371304750d1c673315321a55d15fc59015", + "reference": "086b94371304750d1c673315321a55d15fc59015", + "shasum": "" + }, + "require": { + "amphp/amp": "^2.4.2", + "amphp/byte-stream": "^1.5", + "composer-runtime-api": "^2", + "composer/semver": "^1.4 || ^2.0 || ^3.0", + "composer/xdebug-handler": "^2.0 || ^3.0", + "dnoegel/php-xdg-base-dir": "^0.1.1", + "ext-ctype": "*", + "ext-dom": "*", + "ext-json": "*", + "ext-libxml": "*", + "ext-mbstring": "*", + "ext-simplexml": "*", + "ext-tokenizer": "*", + "felixfbecker/advanced-json-rpc": "^3.1", + "felixfbecker/language-server-protocol": "^1.5.2", + "fidry/cpu-core-counter": "^0.4.1 || ^0.5.1", + "netresearch/jsonmapper": "^1.0 || ^2.0 || ^3.0 || ^4.0", + "nikic/php-parser": "^4.14", + "php": "^7.4 || ~8.0.0 || ~8.1.0 || ~8.2.0", + "sebastian/diff": "^4.0 || ^5.0", + "spatie/array-to-xml": "^2.17.0 || ^3.0", + "symfony/console": "^4.1.6 || ^5.0 || ^6.0", + "symfony/filesystem": "^5.4 || ^6.0" + }, + "provide": { + "psalm/psalm": "self.version" + }, + "require-dev": { + "amphp/phpunit-util": "^2.0", + "bamarni/composer-bin-plugin": "^1.4", + "brianium/paratest": "^6.9", + "ext-curl": "*", + "mockery/mockery": "^1.5", + "nunomaduro/mock-final-classes": "^1.1", + "php-parallel-lint/php-parallel-lint": "^1.2", + "phpstan/phpdoc-parser": "^1.6", + "phpunit/phpunit": "^9.6", + "psalm/plugin-mockery": "^1.1", + "psalm/plugin-phpunit": "^0.18", + "slevomat/coding-standard": "^8.4", + "squizlabs/php_codesniffer": "^3.6", + "symfony/process": "^4.4 || ^5.0 || ^6.0" + }, + "suggest": { + "ext-curl": "In order to send data to shepherd", + "ext-igbinary": "^2.0.5 is required, used to serialize caching data" + }, + "bin": [ + "psalm", + "psalm-language-server", + "psalm-plugin", + "psalm-refactor", + "psalter" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.x-dev", + "dev-4.x": "4.x-dev", + "dev-3.x": "3.x-dev", + "dev-2.x": "2.x-dev", + "dev-1.x": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psalm\\": "src/Psalm/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Matthew Brown" + } + ], + "description": "A static analysis tool for finding errors in PHP applications", + "keywords": [ + "code", + "inspection", + "php", + "static analysis" + ], + "support": { + "issues": "https://github.com/vimeo/psalm/issues", + "source": "https://github.com/vimeo/psalm/tree/5.13.1" + }, + "time": "2023-06-27T16:39:49+00:00" + }, { "name": "zbateson/mail-mime-parser", "version": "2.4.0", @@ -8435,5 +9172,5 @@ "platform-dev": { "ext-pdo": "*" }, - "plugin-api-version": "2.3.0" + "plugin-api-version": "2.6.0" } diff --git a/phpstan.neon b/phpstan.neon deleted file mode 100644 index fcf05bd..0000000 --- a/phpstan.neon +++ /dev/null @@ -1,9 +0,0 @@ -parameters: - level: 4 - paths: - - . - ignoreErrors: - excludePaths: - - .* - - vendor - - tests diff --git a/psalm.xml b/psalm.xml new file mode 100644 index 0000000..c9d0ce2 --- /dev/null +++ b/psalm.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + diff --git a/src/Builders/Clauses/BuilderWhere.php b/src/Builders/Clauses/BuilderWhere.php index 8ee4861..93342b6 100644 --- a/src/Builders/Clauses/BuilderWhere.php +++ b/src/Builders/Clauses/BuilderWhere.php @@ -9,6 +9,8 @@ /** * @internal + * + * @psalm-api */ trait BuilderWhere { @@ -38,6 +40,15 @@ public function where( return $this; } + /** + * @param Closure|string $field + * @param string $operator + * @param mixed|null $value + * + * @return $this + * + * @psalm-api + */ public function orWhere(string|Closure $field, string $operator = '=', mixed $value = null): static { return $this->where($field, $operator, $value, 'or'); diff --git a/src/Builders/Clauses/Where/BuilderWhereCallback.php b/src/Builders/Clauses/Where/BuilderWhereCallback.php index d864f67..3ebf7dd 100644 --- a/src/Builders/Clauses/Where/BuilderWhereCallback.php +++ b/src/Builders/Clauses/Where/BuilderWhereCallback.php @@ -6,6 +6,8 @@ /** * @internal + * + * @psalm-api */ class BuilderWhereCallback { diff --git a/src/Builders/Clauses/Where/BuilderWhereCondition.php b/src/Builders/Clauses/Where/BuilderWhereCondition.php index 2fae3a8..0256a8b 100644 --- a/src/Builders/Clauses/Where/BuilderWhereCondition.php +++ b/src/Builders/Clauses/Where/BuilderWhereCondition.php @@ -4,6 +4,8 @@ /** * @internal + * + * @psalm-api */ class BuilderWhereCondition { diff --git a/src/Builders/Clauses/Where/BuilderWhereIn.php b/src/Builders/Clauses/Where/BuilderWhereIn.php index 1cbf9f6..b5301d8 100644 --- a/src/Builders/Clauses/Where/BuilderWhereIn.php +++ b/src/Builders/Clauses/Where/BuilderWhereIn.php @@ -4,6 +4,8 @@ /** * @internal + * + * @psalm-api */ class BuilderWhereIn { diff --git a/src/Builders/SelectBulkBuilder.php b/src/Builders/SelectBulkBuilder.php index c12c5f4..ef74371 100644 --- a/src/Builders/SelectBulkBuilder.php +++ b/src/Builders/SelectBulkBuilder.php @@ -19,11 +19,23 @@ class SelectBulkBuilder implements BulkBuilderWhereClause */ private array $columns = []; + /** + * @return string|null + * + * @psalm-api + */ public function getFrom(): ?string { return $this->from; } + /** + * @param string $table + * + * @return $this + * + * @psalm-api + */ public function from(string $table): static { $this->from = $table; @@ -33,6 +45,8 @@ public function from(string $table): static /** * @return string[] + * + * @psalm-api */ public function getSelect(): array { @@ -43,6 +57,8 @@ public function getSelect(): array * @param string[] $columns * * @return $this + * + * @psalm-api */ public function select(array $columns): static { @@ -50,14 +66,4 @@ public function select(array $columns): static return $this; } - - public function reset(): static - { - $this->from = null; - $this->columns = []; - $this->wheres = []; - $this->fields = []; - - return $this; - } } diff --git a/src/Builders/UpdateBulkBuilder.php b/src/Builders/UpdateBulkBuilder.php index 563cde1..c65ae3d 100644 --- a/src/Builders/UpdateBulkBuilder.php +++ b/src/Builders/UpdateBulkBuilder.php @@ -23,7 +23,7 @@ class UpdateBulkBuilder implements BulkBuilderWhereClause */ private array $sets = []; - public function getTable(): string + public function getTable(): ?string { return $this->table; } diff --git a/src/Bulk.php b/src/Bulk.php index 5b365cf..aaf89ed 100644 --- a/src/Bulk.php +++ b/src/Bulk.php @@ -130,6 +130,14 @@ public function __construct(Model|string $model) $this->uniqueBy([$this->model->getKeyName()]); } + /** + * @param string $name + * @param array $arguments + * + * @return $this + * + * @psalm-suppress PossiblyUnusedMethod + */ public function __call(string $name, array $arguments) { if (str_starts_with($name, 'on')) { @@ -197,6 +205,8 @@ public function uniqueBy(string|array|callable $attributes): static * @param callable|string|string[]|string[][] $attributes * * @return $this + * + * @psalm-api */ public function orUniqueBy(string|array|callable $attributes): static { @@ -246,6 +256,8 @@ public function setEvents(array $events): static * - `restored`. * * @return $this + * + * @psalm-api */ public function disableModelEndEvents(): static { @@ -290,6 +302,8 @@ public function disableEvents(array $events = null): static * @param string $event * * @return $this + * + * @psalm-api */ public function disableEvent(string $event): static { @@ -328,6 +342,8 @@ public function enableEvents(array $events = null): static * @param string $event * * @return $this + * + * @psalm-api */ public function enableEvent(string $event): static { @@ -340,6 +356,8 @@ public function enableEvent(string $event): static * @param string[] $attributes * * @return $this + * + * @psalm-api */ public function updateOnly(array $attributes): static { @@ -354,6 +372,8 @@ public function updateOnly(array $attributes): static * @param string[] $attributes * * @return $this + * + * @psalm-api */ public function updateAllExcept(array $attributes): static { @@ -371,6 +391,8 @@ public function updateAllExcept(array $attributes): static * @return $this * * @throws BulkException + * + * @psalm-api */ public function create(iterable $rows, bool $ignoreConflicts = false): static { @@ -400,6 +422,8 @@ public function create(iterable $rows, bool $ignoreConflicts = false): static * @return $this * * @throws BulkException + * + * @psalm-api */ public function createOrAccumulate(iterable $rows, bool $ignoreConflicts = false): static { @@ -426,9 +450,13 @@ public function createOrAccumulate(iterable $rows, bool $ignoreConflicts = false * @param string[] $columns columns that should be selected from the database * @param bool $ignoreConflicts * - * @return Collection|TCollection + * @return Collection + * + * @psalm-return TCollection * * @throws BulkException + * + * @psalm-api */ public function createAndReturn( iterable $rows, @@ -481,6 +509,8 @@ public function update(iterable $rows): static * @return $this * * @throws BulkException + * + * @psalm-api */ public function updateOrAccumulate(iterable $rows): static { @@ -499,9 +529,13 @@ public function updateOrAccumulate(iterable $rows): static * @param iterable|Model|object|stdClass|TModel> $rows * @param string[] $columns columns that should be selected from the database * - * @return Collection|TCollection + * @return Collection + * + * @psalm-return TCollection * * @throws BulkException + * + * @psalm-api */ public function updateAndReturn(iterable $rows, array $columns = ['*']): Collection { @@ -530,6 +564,8 @@ function (Collection $collection) use ($result): void { * @return $this * * @throws BulkException + * + * @psalm-api */ public function upsert(iterable $rows): static { @@ -550,6 +586,8 @@ public function upsert(iterable $rows): static * @return $this * * @throws BulkException + * + * @psalm-api */ public function upsertOrAccumulate(iterable $rows): static { @@ -568,9 +606,13 @@ public function upsertOrAccumulate(iterable $rows): static * @param iterable|Model|object|stdClass|TModel> $rows * @param string[] $columns columns that should be selected from the database * - * @return Collection|TCollection + * @return Collection + * + * @psalm-return TCollection * * @throws BulkException + * + * @psalm-api */ public function upsertAndReturn(iterable $rows, array $columns = ['*']): Collection { @@ -602,6 +644,8 @@ function (Collection $collection) use ($result): void { * * @throws BulkBindingResolution * @throws BulkException + * + * @psalm-api */ public function delete(iterable $rows): static { @@ -622,6 +666,8 @@ public function delete(iterable $rows): static * @return $this * * @throws BulkException + * + * @psalm-api */ public function deleteOrAccumulate(iterable $rows): static { @@ -643,6 +689,8 @@ public function deleteOrAccumulate(iterable $rows): static * * @throws BulkBindingResolution * @throws BulkException + * + * @psalm-api */ public function forceDelete(iterable $rows): static { @@ -663,6 +711,8 @@ public function forceDelete(iterable $rows): static * @return $this * * @throws BulkException + * + * @psalm-api */ public function forceDeleteOrAccumulate(iterable $rows): static { @@ -765,6 +815,8 @@ public function forceDeleteAccumulated(): static * @return $this * * @throws BulkException + * + * @psalm-api */ public function saveAccumulated(): static { @@ -779,6 +831,8 @@ public function saveAccumulated(): static * Adds soft deleted rows to queries. * * @return $this + * + * @psalm-api */ public function withTrashed(): static { diff --git a/src/BulkBuilder.php b/src/BulkBuilder.php index e7cbdbc..e2a271c 100644 --- a/src/BulkBuilder.php +++ b/src/BulkBuilder.php @@ -9,10 +9,11 @@ /** * @template TCollection of Collection * @template TModel of Model - * - * @uses BulkBuilderTrait */ class BulkBuilder extends Builder { + /** + * @use BulkBuilderTrait + */ use BulkBuilderTrait; } diff --git a/src/BulkBuilderTrait.php b/src/BulkBuilderTrait.php index a88a46f..3ee6751 100644 --- a/src/BulkBuilderTrait.php +++ b/src/BulkBuilderTrait.php @@ -37,6 +37,8 @@ public function bulk(): Bulk * @return int * * @throws BulkException + * + * @psalm-api */ public function selectAndUpdateMany( array $values, diff --git a/src/Collections/BulkRows.php b/src/Collections/BulkRows.php index b67c31f..0e7f8ca 100644 --- a/src/Collections/BulkRows.php +++ b/src/Collections/BulkRows.php @@ -10,6 +10,8 @@ /** * @template TModel of Model * @template TOriginal of mixed + * + * @extends Collection> */ class BulkRows extends Collection { diff --git a/src/Contracts/BulkBuilderWhereClause.php b/src/Contracts/BulkBuilderWhereClause.php index 82414b6..42c3e7e 100644 --- a/src/Contracts/BulkBuilderWhereClause.php +++ b/src/Contracts/BulkBuilderWhereClause.php @@ -16,7 +16,25 @@ public function where( string $boolean = 'and', ): static; + /** + * @param Closure|string $field + * @param string $operator + * @param mixed|null $value + * + * @return $this + * + * @psalm-api + */ public function orWhere(string|Closure $field, string $operator = '=', mixed $value = null): static; + /** + * @param string $field + * @param array $values + * @param string $boolean + * + * @return $this + * + * @psalm-api + */ public function whereIn(string $field, array $values, string $boolean = 'and'): static; } diff --git a/src/Contracts/BulkDriver.php b/src/Contracts/BulkDriver.php index e1d3030..dbbfde4 100644 --- a/src/Contracts/BulkDriver.php +++ b/src/Contracts/BulkDriver.php @@ -15,9 +15,33 @@ public function insertWithResult( ?string $primaryKeyName, ): BulkInsertResult; + /** + * @param ConnectionInterface $connection + * @param InsertBuilder $builder + * + * @return void + * + * @psalm-api + */ public function quietInsert(ConnectionInterface $connection, InsertBuilder $builder): void; + /** + * @param ConnectionInterface $connection + * @param UpdateBulkBuilder $builder + * + * @return int + * + * @psalm-api + */ public function update(ConnectionInterface $connection, UpdateBulkBuilder $builder): int; + /** + * @param ConnectionInterface $connection + * @param DeleteBulkBuilder $builder + * + * @return int + * + * @psalm-api + */ public function forceDelete(ConnectionInterface $connection, DeleteBulkBuilder $builder): int; } diff --git a/src/Entities/BulkAccumulationEntity.php b/src/Entities/BulkAccumulationEntity.php index 62ae2ef..b0e76ab 100644 --- a/src/Entities/BulkAccumulationEntity.php +++ b/src/Entities/BulkAccumulationEntity.php @@ -105,6 +105,8 @@ public function setRows(array $originals): static /** * @return string[] + * + * @psalm-suppress PossiblyUnusedMethod */ public function getUpdateOnly(): array { @@ -113,6 +115,8 @@ public function getUpdateOnly(): array /** * @return string[] + * + * @psalm-suppress PossiblyUnusedMethod */ public function getUpdateExcept(): array { diff --git a/src/Entities/BulkAccumulationItemEntity.php b/src/Entities/BulkAccumulationItemEntity.php index 365cb8b..40520e5 100644 --- a/src/Entities/BulkAccumulationItemEntity.php +++ b/src/Entities/BulkAccumulationItemEntity.php @@ -70,33 +70,4 @@ public function setModel(Model $model): static return $this; } - - /** - * @return bool - * - * @deprecated. All the skipping rows will be deleted from collection. - * This method is not actual anymore and will be deleted in the future. - */ - public function isSkipSaving(): bool - { - return $this->skipSaving; - } - -// /** -// * @return bool -// */ -// public function isCreationSkipped(): bool -// { -// return $this->skipCreating; -// } -// -// /** -// * @return BulkAccumulationItemEntity -// */ -// public function skipCreation(): BulkAccumulationItemEntity -// { -// $this->skipCreating = true; -// -// return $this; -// } } diff --git a/src/Entities/BulkRow.php b/src/Entities/BulkRow.php index b00bb9e..39f82ee 100644 --- a/src/Entities/BulkRow.php +++ b/src/Entities/BulkRow.php @@ -7,6 +7,8 @@ /** * @template TModel of Model * @template TOriginal of mixed + * + * @psalm-api */ class BulkRow { diff --git a/src/Enums/BulkEventEnum.php b/src/Enums/BulkEventEnum.php index 350d09f..ab47590 100644 --- a/src/Enums/BulkEventEnum.php +++ b/src/Enums/BulkEventEnum.php @@ -142,6 +142,8 @@ public static function collection(): array /** * @return string[] + * + * @psalm-suppress PossiblyUnusedMethod */ public static function create(): array { @@ -172,6 +174,8 @@ public static function created(): array /** * @return string[] + * + * @psalm-suppress PossiblyUnusedMethod */ public static function update(): array { @@ -280,6 +284,8 @@ public static function restored(): array /** * @return string[] + * + * @psalm-suppress PossiblyUnusedMethod */ public static function save(): array { diff --git a/src/Events/BulkEventDispatcher.php b/src/Events/BulkEventDispatcher.php index cddc48f..c380c8d 100644 --- a/src/Events/BulkEventDispatcher.php +++ b/src/Events/BulkEventDispatcher.php @@ -46,11 +46,27 @@ public function listen(string $event, mixed $listener, bool $once = false): ?str return $key; } + /** + * @param string $event + * @param callable|null $listener + * + * @return string|null + * + * @psalm-api + */ public function once(string $event, ?callable $listener): ?string { return $this->listen($event, $listener, true); } + /** + * @param string $event + * @param string|null $key + * + * @return $this + * + * @psalm-api + */ public function forget(string $event, ?string $key): static { if ($key !== null) { diff --git a/src/Exceptions/BulkIdentifierDidNotFind.php b/src/Exceptions/BulkIdentifierDidNotFind.php index afa2a47..fc10afc 100644 --- a/src/Exceptions/BulkIdentifierDidNotFind.php +++ b/src/Exceptions/BulkIdentifierDidNotFind.php @@ -26,6 +26,11 @@ public function getUniqueAttributes(): array return $this->uniqueAttributes; } + /** + * @return array + * + * @psalm-api + */ public function context(): array { return [ diff --git a/src/Exceptions/BulkModelWasNotTransferred.php b/src/Exceptions/BulkModelWasNotTransferred.php index a4ab42a..ba752b3 100644 --- a/src/Exceptions/BulkModelWasNotTransferred.php +++ b/src/Exceptions/BulkModelWasNotTransferred.php @@ -5,6 +5,9 @@ use Lapaliv\BulkUpsert\Contracts\BulkException; use RuntimeException; +/** + * @psalm-api + */ class BulkModelWasNotTransferred extends RuntimeException implements BulkException { public function __construct() diff --git a/src/Exceptions/BulkValueTypeIsNotSupported.php b/src/Exceptions/BulkValueTypeIsNotSupported.php index 614d8d1..ccf9bca 100644 --- a/src/Exceptions/BulkValueTypeIsNotSupported.php +++ b/src/Exceptions/BulkValueTypeIsNotSupported.php @@ -17,6 +17,11 @@ public function getValue(): mixed return $this->value; } + /** + * @return array + * + * @psalm-api + */ public function context(): array { return [ diff --git a/src/Features/GetInsertBuilderFeature.php b/src/Features/GetInsertBuilderFeature.php index 10a0bc3..a58d715 100644 --- a/src/Features/GetInsertBuilderFeature.php +++ b/src/Features/GetInsertBuilderFeature.php @@ -100,7 +100,7 @@ private function convertModelToArray( $dateFields, ); - foreach ($result as $key => $value) { + foreach (array_keys($result) as $key) { $columns[$key] = $key; } diff --git a/src/Features/GetUpdateBuilderFeature.php b/src/Features/GetUpdateBuilderFeature.php index 56b5f73..e849484 100644 --- a/src/Features/GetUpdateBuilderFeature.php +++ b/src/Features/GetUpdateBuilderFeature.php @@ -106,15 +106,15 @@ private function collectRowAttributes( unset($attributes[$deletedAtColumn]); } - if (!empty($data->updateOnly)) { - foreach ($attributes as $key => $value) { - if (!in_array($key, $data->updateOnly, true)) { + if (!empty($data->getUpdateOnly())) { + foreach (array_keys($attributes) as $key) { + if (!in_array($key, $data->getUpdateOnly(), true)) { unset($attributes[$key]); } } - } elseif (!empty($data->updateExcept)) { - foreach ($attributes as $key => $value) { - if (in_array($key, $data->updateExcept, true)) { + } elseif (!empty($data->getUpdateExcept())) { + foreach (array_keys($attributes) as $key) { + if (in_array($key, $data->getUpdateExcept(), true)) { unset($attributes[$key]); } } diff --git a/src/Features/KeyByFeature.php b/src/Features/KeyByFeature.php index 3f53dfb..f68cdd4 100644 --- a/src/Features/KeyByFeature.php +++ b/src/Features/KeyByFeature.php @@ -17,7 +17,7 @@ public function __construct( } /** - * @param array>|Collection $rows + * @param array>|Collection $rows * @param string[] $attributes * * @return array diff --git a/src/Features/MarkNonexistentRowsAsSkippedFeature.php b/src/Features/MarkNonexistentRowsAsSkippedFeature.php index ab45dd3..47f6d22 100644 --- a/src/Features/MarkNonexistentRowsAsSkippedFeature.php +++ b/src/Features/MarkNonexistentRowsAsSkippedFeature.php @@ -69,13 +69,13 @@ private function mark( $key = $this->getUniqueKeyFeature->handle($row->model, $nonExistent->uniqueBy); if (array_key_exists($key, $keyedSelected)) { - foreach ($row->model->getAttributes() as $attribute => $value) { + foreach (array_keys($row->getModel()->getAttributes()) as $attribute) { $keyedSelected[$key]->setAttribute( $attribute, - $row->model->getAttribute($attribute) + $row->getModel()->getAttribute($attribute) ); } - $row->model = $keyedSelected[$key]; + $row->setModel($keyedSelected[$key]); } else { $row->skipUpdating = true; } diff --git a/src/Features/SelectExistingRowsFeature.php b/src/Features/SelectExistingRowsFeature.php index 58805d9..106b854 100644 --- a/src/Features/SelectExistingRowsFeature.php +++ b/src/Features/SelectExistingRowsFeature.php @@ -2,8 +2,9 @@ namespace Lapaliv\BulkUpsert\Features; +use Illuminate\Database\Eloquent\Collection; use Illuminate\Database\Eloquent\Model; -use Illuminate\Support\Collection; +use Illuminate\Support\Collection as SupportCollection; /** * @internal @@ -16,9 +17,21 @@ public function __construct( // } + /** + * @param Model $eloquent + * @param SupportCollection $collection + * @param array $uniqueBy + * @param array $selectColumns + * @param string|null $deletedAtColumn + * @param bool $withTrashed + * + * @return Collection + * + * @psalm-return Collection + */ public function handle( Model $eloquent, - Collection $collection, + SupportCollection $collection, array $uniqueBy, array $selectColumns, ?string $deletedAtColumn = null, diff --git a/src/Providers/BulkUpsertServiceProvider.php b/src/Providers/BulkUpsertServiceProvider.php index bf62ed7..5736b31 100644 --- a/src/Providers/BulkUpsertServiceProvider.php +++ b/src/Providers/BulkUpsertServiceProvider.php @@ -17,6 +17,9 @@ use Lapaliv\BulkUpsert\Features\GetValueHashFeature; use Lapaliv\BulkUpsert\Features\KeyByFeature; +/** + * @psalm-suppress UnusedClass + */ class BulkUpsertServiceProvider extends ServiceProvider { /**