Skip to content

Commit

Permalink
Added support for Symfony^6.4
Browse files Browse the repository at this point in the history
Removed support for PHP<8.1
Removed support for Symfony<5.4
Removed support for Monolog 1.*
  • Loading branch information
pmishev committed Oct 17, 2024
1 parent a8a3268 commit 399224d
Show file tree
Hide file tree
Showing 89 changed files with 1,256 additions and 1,854 deletions.
47 changes: 29 additions & 18 deletions .github/workflows/phpunit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,39 +48,44 @@ jobs:
- 'highest'
php:
- '8.1'
- '8.2'
- '8.3'
elasticsearch:
- '7.17.13'
- '7.17.24'
- '8.15.2'
symfony:
- '~5.0'
- '~6.0'
include:
- php: '8.1'
symfony: '~5.0'
- php: '8.3'
symfony: '~6.0'
elasticsearch: '8.0.1'
experimental: false
- php: '8.1'
symfony: '~5.0'
- php: '8.3'
symfony: '~6.0'
elasticsearch: '8.0.1'
experimental: false
- php: '8.3'
symfony: '~6.0'
elasticsearch: '8.1.3' # there are some bc in minor version https://www.elastic.co/guide/en/elasticsearch/reference/current/migrating-8.1.html#breaking-changes-8.1
experimental: false
- php: '8.1'
symfony: '~5.0'
- php: '8.3'
symfony: '~6.0'
elasticsearch: '8.5.3' # there are some bc in minor version https://www.elastic.co/guide/en/elasticsearch/reference/current/migrating-8.5.html
experimental: false
- php: '8.1'
symfony: '~5.0'
- php: '8.3'
symfony: '~6.0'
elasticsearch: '8.6.2' # there are no bc in minor version https://www.elastic.co/guide/en/elasticsearch/reference/current/migrating-8.6.html
experimental: false
- php: '8.1'
symfony: '~5.0'
- php: '8.3'
symfony: '~6.0'
elasticsearch: '8.7.1' # there are no bc in minor version https://www.elastic.co/guide/en/elasticsearch/reference/current/migrating-8.7.html
experimental: false
- php: '8.1'
symfony: '~5.0'
- php: '8.3'
symfony: '~6.0'
elasticsearch: '8.8.0' # there are no bc in minor version https://www.elastic.co/guide/en/elasticsearch/reference/current/migrating-8.8.html
experimental: false
- php: '8.1'
symfony: '~6.0'
elasticsearch: '8.10.2' # newest version
symfony: '~5.0'
elasticsearch: '8.15.2' # newest version
experimental: false
fail-fast: false
steps:
Expand Down Expand Up @@ -115,10 +120,16 @@ jobs:

