Skip to content

Commit 399224d

Browse files
committed
Added support for Symfony^6.4
Removed support for PHP<8.1 Removed support for Symfony<5.4 Removed support for Monolog 1.*
1 parent a8a3268 commit 399224d

File tree

89 files changed

+1256
-1854
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+1256
-1854
lines changed

.github/workflows/phpunit-tests.yml

+29-18
Original file line numberDiff line numberDiff line change
@@ -48,39 +48,44 @@ jobs:
4848
- 'highest'
4949
php:
5050
- '8.1'
51-
- '8.2'
51+
- '8.3'
5252
elasticsearch:
53-
- '7.17.13'
53+
- '7.17.24'
54+
- '8.15.2'
5455
symfony:
55-
- '~5.0'
56+
- '~6.0'
5657
include:
57-
- php: '8.1'
58-
symfony: '~5.0'
58+
- php: '8.3'
59+
symfony: '~6.0'
5960
elasticsearch: '8.0.1'
6061
experimental: false
61-
- php: '8.1'
62-
symfony: '~5.0'
62+
- php: '8.3'
63+
symfony: '~6.0'
64+
elasticsearch: '8.0.1'
65+
experimental: false
66+
- php: '8.3'
67+
symfony: '~6.0'
6368
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
6469
experimental: false
65-
- php: '8.1'
66-
symfony: '~5.0'
70+
- php: '8.3'
71+
symfony: '~6.0'
6772
elasticsearch: '8.5.3' # there are some bc in minor version https://www.elastic.co/guide/en/elasticsearch/reference/current/migrating-8.5.html
6873
experimental: false
69-
- php: '8.1'
70-
symfony: '~5.0'
74+
- php: '8.3'
75+
symfony: '~6.0'
7176
elasticsearch: '8.6.2' # there are no bc in minor version https://www.elastic.co/guide/en/elasticsearch/reference/current/migrating-8.6.html
7277
experimental: false
73-
- php: '8.1'
74-
symfony: '~5.0'
78+
- php: '8.3'
79+
symfony: '~6.0'
7580
elasticsearch: '8.7.1' # there are no bc in minor version https://www.elastic.co/guide/en/elasticsearch/reference/current/migrating-8.7.html
7681
experimental: false
77-
- php: '8.1'
78-
symfony: '~5.0'
82+
- php: '8.3'
83+
symfony: '~6.0'
7984
elasticsearch: '8.8.0' # there are no bc in minor version https://www.elastic.co/guide/en/elasticsearch/reference/current/migrating-8.8.html
8085
experimental: false
8186
- php: '8.1'
82-
symfony: '~6.0'
83-
elasticsearch: '8.10.2' # newest version
87+
symfony: '~5.0'
88+
elasticsearch: '8.15.2' # newest version
8489
experimental: false
8590
fail-fast: false
8691
steps:
@@ -115,10 +120,16 @@ jobs:
115120

116121
- name: 'Run phpunit tests'
117122
run: |
118-
vendor/bin/simple-phpunit --coverage-clover=tests/App/build/clover.xml 2>/dev/null
123+
vendor/bin/simple-phpunit --coverage-clover=tests/App/build/clover.xml
119124
120125
- name: Upload coverage results to Coveralls
121126
env:
122127
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_TOKEN }}
123128
run: |
124129
vendor/bin/php-coveralls --coverage_clover=tests/App/build/clover.xml --json_path=tests/App/build/coveralls.json -v
130+
131+
# Enable tmate debugging on failure for 15 minutes
132+
- name: Setup tmate session
133+
if: ${{ !env.ACT && failure() }}
134+
uses: mxschmitt/action-tmate@v3
135+
timeout-minutes: 15

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,5 @@
88
.phpunit.result.cache
99
.idea
1010
/.php-cs-fixer.cache
11+
/.phpstan-cache
12+
/.rector-cache/

