diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ed45f83..c403feb 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 ] @@ -51,7 +51,6 @@ jobs: name: PHPStan standard run: make phpstan - - if: matrix.php == '7.4' - name: Tests + - name: Tests run: make tests diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index f0b108f..0000000 --- a/.travis.yml +++ /dev/null @@ -1,44 +0,0 @@ -language: php - -cache: - directories: - - $HOME/.composer/cache - - $HOME/phpcs-cache - -php: - - 7.4 - -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 - -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' diff --git a/composer.json b/composer.json index 05bd80f..b66d82b 100644 --- a/composer.json +++ b/composer.json @@ -27,15 +27,14 @@ "php": ">=7.4", "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": "^2.7.1 || ^2.8.0", - "symfony/console": "^4", + "spameri/elastic-query": "^v1.0.0-alpha.13", + "elasticsearch/elasticsearch": "^7.12.0", + "nette/di": "^3.0.5", + "nette/utils": "^3.2.5", + "symfony/console": "^4.4.26", "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", @@ -43,9 +42,10 @@ "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", - "mockery/mockery": "^1.2" + "nette/bootstrap": "^3.0", + "nette/http": "^3.0.7", + "kdyby/console": "^4.0.0", + "mockery/mockery": "^1.5" }, "autoload": { "psr-4": { @@ -56,5 +56,10 @@ "psr-4": { "SpameriTests\\": "tests/SpameriTests" } + }, + "config": { + "allow-plugins": { + "dealerdirect/phpcodesniffer-composer-installer": true + } } } 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/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; - } - } 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', diff --git a/src/Entity/DateTimeInterface.php b/src/Entity/DateTimeInterface.php index 58ed1f9..9aea848 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..a4df11a 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)) { 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