From 991a32b6682eed02daf502919f69c3105609959a Mon Sep 17 00:00:00 2001 From: Jakub-Fajkus Date: Wed, 26 Jan 2022 11:12:01 +0100 Subject: [PATCH 01/14] Allow PHP 8.1 --- .travis.yml | 14 ++++++++++++++ composer.json | 7 ++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index f0b108f..009f197 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,8 @@ cache: php: - 7.4 + - 8.0 + - 8.1 services: - elasticsearch @@ -25,6 +27,18 @@ matrix: env: COMPOSER_EXTRA_ARGS="" PHPSTAN=1 RUN_TESTS=0 - php: 7.4 env: COMPOSER_EXTRA_ARGS="" CODING_STANDARD=1 RUN_TESTS=0 + - php: 8.0 + env: COMPOSER_EXTRA_ARGS="" COVERAGE="--coverage ./coverage.xml --coverage-src ./src" + - php: 8.0 + env: COMPOSER_EXTRA_ARGS="" PHPSTAN=1 RUN_TESTS=0 + - php: 8.0 + env: COMPOSER_EXTRA_ARGS="" CODING_STANDARD=1 RUN_TESTS=0 + - php: 8.1 + env: COMPOSER_EXTRA_ARGS="" COVERAGE="--coverage ./coverage.xml --coverage-src ./src" + - php: 8.1 + env: COMPOSER_EXTRA_ARGS="" PHPSTAN=1 RUN_TESTS=0 + - php: 8.1 + env: COMPOSER_EXTRA_ARGS="" CODING_STANDARD=1 RUN_TESTS=0 before_install: - travis_retry composer self-update diff --git a/composer.json b/composer.json index 05bd80f..1cc4095 100644 --- a/composer.json +++ b/composer.json @@ -31,7 +31,7 @@ "elasticsearch/elasticsearch": "^2.4.0 || ^7.12.0", "nette/di": "^2.4.17 || ^3.0", "nette/utils": "^2.5.7 || ^3.0", - "kdyby/console": "^2.7.1 || ^2.8.0", + "kdyby/console": "^4.0.0", "symfony/console": "^4", "tracy/tracy": "^2.6.7", "monolog/monolog": "^2.0.2", @@ -56,5 +56,10 @@ "psr-4": { "SpameriTests\\": "tests/SpameriTests" } + }, + "config": { + "allow-plugins": { + "dealerdirect/phpcodesniffer-composer-installer": true + } } } From ba4d10001f1aec393dd9527e8e548975cdf2c941 Mon Sep 17 00:00:00 2001 From: Jakub-Fajkus Date: Fri, 4 Feb 2022 15:38:40 +0100 Subject: [PATCH 02/14] cs --- src/Model/Indices/GetFieldMapping.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Model/Indices/GetFieldMapping.php b/src/Model/Indices/GetFieldMapping.php index 03a333d..cad9a7d 100644 --- a/src/Model/Indices/GetFieldMapping.php +++ b/src/Model/Indices/GetFieldMapping.php @@ -7,8 +7,6 @@ class GetFieldMapping private \Spameri\Elastic\ClientProvider $clientProvider; - private \Spameri\Elastic\Model\VersionProvider $versionProvider; - public function __construct( \Spameri\Elastic\ClientProvider $clientProvider From 414e6aa6b62814cc3f52e43042218845df1b97d7 Mon Sep 17 00:00:00 2001 From: Jakub-Fajkus Date: Fri, 4 Feb 2022 15:49:32 +0100 Subject: [PATCH 03/14] drop travis.yml --- .travis.yml | 58 ----------------------------------------------------- 1 file changed, 58 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 009f197..0000000 --- a/.travis.yml +++ /dev/null @@ -1,58 +0,0 @@ -language: php - -cache: - directories: - - $HOME/.composer/cache - - $HOME/phpcs-cache - -php: - - 7.4 - - 8.0 - - 8.1 - -services: - - elasticsearch - -env: - matrix: - - RUN_TESTS=1 COMPOSER_EXTRA_ARGS="" - - RUN_TESTS=1 COMPOSER_EXTRA_ARGS="--prefer-lowest" - -matrix: - fast_finish: true - include: - - php: 7.4 - env: COMPOSER_EXTRA_ARGS="" COVERAGE="--coverage ./coverage.xml --coverage-src ./src" - - php: 7.4 - env: COMPOSER_EXTRA_ARGS="" PHPSTAN=1 RUN_TESTS=0 - - php: 7.4 - env: COMPOSER_EXTRA_ARGS="" CODING_STANDARD=1 RUN_TESTS=0 - - php: 8.0 - env: COMPOSER_EXTRA_ARGS="" COVERAGE="--coverage ./coverage.xml --coverage-src ./src" - - php: 8.0 - env: COMPOSER_EXTRA_ARGS="" PHPSTAN=1 RUN_TESTS=0 - - php: 8.0 - env: COMPOSER_EXTRA_ARGS="" CODING_STANDARD=1 RUN_TESTS=0 - - php: 8.1 - env: COMPOSER_EXTRA_ARGS="" COVERAGE="--coverage ./coverage.xml --coverage-src ./src" - - php: 8.1 - env: COMPOSER_EXTRA_ARGS="" PHPSTAN=1 RUN_TESTS=0 - - php: 8.1 - env: COMPOSER_EXTRA_ARGS="" CODING_STANDARD=1 RUN_TESTS=0 - -before_install: - - travis_retry composer self-update - -install: - - travis_retry composer update --no-interaction --no-suggest --no-progress --prefer-dist --prefer-stable $COMPOSER_EXTRA_ARGS # update because we may need --prefer-lowest option - -script: - - if [ "$PHPSTAN" = "1" ]; then make phpstan; fi - - if [ "$CODING_STANDARD" = "1" ]; then make cs; fi - - if [ "$RUN_TESTS" = "1" ]; then make coverage; fi - -after_script: - - if [ "$COVERAGE" != "" ]; then vendor/bin/php-coveralls --verbose --config tests/.coveralls.yml || true; fi - -after_failure: - - 'for i in $(find ./tests -name \*.actual); do echo "--- $i"; cat $i; echo; echo; done' From 09e4202fee607b74d883f91b3fab72e48e385023 Mon Sep 17 00:00:00 2001 From: Jakub-Fajkus Date: Fri, 4 Feb 2022 15:49:49 +0100 Subject: [PATCH 04/14] add php 8.0 and 8.1 to ci matrix --- .github/workflows/ci.yml | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ed45f83..1bf70c8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,7 +9,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php: [ 7.4 ] + php: [ 7.4, 8.0, 8.1 ] version: [ lowest, standard ] elastic: [ 7.12.1 ] @@ -39,19 +39,18 @@ jobs: name: Composer standard run: make composer - - if: matrix.php == '7.4' + - if: matrix.php == '8.1' name: Coding standard run: make cs - - if: matrix.php == '7.4' && matrix.version == 'lowest' + - if: matrix.version == 'lowest' name: PHPStan lowest run: make phpstan-lowest - - if: matrix.php == '7.4' && matrix.version == 'standard' + - if: matrix.version == 'standard' name: PHPStan standard run: make phpstan - - if: matrix.php == '7.4' - name: Tests + - name: Tests run: make tests From 98354c381f36b853b59efaac37c7e77ec45999b6 Mon Sep 17 00:00:00 2001 From: Jakub-Fajkus Date: Fri, 4 Feb 2022 15:54:12 +0100 Subject: [PATCH 05/14] add php 8.0 and 8.1 to ci matrix --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1bf70c8..c403feb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -39,15 +39,15 @@ jobs: name: Composer standard run: make composer - - if: matrix.php == '8.1' + - if: matrix.php == '7.4' name: Coding standard run: make cs - - if: matrix.version == 'lowest' + - if: matrix.php == '7.4' && matrix.version == 'lowest' name: PHPStan lowest run: make phpstan-lowest - - if: matrix.version == 'standard' + - if: matrix.php == '7.4' && matrix.version == 'standard' name: PHPStan standard run: make phpstan From 34df33254779828fdd57799dd8c3971914eecf6a Mon Sep 17 00:00:00 2001 From: Jakub-Fajkus Date: Fri, 4 Feb 2022 16:38:13 +0100 Subject: [PATCH 06/14] Drop nette 2.4 and ES 2.4 --- composer.json | 12 +++--- src/DI/SpameriElasticSearchExtension.php | 49 ++++-------------------- 2 files changed, 13 insertions(+), 48 deletions(-) diff --git a/composer.json b/composer.json index 1cc4095..3b1202d 100644 --- a/composer.json +++ b/composer.json @@ -28,10 +28,9 @@ "ext-json": "*", "ext-curl": "*", "spameri/elastic-query": "^v1.0.0-alpha.10", - "elasticsearch/elasticsearch": "^2.4.0 || ^7.12.0", - "nette/di": "^2.4.17 || ^3.0", - "nette/utils": "^2.5.7 || ^3.0", - "kdyby/console": "^4.0.0", + "elasticsearch/elasticsearch": "^7.12.0", + "nette/di": "^3.0", + "nette/utils": "^3.0", "symfony/console": "^4", "tracy/tracy": "^2.6.7", "monolog/monolog": "^2.0.2", @@ -43,8 +42,9 @@ "nette/tester": "^2.4", "phpstan/phpstan": "0.12.84", "php-coveralls/php-coveralls": "^2.1", - "nette/bootstrap": "~2.4.6 || ^3.0", - "nette/http": "^2.4.12 || ^3.0", + "nette/bootstrap": "^3.0", + "nette/http": "^3.0", + "kdyby/console": "^4.0.0", "mockery/mockery": "^1.2" }, "autoload": { diff --git a/src/DI/SpameriElasticSearchExtension.php b/src/DI/SpameriElasticSearchExtension.php index 2ee9756..34a2a60 100644 --- a/src/DI/SpameriElasticSearchExtension.php +++ b/src/DI/SpameriElasticSearchExtension.php @@ -31,29 +31,17 @@ public function loadConfiguration(): void $services = $this->toggleDebugBar($config, $services); - if ( ! \class_exists(\Symfony\Component\Console\Command\Command::class)) { - $services = $this->removeCommandDefinitions($services); - } - $services = $this->setConfigOptions($services, $config); - if (\method_exists($this->compiler, 'loadDefinitionsFromConfig')) { - $aliasedServices = []; - foreach ($services['services'] as $key => $service) { - $aliasedServices['spameriElasticSearch.' . $key] = $service; - } + $aliasedServices = []; + foreach ($services['services'] as $key => $service) { + $aliasedServices['spameriElasticSearch.' . $key] = $service; + } - $this->compiler->loadDefinitionsFromConfig( - $aliasedServices - ); + $this->compiler->loadDefinitionsFromConfig( + $aliasedServices + ); - } else { - $this->compiler::loadDefinitions( - $this->getContainerBuilder(), - $services['services'], - $this->name - ); - } } @@ -104,27 +92,4 @@ public function toggleDebugBar( return $services; } - - /** - * @param array $services - * @return array - */ - public function removeCommandDefinitions( - array $services - ): array - { - $iterableServices = $services['services']; - foreach ($iterableServices as $serviceKey => $serviceArray) { - if (isset($serviceArray['tags'])) { - foreach ($serviceArray['tags'] as $tag) { - if ($tag === 'kdyby.console.command') { - unset($services[$serviceKey]); - } - } - } - } - - return $services; - } - } From 2e172e3f4db301efb54154040932d37c5784d289 Mon Sep 17 00:00:00 2001 From: Jakub-Fajkus Date: Fri, 4 Feb 2022 16:52:50 +0100 Subject: [PATCH 07/14] bump mockery to ^1.5 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 3b1202d..289ec45 100644 --- a/composer.json +++ b/composer.json @@ -45,7 +45,7 @@ "nette/bootstrap": "^3.0", "nette/http": "^3.0", "kdyby/console": "^4.0.0", - "mockery/mockery": "^1.2" + "mockery/mockery": "^1.5" }, "autoload": { "psr-4": { From ac5a563a559e40cff440b186ce2ef3cd1f21d1b1 Mon Sep 17 00:00:00 2001 From: Jakub-Fajkus Date: Fri, 4 Feb 2022 17:07:09 +0100 Subject: [PATCH 08/14] bump nette/di to ^3.0.5 reason: E_DEPRECATED: Method ReflectionParameter::isArray() is deprecated --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 289ec45..5278b59 100644 --- a/composer.json +++ b/composer.json @@ -29,7 +29,7 @@ "ext-curl": "*", "spameri/elastic-query": "^v1.0.0-alpha.10", "elasticsearch/elasticsearch": "^7.12.0", - "nette/di": "^3.0", + "nette/di": "^3.0.5", "nette/utils": "^3.0", "symfony/console": "^4", "tracy/tracy": "^2.6.7", From c188790f90445e12f22fdb290daf979eb025a881 Mon Sep 17 00:00:00 2001 From: Jakub-Fajkus Date: Fri, 4 Feb 2022 17:14:52 +0100 Subject: [PATCH 09/14] bump ezimuel/ringphp to ^1.2 reason: Warning: Uncaught Error: Object of class UnwindExit could not be converted to string in /var/www/html/vendor/ezimuel/ringphp/src/Future/CompletedFutureArray.php:7 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 5278b59..5285875 100644 --- a/composer.json +++ b/composer.json @@ -34,7 +34,7 @@ "symfony/console": "^4", "tracy/tracy": "^2.6.7", "monolog/monolog": "^2.0.2", - "ezimuel/ringphp": "^1.1.2" + "ezimuel/ringphp": "^1.2" }, "require-dev": { "spameri/coding-standard": "dev-master", From abd1cab65f85be8e0b93d4b5ddd14b1d63ec30e7 Mon Sep 17 00:00:00 2001 From: Jakub-Fajkus Date: Fri, 4 Feb 2022 17:15:26 +0100 Subject: [PATCH 10/14] bump nette/http to ^3.0.7 reason: E_WARNING: Undefined array key "Nette\Http\RequestFactory" --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 5285875..b306b38 100644 --- a/composer.json +++ b/composer.json @@ -43,7 +43,7 @@ "phpstan/phpstan": "0.12.84", "php-coveralls/php-coveralls": "^2.1", "nette/bootstrap": "^3.0", - "nette/http": "^3.0", + "nette/http": "^3.0.7", "kdyby/console": "^4.0.0", "mockery/mockery": "^1.5" }, From 07f6a0f0221993f500eae3d34743e9569a2007da Mon Sep 17 00:00:00 2001 From: Jakub-Fajkus Date: Mon, 7 Feb 2022 09:59:51 +0100 Subject: [PATCH 11/14] Supress type errors --- src/Entity/DateTimeInterface.php | 1 + src/Entity/Property/DateTime.php | 1 + 2 files changed, 2 insertions(+) diff --git a/src/Entity/DateTimeInterface.php b/src/Entity/DateTimeInterface.php index 58ed1f9..c3489a3 100644 --- a/src/Entity/DateTimeInterface.php +++ b/src/Entity/DateTimeInterface.php @@ -5,6 +5,7 @@ interface DateTimeInterface extends \DateTimeInterface { + #[\ReturnTypeWillChange] public function format($format = NULL); } diff --git a/src/Entity/Property/DateTime.php b/src/Entity/Property/DateTime.php index 0c5edc9..9bd2d88 100644 --- a/src/Entity/Property/DateTime.php +++ b/src/Entity/Property/DateTime.php @@ -13,6 +13,7 @@ class DateTime extends \Nette\Utils\DateTime implements \Spameri\Elastic\Entity\ * @param string|null $format * @return string */ + #[\ReturnTypeWillChange] public function format($format = NULL) { if (\is_null($format)) { From 72aa740200f0ba9188d0a1cc038e793c68b61522 Mon Sep 17 00:00:00 2001 From: Jakub-Fajkus Date: Mon, 7 Feb 2022 10:19:40 +0100 Subject: [PATCH 12/14] cs --- src/Entity/DateTimeInterface.php | 2 +- src/Entity/Property/DateTime.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Entity/DateTimeInterface.php b/src/Entity/DateTimeInterface.php index c3489a3..9aea848 100644 --- a/src/Entity/DateTimeInterface.php +++ b/src/Entity/DateTimeInterface.php @@ -5,7 +5,7 @@ interface DateTimeInterface extends \DateTimeInterface { - #[\ReturnTypeWillChange] + #[\ReturnTypeWillChange] public function format($format = NULL); } diff --git a/src/Entity/Property/DateTime.php b/src/Entity/Property/DateTime.php index 9bd2d88..a4df11a 100644 --- a/src/Entity/Property/DateTime.php +++ b/src/Entity/Property/DateTime.php @@ -13,7 +13,7 @@ class DateTime extends \Nette\Utils\DateTime implements \Spameri\Elastic\Entity\ * @param string|null $format * @return string */ - #[\ReturnTypeWillChange] + #[\ReturnTypeWillChange] public function format($format = NULL) { if (\is_null($format)) { From 1a75ca88f13da8672ab763c7ee023e8b4695dead Mon Sep 17 00:00:00 2001 From: Jakub-Fajkus Date: Mon, 7 Feb 2022 10:33:03 +0100 Subject: [PATCH 13/14] set lowest versions --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index b306b38..049100b 100644 --- a/composer.json +++ b/composer.json @@ -30,8 +30,8 @@ "spameri/elastic-query": "^v1.0.0-alpha.10", "elasticsearch/elasticsearch": "^7.12.0", "nette/di": "^3.0.5", - "nette/utils": "^3.0", - "symfony/console": "^4", + "nette/utils": "^3.2.5", + "symfony/console": "^4.4.26", "tracy/tracy": "^2.6.7", "monolog/monolog": "^2.0.2", "ezimuel/ringphp": "^1.2" From 36317691262940b0e2bdf9ed714bf2ee2c79b38b Mon Sep 17 00:00:00 2001 From: Jakub-Fajkus Date: Tue, 8 Feb 2022 10:54:38 +0100 Subject: [PATCH 14/14] fix lowest version of elastic-query --- composer.json | 2 +- phpstan-low.neon | 9 --------- phpstan.neon | 6 +++--- .../Collection/AbstractElasticEntityCollection.php | 1 + 4 files changed, 5 insertions(+), 13 deletions(-) diff --git a/composer.json b/composer.json index 049100b..b66d82b 100644 --- a/composer.json +++ b/composer.json @@ -27,7 +27,7 @@ "php": ">=7.4", "ext-json": "*", "ext-curl": "*", - "spameri/elastic-query": "^v1.0.0-alpha.10", + "spameri/elastic-query": "^v1.0.0-alpha.13", "elasticsearch/elasticsearch": "^7.12.0", "nette/di": "^3.0.5", "nette/utils": "^3.2.5", diff --git a/phpstan-low.neon b/phpstan-low.neon index ab6a741..7969873 100644 --- a/phpstan-low.neon +++ b/phpstan-low.neon @@ -11,15 +11,6 @@ parameters: ignoreErrors: - '#PHPDoc tag \@throws with type Elasticsearch\\Common\\Exceptions\\ElasticsearchException is not subtype of Throwable#' - '#Call to function array_key_exists\(\) with string and array will always evaluate to false.#' - - - message: "#^Call to method addSetup\\(\\) on an unknown class Nette\\\\DI\\\\Definitions\\\\ServiceDefinition\\.$#" - count: 1 - path: src/DI/SpameriElasticSearchExtension.php - - - - message: "#^PHPDoc tag @var for variable \\$definition contains unknown class Nette\\\\DI\\\\Definitions\\\\ServiceDefinition\\.$#" - count: 1 - path: src/DI/SpameriElasticSearchExtension.php - message: "#^Method Spameri\\\\Elastic\\\\Diagnostics\\\\PanelLogger\\:\\:emergency\\(\\) should return null but return statement is missing\\.$#" diff --git a/phpstan.neon b/phpstan.neon index c6b2b64..ecfe68c 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -29,9 +29,9 @@ parameters: path: src/Model/TypeToNewIndex/Migrate.php - - message: "#^Static method Nette\\\\DI\\\\Compiler\\:\\:loadDefinitions\\(\\) invoked with 3 parameters, 0 required\\.$#" - count: 1 - path: src/DI/SpameriElasticSearchExtension.php + message: "#^Unable to resolve the template type T in call to method Nette\\\\DI\\\\Container\\:\\:getByType\\(\\)$#" + count: 2 + path: src/Model/ServiceLocator.php checkGenericClassInNonGenericObjectType: false diff --git a/src/Entity/Collection/AbstractElasticEntityCollection.php b/src/Entity/Collection/AbstractElasticEntityCollection.php index 94b3882..2f3f6d1 100644 --- a/src/Entity/Collection/AbstractElasticEntityCollection.php +++ b/src/Entity/Collection/AbstractElasticEntityCollection.php @@ -72,6 +72,7 @@ public function initialize(): void $entities = $this->service->getAllBy( new \Spameri\ElasticQuery\ElasticQuery( new \Spameri\ElasticQuery\Query\QueryCollection( + NULL, new \Spameri\ElasticQuery\Query\MustCollection( new \Spameri\ElasticQuery\Query\Terms( '_id',