.php-cs-fixer.dist.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
// Indent '=>' operator
1818
'binary_operator_spaces' => ['operators' => ['=>' => 'align_single_space_minimal']],
1919
// PSR12 imports order
20-
'ordered_imports' => ['imports_order' => ['class', 'function', 'const']],
20+
'ordered_imports' => ['imports_order' => ['class', 'function', 'const']],
21+
'phpdoc_separation' => true,
2122
])
2223
;

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ Installation instructions and documentation of the bundle can be found [here](do
2121
## Version matrix
2222

2323
| ElasticsearchBundle | Elasticsearch | Symfony | PHP |
24-
| ------------------- | -------------- | ----------- | ----------- |
24+
|---------------------| -------------- |-------------|-------------|
25+
| ~7.2 | >= 7.0 | 5.0+ | 8.1+ |
2526
| ~7.0 | >= 7.0 | 4.4+ / 5.0+ | 7.3+ / 8.0+ |
2627
| ~6.2 | >= 6.2, < 7.0 | 3.4+ / 4.0+ | 7.3+ |
2728
| ~6.1.0 | >= 6.0, < 6.2 | | |

composer.json

+20-17
Original file line numberDiff line numberDiff line change
@@ -11,37 +11,40 @@
1111
}
1212
],
1313
"require": {
14-
"php": "^7.3 || ^8.0",
15-
"psr/log": "^1.0",
14+
"php": "^8.1",
15+
"psr/log": "^2.0 || ^3.0",
1616

17-
"symfony/framework-bundle": "^4.4 || ^5.0",
18-
"symfony/options-resolver": "^4.4 || ^5.0",
19-
"symfony/config": "^4.4 || ^5.0",
20-
"symfony/event-dispatcher": "^4.4 || ^5.0",
21-
"symfony/translation": "^4.4 || ^5.0",
22-
"symfony/console": "^4.4 || ^5.0",
23-
"symfony/http-kernel": "^4.4 || ^5.0",
24-
"symfony/event-dispatcher-contracts": "^1.1 || ^2.2",
17+
"symfony/framework-bundle": "^5.4 || ^6.4",
18+
"symfony/options-resolver": "^5.4 || ^6.4",
19+
"symfony/config": "^5.4 || ^6.4",
20+
"symfony/event-dispatcher": "^5.4 || ^6.4",
21+
"symfony/translation": "^5.4 || ^6.4",
22+
"symfony/console": "^5.4 || ^6.4",
23+
"symfony/http-kernel": "^5.4 || ^6.4",
24+
"symfony/event-dispatcher-contracts": "^3.5",
2525

2626
"doctrine/annotations": "^1.2",
2727
"doctrine/cache": "^1.4",
2828
"elasticsearch/elasticsearch": "^7.0"
2929
},
3030
"require-dev": {
31-
"symfony/debug": "^4.4 || ^5.0",
32-
"symfony/stopwatch": "^4.4 || ^5.0",
33-
"symfony/phpunit-bridge": "^4.4 || ^5.0",
34-
"symfony/browser-kit": "^4.4 || ^5.0",
35-
"symfony/dotenv": "^4.4 || ^5.0",
31+
"symfony/stopwatch": "^5.4 || ^6.4",
32+
"symfony/phpunit-bridge": "^5.4 || ^6.4",
33+
"symfony/browser-kit": "^5.4 || ^6.4",
34+
"symfony/dotenv": "^5.4 || ^6.4",
3635
"doctrine/orm": "^2.6.3",
3736

38-
"monolog/monolog": "^1.0|^2.0|^3.0",
37+
"monolog/monolog": "^2.0|^3.0",
3938
"knplabs/knp-paginator-bundle": "^4.0 || ^5.0",
4039
"friendsofphp/php-cs-fixer": "^3.34",
4140
"php-coveralls/php-coveralls": "^2.1",
4241
"escapestudios/symfony2-coding-standard": "^3.0",
4342
"jchook/phpunit-assert-throws": "^1.0",
44-
"dms/phpunit-arraysubset-asserts": "^0.2.1"
43+
"dms/phpunit-arraysubset-asserts": "^0.2.1",
44+
"phpstan/phpstan": "^1.12",
45+
"phpstan/phpstan-symfony": "^1.4",
46+
"phpstan/phpstan-phpunit": "^1.4",
47+
"rector/rector": "^1.2"
4548
},
4649
"suggest": {
4750
"monolog/monolog": "Allows for client-level logging and tracing",

docker-compose.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
services:
22
elasticsearch:
3-
image: "docker.elastic.co/elasticsearch/elasticsearch:${ELASTICSEARCH_VERSION:-7.17.13}"
3+
image: "docker.elastic.co/elasticsearch/elasticsearch:${ELASTICSEARCH_VERSION:-8.15.2}"
44
container_name: sfes_elasticsearch
55
environment:
66
- discovery.type=single-node

phpcs.xml

-10
This file was deleted.

phpstan.dist.neon

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
includes:
2+
- vendor/phpstan/phpstan-symfony/extension.neon
3+
- vendor/phpstan/phpstan-symfony/rules.neon
4+
# - vendor/phpstan/phpstan-phpunit/extension.neon
5+
# - vendor/phpstan/phpstan-phpunit/rules.neon
6+
7+
parameters:
8+
level: 5
9+
tmpDir: .phpstan-cache
10+
treatPhpDocTypesAsCertain: false
11+
12+
symfony:
13+
containerXmlPath: var/cache/test/Sineflow_ElasticsearchBundle_Tests_App_AppKernelTestDebugContainer.xml
14+
15+
paths:
16+
- config
17+
- src
18+
#- tests

rector.php

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Rector\Caching\ValueObject\Storage\FileCacheStorage;
6+
use Rector\Config\RectorConfig;
7+
use Rector\Doctrine\Set\DoctrineSetList;
8+
use Rector\Symfony\Set\SymfonySetList;
9+
10+
return RectorConfig::configure()
11+
->withCache(__DIR__.'/.rector-cache', FileCacheStorage::class)
12+
->withSymfonyContainerXml(__DIR__.'/var/cache/test/Sineflow_ElasticsearchBundle_Tests_App_AppKernelTestDebugContainer.xml')
13+
->withPHPStanConfigs([__DIR__.'/phpstan.dist.neon'])
14+
->withParallel()
15+
16+
->withImportNames(importShortClasses: false) // Allow global classes without use statements
17+
18+
->withPaths([
19+
__DIR__.'/config',
20+
__DIR__.'/src',
21+
__DIR__.'/tests',
22+
])
23+
24+
->withAttributesSets(symfony: true, doctrine: true)
25+
26+
->withSets([
27+
SymfonySetList::SYMFONY_CODE_QUALITY,
28+
DoctrineSetList::DOCTRINE_CODE_QUALITY,
29+
])
30+
31+
->withPhpSets()
32+
;

src/Annotation/Document.php

+5-14
Original file line numberDiff line numberDiff line change
@@ -13,28 +13,19 @@
1313
*/
1414
final class Document implements DumperInterface
1515
{
16-
/**
17-
* @var string
18-
*/
19-
public $repositoryClass;
20-
21-
/**
22-
* @var string
23-
*/
24-
public $providerClass;
16+
public ?string $repositoryClass = null;
17+
public ?string $providerClass = null;
2518

2619
/**
2720
* Settings directly passed to Elasticsearch client as-is
28-
*
29-
* @var array
3021
*/
31-
public $options;
22+
public array $options = [];
3223

3324
/**
3425
* {@inheritdoc}
3526
*/
36-
public function dump(array $settings = [])
27+
public function dump(array $settings = []): array
3728
{
38-
return (array) $this->options;
29+
return $this->options;
3930
}
4031
}

src/Annotation/Id.php

+13-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,18 @@
99
*
1010
* @Target("PROPERTY")
1111
*/
12-
final class Id
12+
final class Id implements PropertyAnnotationInterface
1313
{
14+
public const NAME = '_id';
15+
public const TYPE = 'keyword';
16+
17+
public function getName(): ?string
18+
{
19+
return self::NAME;
20+
}
21+
22+
public function getType(): ?string
23+
{
24+
return self::TYPE;
25+
}
1426
}

src/Annotation/Property.php

+22-29
Original file line numberDiff line numberDiff line change
@@ -5,74 +5,67 @@
55
use Sineflow\ElasticsearchBundle\Mapping\DumperInterface;
66

77
/**
8-
* Annotation used to check mapping type during the parsing process.
8+
* Annotation used for all properties of the document, apart from the special ones (like _id and _score)
99
*
1010
* @Annotation
1111
*
1212
* @Target("PROPERTY")
1313
*/
14-
final class Property implements DumperInterface
14+
final class Property implements PropertyAnnotationInterface, DumperInterface
1515
{
1616
public const LANGUAGE_PLACEHOLDER = '{lang}';
1717

1818
public const DEFAULT_LANG_SUFFIX = 'default';
1919

2020
/**
21-
* @var string
22-
*
2321
* @Required
2422
*/
25-
public $name;
23+
public string $name;
2624

2725
/**
28-
* @var string
29-
*
3026
* @Required
3127
*/
32-
public $type;
28+
public string $type;
3329

34-
/**
35-
* @var bool
36-
*/
37-
public $multilanguage;
30+
public bool $multilanguage = false;
3831

3932
/**
4033
* Override mapping for the 'default' language field of multilanguage properties
41-
*
42-
* @var array
4334
*/
44-
public $multilanguageDefaultOptions;
35+
public array $multilanguageDefaultOptions = [];
4536

4637
/**
4738
* The object name must be defined, if type is 'object' or 'nested'
48-
*
49-
* @var string Object name to map.
5039
*/
51-
public $objectName;
40+
public string $objectName;
5241

5342
/**
5443
* Defines if related object will have one or multiple values.
5544
* If this value is set to true, ObjectIterator will be provided in the result, as opposed to an ObjectInterface object
56-
*
57-
* @var bool
5845
*/
59-
public $multiple;
46+
public bool $multiple = false;
6047

6148
/**
6249
* Settings directly passed to Elasticsearch client as-is
63-
*
64-
* @var array
6550
*/
66-
public $options;
51+
public array $options = [];
52+
53+
public function getName(): ?string
54+
{
55+
return $this->name;
56+
}
57+
58+
public function getType(): ?string
59+
{
60+
return $this->type;
61+
}
6762

6863
/**
6964
* Dumps property fields as array for index mapping
70-
*
71-
* @return array
7265
*/
73-
public function dump(array $settings = [])
66+
public function dump(array $settings = []): array
7467
{
75-
$result = (array) $this->options;
68+
$result = $this->options;
7669

7770
// Although it is completely valid syntax to explicitly define objects as such in the mapping definition, ES does not do that by default.
7871
// 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
@@ -86,7 +79,7 @@ public function dump(array $settings = [])
8679
}
8780

8881
// Recursively replace {lang} in any string option with the respective language
89-
\array_walk_recursive($result, static function (&$value, $key, $settings) {
82+
\array_walk_recursive($result, static function (&$value, $key, $settings): void {
9083
if (\is_string($value) && \str_contains($value, self::LANGUAGE_PLACEHOLDER)) {
9184
if (\in_array($key, ['analyzer', 'index_analyzer', 'search_analyzer'])) {
9285
// Replace {lang} in any analyzers with the respective language

0 commit comments

Comments
 (0)