- name: 'Run phpunit tests'
run: |
vendor/bin/simple-phpunit --coverage-clover=tests/App/build/clover.xml 2>/dev/null
vendor/bin/simple-phpunit --coverage-clover=tests/App/build/clover.xml
- name: Upload coverage results to Coveralls
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_TOKEN }}
run: |
vendor/bin/php-coveralls --coverage_clover=tests/App/build/clover.xml --json_path=tests/App/build/coveralls.json -v
# Enable tmate debugging on failure for 15 minutes
- name: Setup tmate session
if: ${{ !env.ACT && failure() }}
uses: mxschmitt/action-tmate@v3
timeout-minutes: 15
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@
.phpunit.result.cache
.idea
/.php-cs-fixer.cache
/.phpstan-cache
/.rector-cache/
3 changes: 2 additions & 1 deletion .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
// Indent '=>' operator
'binary_operator_spaces' => ['operators' => ['=>' => 'align_single_space_minimal']],
// PSR12 imports order
'ordered_imports' => ['imports_order' => ['class', 'function', 'const']],
'ordered_imports' => ['imports_order' => ['class', 'function', 'const']],
'phpdoc_separation' => true,
])
;
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ Installation instructions and documentation of the bundle can be found [here](do
## Version matrix

| ElasticsearchBundle | Elasticsearch | Symfony | PHP |
| ------------------- | -------------- | ----------- | ----------- |
|---------------------| -------------- |-------------|-------------|
| ~7.2 | >= 7.0 | 5.0+ | 8.1+ |
| ~7.0 | >= 7.0 | 4.4+ / 5.0+ | 7.3+ / 8.0+ |
| ~6.2 | >= 6.2, < 7.0 | 3.4+ / 4.0+ | 7.3+ |
| ~6.1.0 | >= 6.0, < 6.2 | | |
Expand Down
37 changes: 20 additions & 17 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,37 +11,40 @@
}
],
"require": {
"php": "^7.3 || ^8.0",
"psr/log": "^1.0",
"php": "^8.1",
"psr/log": "^2.0 || ^3.0",

"symfony/framework-bundle": "^4.4 || ^5.0",
"symfony/options-resolver": "^4.4 || ^5.0",
"symfony/config": "^4.4 || ^5.0",
"symfony/event-dispatcher": "^4.4 || ^5.0",
"symfony/translation": "^4.4 || ^5.0",
"symfony/console": "^4.4 || ^5.0",
"symfony/http-kernel": "^4.4 || ^5.0",
"symfony/event-dispatcher-contracts": "^1.1 || ^2.2",
"symfony/framework-bundle": "^5.4 || ^6.4",
"symfony/options-resolver": "^5.4 || ^6.4",
"symfony/config": "^5.4 || ^6.4",
"symfony/event-dispatcher": "^5.4 || ^6.4",
"symfony/translation": "^5.4 || ^6.4",
"symfony/console": "^5.4 || ^6.4",
"symfony/http-kernel": "^5.4 || ^6.4",
"symfony/event-dispatcher-contracts": "^3.5",

"doctrine/annotations": "^1.2",
"doctrine/cache": "^1.4",
"elasticsearch/elasticsearch": "^7.0"
},
"require-dev": {
"symfony/debug": "^4.4 || ^5.0",
"symfony/stopwatch": "^4.4 || ^5.0",
"symfony/phpunit-bridge": "^4.4 || ^5.0",
"symfony/browser-kit": "^4.4 || ^5.0",
"symfony/dotenv": "^4.4 || ^5.0",
"symfony/stopwatch": "^5.4 || ^6.4",
"symfony/phpunit-bridge": "^5.4 || ^6.4",
"symfony/browser-kit": "^5.4 || ^6.4",
"symfony/dotenv": "^5.4 || ^6.4",
"doctrine/orm": "^2.6.3",

"monolog/monolog": "^1.0|^2.0|^3.0",
"monolog/monolog": "^2.0|^3.0",
"knplabs/knp-paginator-bundle": "^4.0 || ^5.0",
"friendsofphp/php-cs-fixer": "^3.34",
"php-coveralls/php-coveralls": "^2.1",
"escapestudios/symfony2-coding-standard": "^3.0",
"jchook/phpunit-assert-throws": "^1.0",
"dms/phpunit-arraysubset-asserts": "^0.2.1"
"dms/phpunit-arraysubset-asserts": "^0.2.1",
"phpstan/phpstan": "^1.12",
"phpstan/phpstan-symfony": "^1.4",
"phpstan/phpstan-phpunit": "^1.4",
"rector/rector": "^1.2"
},
"suggest": {
"monolog/monolog": "Allows for client-level logging and tracing",
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
services:
elasticsearch:
image: "docker.elastic.co/elasticsearch/elasticsearch:${ELASTICSEARCH_VERSION:-7.17.13}"
image: "docker.elastic.co/elasticsearch/elasticsearch:${ELASTICSEARCH_VERSION:-8.15.2}"
container_name: sfes_elasticsearch
environment:
- discovery.type=single-node
Expand Down
10 changes: 0 additions & 10 deletions phpcs.xml

This file was deleted.

18 changes: 18 additions & 0 deletions phpstan.dist.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
includes:
- vendor/phpstan/phpstan-symfony/extension.neon
- vendor/phpstan/phpstan-symfony/rules.neon
# - vendor/phpstan/phpstan-phpunit/extension.neon
# - vendor/phpstan/phpstan-phpunit/rules.neon

parameters:
level: 5
tmpDir: .phpstan-cache
treatPhpDocTypesAsCertain: false

symfony:
containerXmlPath: var/cache/test/Sineflow_ElasticsearchBundle_Tests_App_AppKernelTestDebugContainer.xml

paths:
- config
- src
#- tests
32 changes: 32 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

declare(strict_types=1);

use Rector\Caching\ValueObject\Storage\FileCacheStorage;
use Rector\Config\RectorConfig;
use Rector\Doctrine\Set\DoctrineSetList;
use Rector\Symfony\Set\SymfonySetList;

return RectorConfig::configure()
->withCache(__DIR__.'/.rector-cache', FileCacheStorage::class)
->withSymfonyContainerXml(__DIR__.'/var/cache/test/Sineflow_ElasticsearchBundle_Tests_App_AppKernelTestDebugContainer.xml')
->withPHPStanConfigs([__DIR__.'/phpstan.dist.neon'])
->withParallel()

->withImportNames(importShortClasses: false) // Allow global classes without use statements

->withPaths([
__DIR__.'/config',
__DIR__.'/src',
__DIR__.'/tests',
])

->withAttributesSets(symfony: true, doctrine: true)

->withSets([
SymfonySetList::SYMFONY_CODE_QUALITY,
DoctrineSetList::DOCTRINE_CODE_QUALITY,
])

->withPhpSets()
;
19 changes: 5 additions & 14 deletions src/Annotation/Document.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,19 @@
*/
final class Document implements DumperInterface
{
/**
* @var string
*/
public $repositoryClass;

/**
* @var string
*/
public $providerClass;
public ?string $repositoryClass = null;
public ?string $providerClass = null;

/**
* Settings directly passed to Elasticsearch client as-is
*
* @var array
*/
public $options;
public array $options = [];

/**
* {@inheritdoc}
*/
public function dump(array $settings = [])
public function dump(array $settings = []): array
{
return (array) $this->options;
return $this->options;
}
}
14 changes: 13 additions & 1 deletion src/Annotation/Id.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,18 @@
*
* @Target("PROPERTY")
*/
final class Id
final class Id implements PropertyAnnotationInterface
{
public const NAME = '_id';
public const TYPE = 'keyword';

public function getName(): ?string
{
return self::NAME;
}

public function getType(): ?string
{
return self::TYPE;
}
}
51 changes: 22 additions & 29 deletions src/Annotation/Property.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,74 +5,67 @@
use Sineflow\ElasticsearchBundle\Mapping\DumperInterface;

/**
* Annotation used to check mapping type during the parsing process.
* Annotation used for all properties of the document, apart from the special ones (like _id and _score)
*
* @Annotation
*
* @Target("PROPERTY")
*/
final class Property implements DumperInterface
final class Property implements PropertyAnnotationInterface, DumperInterface
{
public const LANGUAGE_PLACEHOLDER = '{lang}';

public const DEFAULT_LANG_SUFFIX = 'default';

/**
* @var string
*
* @Required
*/
public $name;
public string $name;

/**
* @var string
*
* @Required
*/
public $type;
public string $type;

/**
* @var bool
*/
public $multilanguage;
public bool $multilanguage = false;

/**
* Override mapping for the 'default' language field of multilanguage properties
*
* @var array
*/
public $multilanguageDefaultOptions;
public array $multilanguageDefaultOptions = [];

/**
* The object name must be defined, if type is 'object' or 'nested'
*
* @var string Object name to map.
*/
public $objectName;
public string $objectName;

/**
* Defines if related object will have one or multiple values.
* If this value is set to true, ObjectIterator will be provided in the result, as opposed to an ObjectInterface object
*
* @var bool
*/
public $multiple;
public bool $multiple = false;

/**
* Settings directly passed to Elasticsearch client as-is
*
* @var array
*/
public $options;
public array $options = [];

public function getName(): ?string
{
return $this->name;
}

public function getType(): ?string
{
return $this->type;
}

/**
* Dumps property fields as array for index mapping
*
* @return array
*/
public function dump(array $settings = [])
public function dump(array $settings = []): array
{
$result = (array) $this->options;
$result = $this->options;

// Although it is completely valid syntax to explicitly define objects as such in the mapping definition, ES does not do that by default.
// So, in order to ensure that the mapping for index creation would exactly match the mapping returned from the ES _mapping endpoint, we don't explicitly set 'object' data types
Expand All @@ -86,7 +79,7 @@ public function dump(array $settings = [])
}

// Recursively replace {lang} in any string option with the respective language
\array_walk_recursive($result, static function (&$value, $key, $settings) {
\array_walk_recursive($result, static function (&$value, $key, $settings): void {
if (\is_string($value) && \str_contains($value, self::LANGUAGE_PLACEHOLDER)) {
if (\in_array($key, ['analyzer', 'index_analyzer', 'search_analyzer'])) {
// Replace {lang} in any analyzers with the respective language
Expand Down
Loading

0 comments on commit 399224d

Please sign in to comment.