diff --git a/.gitattributes b/.gitattributes index 8a176c8..e1625a1 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,15 +1,11 @@ +/bin/vendorbin export-ignore +/build export-ignore /tests export-ignore +/tools export-ignore /examples export-ignore /docker export-ignore /vendor-bin export-ignore /.editorconfig export-ignore /.gitattributes export-ignore /.gitignore export-ignore -/.travis.yml export-ignore -/captainhook.json export-ignore -/phpstan.neon export-ignore -/phpstan-baseline.neon export-ignore -/phpunit.xml.dist export-ignore -/psalm.xml export-ignore -/psalm-baseline.xml export-ignore -/ruleset.xml export-ignore \ No newline at end of file +/.travis.yml export-ignore \ No newline at end of file diff --git a/.gitignore b/.gitignore index 1c33269..2bb412c 100644 --- a/.gitignore +++ b/.gitignore @@ -3,8 +3,8 @@ /vendor /vendor-bin/**/vendor /vendor-bin/**/composer.lock -/.phpunit.result.cache -/.phpcs-cache /tests/_output /tests/_reports -/build \ No newline at end of file +/build +/tools/cache/* +!/tools/cache/.gitkeep \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index dbb2830..1102ace 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,8 @@ env: - XDEBUG_MODE=coverage language: php php: - - '8.0' + - '8.2' + - '8.3' before_script: - composer self-update @@ -20,7 +21,7 @@ script: - composer phpstan - composer psalm - composer phpcs - - if [ "$TRAVIS_PULL_REQUEST" == "false" -a "${TRAVIS_PHP_VERSION:0:1}" == "8" ]; then ./cc-test-reporter after-build -t clover --exit-code $TRAVIS_TEST_RESULT; fi + - if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then ./cc-test-reporter after-build -t clover --exit-code $TRAVIS_TEST_RESULT; fi notifications: email: false diff --git a/bin/vendorbin b/bin/vendorbin new file mode 100755 index 0000000..a80e213 --- /dev/null +++ b/bin/vendorbin @@ -0,0 +1,48 @@ +#!/usr/bin/env php +in($projectDir . '/vendor-bin')->directories()->depth(0)->sortByName(); + +/** @var array $tools */ +$tools = []; + +foreach ($sourceFinder as $directory) { + $toolName = $directory->getFilename(); + + $options = [ + '--ansi', + ]; + + if ($composerRunType === 'update') { + $options[] = '--no-progress'; + } + + $process = new \Symfony\Component\Process\Process(['composer', $composerRunType, ...$options]); + if (isset($_SERVER['COMPOSER_CACHE_DIR'])) { + $process->setEnv(['COMPOSER_CACHE_DIR' => $_SERVER['COMPOSER_CACHE_DIR']]); + } + $process->setWorkingDirectory($projectDir . '/vendor-bin/' . $toolName); + $process->start(); + $process->wait(); + + echo 'Running composer ' . $composerRunType . ' for ' . $toolName . ' ...' . "\n"; + + $processOutput = \trim($process->getOutput()); + + if ($composerRunType === 'update') { + $processOutput = \trim($processOutput . "\n" . $process->getErrorOutput()); + } + + if (\strlen($processOutput) > 0) { + echo $processOutput . "\n"; + } +} \ No newline at end of file diff --git a/composer.json b/composer.json index b0ace43..ce26020 100644 --- a/composer.json +++ b/composer.json @@ -20,18 +20,19 @@ } ], "require": { - "php": ">=8.0", + "php": ">=8.2", "symfony/console": "^5.0|^6.0|^7.0", "symfony/finder": "^5.0|^6.0|^7.0", "squirrelphp/debug": "^2.0", - "squirrelphp/queries": "^1.2", + "squirrelphp/queries": "^2.0", "squirrelphp/types": "^1.0" }, "require-dev": { - "bamarni/composer-bin-plugin": "^1.8", - "captainhook/plugin-composer": "^5.0", - "phpunit/phpunit": "^10.0", - "mockery/mockery": "^1.0" + "captainhook/captainhook-phar": "^5.0", + "captainhook/hook-installer": "^1.0", + "phpunit/phpunit": "^11.2", + "mockery/mockery": "^1.0", + "symfony/process": "^7.0" }, "suggest": { "squirrelphp/queries-bundle": "Symfony integration of squirrel/queries - automatic assembling of decorated connections", @@ -40,8 +41,13 @@ "config": { "sort-packages": true, "allow-plugins": { - "bamarni/composer-bin-plugin": true, - "captainhook/plugin-composer": true + "captainhook/captainhook-phar": true, + "captainhook/hook-installer": true + } + }, + "extra": { + "captainhook": { + "config": "tools/captainhook.json" } }, "bin": [ @@ -58,19 +64,19 @@ } }, "scripts": { - "phpstan": "vendor/bin/phpstan analyse", - "phpstan_full": "vendor/bin/phpstan clear-result-cache && vendor/bin/phpstan analyse", - "phpstan_base": "vendor/bin/phpstan analyse --generate-baseline", - "psalm": "vendor/bin/psalm --show-info=false", - "psalm_full": "vendor/bin/psalm --clear-cache && vendor/bin/psalm --show-info=false", - "psalm_base": "vendor/bin/psalm --set-baseline=psalm-baseline.xml", - "phpunit": "vendor/bin/phpunit --colors=always", - "phpunit_clover": "vendor/bin/phpunit --coverage-text --coverage-clover build/logs/clover.xml", - "coverage": "XDEBUG_MODE=coverage vendor/bin/phpunit --coverage-html tests/_reports", - "phpcs": "vendor/bin/phpcs --standard=ruleset.xml --extensions=php --cache=.phpcs-cache --ignore=tests/TestEntities/NonRepositoryWithAttributeInUse.php,tests/TestEntities/UserNickname.php --colors src bin tests", - "phpcsd": "vendor/bin/phpcs -s --standard=ruleset.xml --extensions=php --cache=.phpcs-cache --ignore=tests/TestEntities/NonRepositoryWithAttributeInUse.php,tests/TestEntities/UserNickname.php --colors src bin tests", - "phpcsfix": "vendor/bin/phpcbf --standard=ruleset.xml --extensions=php --cache=.phpcs-cache --ignore=tests/TestEntities/NonRepositoryWithAttributeInUse.php,tests/TestEntities/UserNickname.php src bin tests", - "binupdate": "@composer bin all update --ansi", - "bininstall": "@composer bin all install --ansi" + "phpstan": "vendor-bin/phpstan/vendor/bin/phpstan analyse --configuration=tools/phpstan.neon", + "phpstan_full": "rm -Rf tools/cache/phpstan && vendor-bin/phpstan/vendor/bin/phpstan analyse --configuration=tools/phpstan.neon", + "phpstan_base": "vendor-bin/phpstan/vendor/bin/phpstan analyse --configuration=tools/phpstan.neon --generate-baseline=tools/phpstan-baseline.php", + "psalm": "vendor-bin/psalm/vendor/bin/psalm --config=tools/psalm.xml --show-info=false", + "psalm_full": "vendor-bin/psalm/vendor/bin/psalm --config=tools/psalm.xml --clear-cache && vendor-bin/psalm/vendor/bin/psalm --config=tools/psalm.xml --show-info=false", + "psalm_base": "vendor-bin/psalm/vendor/bin/psalm --config=tools/psalm.xml --set-baseline=tools/psalm-baseline.xml", + "phpunit": "vendor/bin/phpunit --configuration=tools/phpunit.xml.dist --colors=always", + "phpunit_clover": "vendor/bin/phpunit --configuration=tools/phpunit.xml.dist --coverage-text --coverage-clover build/logs/clover.xml", + "coverage": "XDEBUG_MODE=coverage vendor/bin/phpunit --configuration=tools/phpunit.xml.dist --coverage-html=tests/_reports", + "phpcs": "vendor-bin/phpcs/vendor/bin/phpcs --standard=tools/ruleset.xml --extensions=php --cache=tools/cache/.phpcs-cache --ignore=tests/TestEntities/NonRepositoryWithAttributeInUse.php,tests/TestEntities/UserNickname.php --colors src tests", + "phpcs_diff": "vendor-bin/phpcs/vendor/bin/phpcs -s --standard=tools/ruleset.xml --extensions=php --cache=tools/cache/.phpcs-cache --ignore=tests/TestEntities/NonRepositoryWithAttributeInUse.php,tests/TestEntities/UserNickname.php --colors src tests", + "phpcs_fix": "vendor-bin/phpcs/vendor/bin/phpcbf --standard=tools/ruleset.xml --extensions=php --cache=tools/cache/.phpcs-cache --ignore=tests/TestEntities/NonRepositoryWithAttributeInUse.php,tests/TestEntities/UserNickname.php --colors src tests", + "binupdate": "bin/vendorbin update", + "binoutdated": "bin/vendorbin outdated" } } diff --git a/docker/compose/composer.yml b/docker/compose/composer.yml new file mode 100644 index 0000000..63cf280 --- /dev/null +++ b/docker/compose/composer.yml @@ -0,0 +1,26 @@ +services: + composer: + image: thecodingmachine/php:8.2-v4-cli + container_name: squirrel_composer + working_dir: /usr/src/app + command: [ "composer", "${COMPOSER_COMMAND}", "--ansi" ] + logging: + driver: "none" + volumes: + - .:/usr/src/app + - "$HOME/.cache/composer:/tmp/composer_cache" + environment: + COMPOSER_CACHE_DIR: "/tmp/composer_cache" + COMPOSER_ROOT_VERSION: 'dev-master' + # Basic config for CLI commands + PHP_INI_ERROR_REPORTING: "E_ALL" + PHP_INI_MEMORY_LIMIT: "1g" + PHP_INI_MAX_EXECUTION_TIME: 3600 + # Enable Opcache + JIT + PHP_INI_OPCACHE__ENABLE_CLI: 1 + PHP_INI_OPCACHE__MEMORY_CONSUMPTION: 256 + PHP_INI_OPCACHE__VALIDATE_TIMESTAMPS: 0 + PHP_INI_JIT_BUFFER_SIZE: "256m" + # For code coverage + PHP_EXTENSION_XDEBUG: 1 + XDEBUG_MODE: coverage \ No newline at end of file diff --git a/docker/composer b/docker/composer new file mode 100755 index 0000000..1cf19f2 --- /dev/null +++ b/docker/composer @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +# Get directory of this script +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" + +COMPOSER_COMMAND="$@" docker compose -f "$DIR/compose/composer.yml" --project-directory "$DIR/.." --project-name=squirrel_composer up --abort-on-container-exit --exit-code-from=composer --no-log-prefix composer 2>&1 \ No newline at end of file diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon deleted file mode 100644 index f5586c8..0000000 --- a/phpstan-baseline.neon +++ /dev/null @@ -1,152 +0,0 @@ -parameters: - ignoreErrors: - - - message: "#^Method Squirrel\\\\Entities\\\\Attribute\\\\EntityProcessor\\:\\:getEntityFromAttribute\\(\\) has parameter \\$class with generic class ReflectionClass but does not specify its types\\: T$#" - count: 1 - path: src/Attribute/EntityProcessor.php - - - - message: "#^Property Squirrel\\\\Entities\\\\Builder\\\\MultiSelectIterator\\:\\:\\$selectReference is never read, only written\\.$#" - count: 1 - path: src/Builder/MultiSelectIterator.php - - - - message: "#^Property Squirrel\\\\Entities\\\\Builder\\\\MultiSelectIterator\\:\\:\\$source is never read, only written\\.$#" - count: 1 - path: src/Builder/MultiSelectIterator.php - - - - message: "#^Class Squirrel\\\\Entities\\\\Builder\\\\SelectEntries implements generic interface IteratorAggregate but does not specify its types\\: TKey, TValue$#" - count: 1 - path: src/Builder/SelectEntries.php - - - - message: "#^Class Squirrel\\\\Entities\\\\Builder\\\\SelectIterator implements generic interface Iterator but does not specify its types\\: TKey, TValue$#" - count: 1 - path: src/Builder/SelectIterator.php - - - - message: "#^Property Squirrel\\\\Entities\\\\Builder\\\\SelectIterator\\:\\:\\$selectReference is never read, only written\\.$#" - count: 1 - path: src/Builder/SelectIterator.php - - - - message: "#^Property Squirrel\\\\Entities\\\\Builder\\\\SelectIterator\\:\\:\\$source is never read, only written\\.$#" - count: 1 - path: src/Builder/SelectIterator.php - - - - message: "#^Cannot call method getObjectToTableFields\\(\\) on mixed\\.$#" - count: 1 - path: src/MultiRepositoryReadOnly.php - - - - message: "#^Cannot call method getObjectTypes\\(\\) on mixed\\.$#" - count: 1 - path: src/MultiRepositoryReadOnly.php - - - - message: "#^Cannot call method getObjectTypesNullable\\(\\) on mixed\\.$#" - count: 1 - path: src/MultiRepositoryReadOnly.php - - - - message: "#^Cannot call method getTableName\\(\\) on mixed\\.$#" - count: 1 - path: src/MultiRepositoryReadOnly.php - - - - message: "#^Match expression does not handle remaining value\\: mixed$#" - count: 1 - path: src/MultiRepositoryReadOnly.php - - - - message: "#^Method Squirrel\\\\Entities\\\\MultiRepositoryReadOnly\\:\\:fetchAllAndFlatten\\(\\) should return array\\ but returns array\\, mixed\\>\\.$#" - count: 1 - path: src/MultiRepositoryReadOnly.php - - - - message: "#^Offset 'where' on array\\{repositories\\: array, tables\\?\\: array, where\\: array, lock\\?\\: bool\\} in isset\\(\\) always exists and is not nullable\\.$#" - count: 1 - path: src/MultiRepositoryReadOnly.php - - - - message: "#^Parameter \\#1 \\$object of method ReflectionProperty\\:\\:getValue\\(\\) expects object\\|null, mixed given\\.$#" - count: 2 - path: src/MultiRepositoryReadOnly.php - - - - message: "#^Parameter \\#1 \\$objectOrClass of class ReflectionClass constructor expects class\\-string\\\\|T of object, mixed given\\.$#" - count: 1 - path: src/MultiRepositoryReadOnly.php - - - - message: "#^Argument of an invalid type mixed supplied for foreach, only iterables are supported\\.$#" - count: 2 - path: src/RepositoryReadOnly.php - - - - message: "#^Cannot access offset mixed on mixed\\.$#" - count: 1 - path: src/RepositoryReadOnly.php - - - - message: "#^Match expression does not handle remaining value\\: mixed$#" - count: 1 - path: src/RepositoryReadOnly.php - - - - message: "#^Offset 'limit' on array\\{fields\\?\\: array\\, field\\?\\: string, where\\?\\: array\\, order\\?\\: array\\, offset\\?\\: int, lock\\?\\: bool\\} in isset\\(\\) does not exist\\.$#" - count: 1 - path: src/RepositoryReadOnly.php - - - - message: "#^Parameter \\#1 \\$array of function array_values expects array, mixed given\\.$#" - count: 1 - path: src/RepositoryReadOnly.php - - - - message: "#^Parameter \\#1 \\$orderOptions of method Squirrel\\\\Entities\\\\RepositoryReadOnly\\:\\:preprocessOrder\\(\\) expects array\\, mixed given\\.$#" - count: 1 - path: src/RepositoryReadOnly.php - - - - message: "#^Parameter \\#1 \\$query of method Squirrel\\\\Queries\\\\DBInterface\\:\\:fetchAll\\(\\) expects array\\{fields\\?\\: array\\, field\\?\\: string, tables\\?\\: array\\, table\\?\\: string, where\\?\\: array\\, group\\?\\: array\\, order\\?\\: array\\, limit\\?\\: int, \\.\\.\\.\\}\\|string, array\\ given\\.$#" - count: 2 - path: src/RepositoryReadOnly.php - - - - message: "#^Parameter \\#1 \\$query of method Squirrel\\\\Queries\\\\DBInterface\\:\\:select\\(\\) expects array\\{fields\\?\\: array\\, field\\?\\: string, tables\\?\\: array\\, table\\?\\: string, where\\?\\: array\\, group\\?\\: array\\, order\\?\\: array\\, limit\\?\\: int, \\.\\.\\.\\}\\|string, array\\ given\\.$#" - count: 1 - path: src/RepositoryReadOnly.php - - - - message: "#^Parameter \\#1 \\$value of function count expects array\\|Countable, mixed given\\.$#" - count: 3 - path: src/RepositoryReadOnly.php - - - - message: "#^Parameter \\#1 \\$value of function floatval expects array\\|bool\\|float\\|int\\|resource\\|string\\|null, mixed given\\.$#" - count: 1 - path: src/RepositoryReadOnly.php - - - - message: "#^Parameter \\#1 \\$value of function intval expects array\\|bool\\|float\\|int\\|resource\\|string\\|null, mixed given\\.$#" - count: 2 - path: src/RepositoryReadOnly.php - - - - message: "#^Parameter \\#1 \\$value of function strval expects bool\\|float\\|int\\|resource\\|string\\|null, mixed given\\.$#" - count: 1 - path: src/RepositoryReadOnly.php - - - - message: "#^Parameter \\#1 \\$where of method Squirrel\\\\Entities\\\\RepositoryReadOnly\\:\\:preprocessWhere\\(\\) expects array\\, mixed given\\.$#" - count: 1 - path: src/RepositoryReadOnly.php - - - - message: "#^Result of && is always false\\.$#" - count: 1 - path: src/RepositoryReadOnly.php - diff --git a/phpstan.neon b/phpstan.neon deleted file mode 100644 index ddd51b4..0000000 --- a/phpstan.neon +++ /dev/null @@ -1,9 +0,0 @@ -includes: - - phpstan-baseline.neon - -parameters: - level: max - paths: - - src - - bin - checkMissingIterableValueType: false \ No newline at end of file diff --git a/src/RepositoryReadOnly.php b/src/RepositoryReadOnly.php index d17f0b6..ab462b4 100644 --- a/src/RepositoryReadOnly.php +++ b/src/RepositoryReadOnly.php @@ -2,12 +2,12 @@ namespace Squirrel\Entities; +use Squirrel\Connection\LargeObject; use Squirrel\Debug\Debug; use Squirrel\Queries\Builder\BuilderInterface; use Squirrel\Queries\DBException; use Squirrel\Queries\DBInterface; use Squirrel\Queries\Exception\DBInvalidOptionException; -use Squirrel\Queries\LargeObject; use Squirrel\Types\Coerce; /** diff --git a/tests/RepositoryTest.php b/tests/RepositoryTest.php index e1db512..717e395 100644 --- a/tests/RepositoryTest.php +++ b/tests/RepositoryTest.php @@ -4,6 +4,7 @@ use Hamcrest\Core\IsEqual; use Mockery\MockInterface; +use Squirrel\Connection\LargeObject; use Squirrel\Entities\RepositoryConfig; use Squirrel\Entities\RepositoryReadOnly; use Squirrel\Entities\RepositorySelectQuery; @@ -12,7 +13,6 @@ use Squirrel\Queries\DBInterface; use Squirrel\Queries\DBSelectQueryInterface; use Squirrel\Queries\Exception\DBInvalidOptionException; -use Squirrel\Queries\LargeObject; class RepositoryTest extends \PHPUnit\Framework\TestCase { diff --git a/tools/cache/.gitkeep b/tools/cache/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/captainhook.json b/tools/captainhook.json similarity index 100% rename from captainhook.json rename to tools/captainhook.json diff --git a/tools/phpstan-baseline.php b/tools/phpstan-baseline.php new file mode 100644 index 0000000..720efd3 --- /dev/null +++ b/tools/phpstan-baseline.php @@ -0,0 +1,197 @@ + '#^Parameter \\#1 \\$sourceCodeDirectories of class Squirrel\\\\Entities\\\\Generate\\\\RepositoriesGenerateCommand constructor expects array\\, mixed given\\.$#', + 'count' => 1, + 'path' => __DIR__ . '/../bin/squirrel_repositories_generate', +]; +$ignoreErrors[] = [ + // identifier: argument.type + 'message' => '#^Parameter \\#2 \\$forceFileCreation of class Squirrel\\\\Entities\\\\Generate\\\\RepositoriesGenerateCommand constructor expects bool, mixed given\\.$#', + 'count' => 1, + 'path' => __DIR__ . '/../bin/squirrel_repositories_generate', +]; +$ignoreErrors[] = [ + // identifier: missingType.generics + 'message' => '#^Method Squirrel\\\\Entities\\\\Attribute\\\\EntityProcessor\\:\\:getEntityFromAttribute\\(\\) has parameter \\$class with generic class ReflectionClass but does not specify its types\\: T$#', + 'count' => 1, + 'path' => __DIR__ . '/../src/Attribute/EntityProcessor.php', +]; +$ignoreErrors[] = [ + // identifier: property.onlyWritten + 'message' => '#^Property Squirrel\\\\Entities\\\\Builder\\\\MultiSelectIterator\\:\\:\\$selectReference is never read, only written\\.$#', + 'count' => 1, + 'path' => __DIR__ . '/../src/Builder/MultiSelectIterator.php', +]; +$ignoreErrors[] = [ + // identifier: property.onlyWritten + 'message' => '#^Property Squirrel\\\\Entities\\\\Builder\\\\MultiSelectIterator\\:\\:\\$source is never read, only written\\.$#', + 'count' => 1, + 'path' => __DIR__ . '/../src/Builder/MultiSelectIterator.php', +]; +$ignoreErrors[] = [ + // identifier: missingType.generics + 'message' => '#^Class Squirrel\\\\Entities\\\\Builder\\\\SelectEntries implements generic interface IteratorAggregate but does not specify its types\\: TKey, TValue$#', + 'count' => 1, + 'path' => __DIR__ . '/../src/Builder/SelectEntries.php', +]; +$ignoreErrors[] = [ + // identifier: missingType.generics + 'message' => '#^Class Squirrel\\\\Entities\\\\Builder\\\\SelectIterator implements generic interface Iterator but does not specify its types\\: TKey, TValue$#', + 'count' => 1, + 'path' => __DIR__ . '/../src/Builder/SelectIterator.php', +]; +$ignoreErrors[] = [ + // identifier: property.onlyWritten + 'message' => '#^Property Squirrel\\\\Entities\\\\Builder\\\\SelectIterator\\:\\:\\$selectReference is never read, only written\\.$#', + 'count' => 1, + 'path' => __DIR__ . '/../src/Builder/SelectIterator.php', +]; +$ignoreErrors[] = [ + // identifier: property.onlyWritten + 'message' => '#^Property Squirrel\\\\Entities\\\\Builder\\\\SelectIterator\\:\\:\\$source is never read, only written\\.$#', + 'count' => 1, + 'path' => __DIR__ . '/../src/Builder/SelectIterator.php', +]; +$ignoreErrors[] = [ + // identifier: method.nonObject + 'message' => '#^Cannot call method getObjectToTableFields\\(\\) on mixed\\.$#', + 'count' => 1, + 'path' => __DIR__ . '/../src/MultiRepositoryReadOnly.php', +]; +$ignoreErrors[] = [ + // identifier: method.nonObject + 'message' => '#^Cannot call method getObjectTypes\\(\\) on mixed\\.$#', + 'count' => 1, + 'path' => __DIR__ . '/../src/MultiRepositoryReadOnly.php', +]; +$ignoreErrors[] = [ + // identifier: method.nonObject + 'message' => '#^Cannot call method getObjectTypesNullable\\(\\) on mixed\\.$#', + 'count' => 1, + 'path' => __DIR__ . '/../src/MultiRepositoryReadOnly.php', +]; +$ignoreErrors[] = [ + // identifier: method.nonObject + 'message' => '#^Cannot call method getTableName\\(\\) on mixed\\.$#', + 'count' => 1, + 'path' => __DIR__ . '/../src/MultiRepositoryReadOnly.php', +]; +$ignoreErrors[] = [ + // identifier: match.unhandled + 'message' => '#^Match expression does not handle remaining value\\: mixed$#', + 'count' => 1, + 'path' => __DIR__ . '/../src/MultiRepositoryReadOnly.php', +]; +$ignoreErrors[] = [ + // identifier: return.type + 'message' => '#^Method Squirrel\\\\Entities\\\\MultiRepositoryReadOnly\\:\\:fetchAllAndFlatten\\(\\) should return array\\ but returns array\\, mixed\\>\\.$#', + 'count' => 1, + 'path' => __DIR__ . '/../src/MultiRepositoryReadOnly.php', +]; +$ignoreErrors[] = [ + // identifier: isset.offset + 'message' => '#^Offset \'where\' on array\\{repositories\\: array, tables\\?\\: array, where\\: array, lock\\?\\: bool\\} in isset\\(\\) always exists and is not nullable\\.$#', + 'count' => 1, + 'path' => __DIR__ . '/../src/MultiRepositoryReadOnly.php', +]; +$ignoreErrors[] = [ + // identifier: argument.type + 'message' => '#^Parameter \\#1 \\$object of method ReflectionProperty\\:\\:getValue\\(\\) expects object\\|null, mixed given\\.$#', + 'count' => 2, + 'path' => __DIR__ . '/../src/MultiRepositoryReadOnly.php', +]; +$ignoreErrors[] = [ + // identifier: argument.type + 'message' => '#^Parameter \\#1 \\$objectOrClass of class ReflectionClass constructor expects class\\-string\\\\|T of object, mixed given\\.$#', + 'count' => 1, + 'path' => __DIR__ . '/../src/MultiRepositoryReadOnly.php', +]; +$ignoreErrors[] = [ + // identifier: foreach.nonIterable + 'message' => '#^Argument of an invalid type mixed supplied for foreach, only iterables are supported\\.$#', + 'count' => 2, + 'path' => __DIR__ . '/../src/RepositoryReadOnly.php', +]; +$ignoreErrors[] = [ + // identifier: offsetAccess.nonOffsetAccessible + 'message' => '#^Cannot access offset mixed on mixed\\.$#', + 'count' => 1, + 'path' => __DIR__ . '/../src/RepositoryReadOnly.php', +]; +$ignoreErrors[] = [ + // identifier: match.unhandled + 'message' => '#^Match expression does not handle remaining value\\: mixed$#', + 'count' => 1, + 'path' => __DIR__ . '/../src/RepositoryReadOnly.php', +]; +$ignoreErrors[] = [ + // identifier: isset.offset + 'message' => '#^Offset \'limit\' on array\\{fields\\?\\: array\\, field\\?\\: string, where\\?\\: array\\, order\\?\\: array\\, offset\\?\\: int, lock\\?\\: bool\\} in isset\\(\\) does not exist\\.$#', + 'count' => 1, + 'path' => __DIR__ . '/../src/RepositoryReadOnly.php', +]; +$ignoreErrors[] = [ + // identifier: argument.type + 'message' => '#^Parameter \\#1 \\$array of function array_values expects array\\, mixed given\\.$#', + 'count' => 1, + 'path' => __DIR__ . '/../src/RepositoryReadOnly.php', +]; +$ignoreErrors[] = [ + // identifier: argument.type + 'message' => '#^Parameter \\#1 \\$orderOptions of method Squirrel\\\\Entities\\\\RepositoryReadOnly\\:\\:preprocessOrder\\(\\) expects array\\, mixed given\\.$#', + 'count' => 1, + 'path' => __DIR__ . '/../src/RepositoryReadOnly.php', +]; +$ignoreErrors[] = [ + // identifier: argument.type + 'message' => '#^Parameter \\#1 \\$query of method Squirrel\\\\Queries\\\\DBInterface\\:\\:fetchAll\\(\\) expects array\\{fields\\?\\: array\\, field\\?\\: string, tables\\?\\: array\\, table\\?\\: string, where\\?\\: array\\, group\\?\\: array\\, order\\?\\: array\\, limit\\?\\: int, \\.\\.\\.\\}\\|string, array\\ given\\.$#', + 'count' => 2, + 'path' => __DIR__ . '/../src/RepositoryReadOnly.php', +]; +$ignoreErrors[] = [ + // identifier: argument.type + 'message' => '#^Parameter \\#1 \\$query of method Squirrel\\\\Queries\\\\DBInterface\\:\\:select\\(\\) expects array\\{fields\\?\\: array\\, field\\?\\: string, tables\\?\\: array\\, table\\?\\: string, where\\?\\: array\\, group\\?\\: array\\, order\\?\\: array\\, limit\\?\\: int, \\.\\.\\.\\}\\|string, array\\ given\\.$#', + 'count' => 1, + 'path' => __DIR__ . '/../src/RepositoryReadOnly.php', +]; +$ignoreErrors[] = [ + // identifier: argument.type + 'message' => '#^Parameter \\#1 \\$value of function count expects array\\|Countable, mixed given\\.$#', + 'count' => 3, + 'path' => __DIR__ . '/../src/RepositoryReadOnly.php', +]; +$ignoreErrors[] = [ + // identifier: argument.type + 'message' => '#^Parameter \\#1 \\$value of function floatval expects array\\|bool\\|float\\|int\\|resource\\|string\\|null, mixed given\\.$#', + 'count' => 1, + 'path' => __DIR__ . '/../src/RepositoryReadOnly.php', +]; +$ignoreErrors[] = [ + // identifier: argument.type + 'message' => '#^Parameter \\#1 \\$value of function intval expects array\\|bool\\|float\\|int\\|resource\\|string\\|null, mixed given\\.$#', + 'count' => 2, + 'path' => __DIR__ . '/../src/RepositoryReadOnly.php', +]; +$ignoreErrors[] = [ + // identifier: argument.type + 'message' => '#^Parameter \\#1 \\$value of function strval expects bool\\|float\\|int\\|resource\\|string\\|null, mixed given\\.$#', + 'count' => 1, + 'path' => __DIR__ . '/../src/RepositoryReadOnly.php', +]; +$ignoreErrors[] = [ + // identifier: argument.type + 'message' => '#^Parameter \\#1 \\$where of method Squirrel\\\\Entities\\\\RepositoryReadOnly\\:\\:preprocessWhere\\(\\) expects array\\, mixed given\\.$#', + 'count' => 1, + 'path' => __DIR__ . '/../src/RepositoryReadOnly.php', +]; +$ignoreErrors[] = [ + // identifier: booleanAnd.alwaysFalse + 'message' => '#^Result of && is always false\\.$#', + 'count' => 1, + 'path' => __DIR__ . '/../src/RepositoryReadOnly.php', +]; + +return ['parameters' => ['ignoreErrors' => $ignoreErrors]]; diff --git a/tools/phpstan.neon b/tools/phpstan.neon new file mode 100644 index 0000000..a7906fa --- /dev/null +++ b/tools/phpstan.neon @@ -0,0 +1,12 @@ +includes: + - phpstan-baseline.php + +parameters: + level: max + paths: + - ../src + - ../bin/squirrel_repositories_generate + tmpDir: cache/phpstan + ignoreErrors: + - + identifier: missingType.iterableValue \ No newline at end of file diff --git a/phpunit.xml.dist b/tools/phpunit.xml.dist similarity index 51% rename from phpunit.xml.dist rename to tools/phpunit.xml.dist index 67a1f9a..0d3c88a 100644 --- a/phpunit.xml.dist +++ b/tools/phpunit.xml.dist @@ -1,17 +1,17 @@ - + - tests + ../tests - src + ../src - src/Generate/PHPFilesInDirectoryGetContents.php + ../src/Generate/PHPFilesInDirectoryGetContents.php diff --git a/psalm-baseline.xml b/tools/psalm-baseline.xml similarity index 65% rename from psalm-baseline.xml rename to tools/psalm-baseline.xml index 525010e..0dafdc1 100644 --- a/psalm-baseline.xml +++ b/tools/psalm-baseline.xml @@ -1,19 +1,19 @@ - + - \IteratorAggregate + - \Iterator + - $db - $db + + @@ -21,9 +21,9 @@ - $sanitizedQuery - $sanitizedQuery - $sanitizedQuery + + + diff --git a/psalm.xml b/tools/psalm.xml similarity index 91% rename from psalm.xml rename to tools/psalm.xml index b9bedf4..67168a7 100644 --- a/psalm.xml +++ b/tools/psalm.xml @@ -5,9 +5,12 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="https://getpsalm.org/schema/config" xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd" - errorBaseline="psalm-baseline.xml" + errorBaseline="tools/psalm-baseline.xml" findUnusedBaselineEntry="true" findUnusedCode="false" + autoloader="vendor/autoload.php" + resolveFromConfigFile="false" + cacheDirectory="tools/cache/psalm" > diff --git a/ruleset.xml b/tools/ruleset.xml similarity index 100% rename from ruleset.xml rename to tools/ruleset.xml