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 15, 2024
1 parent a8a3268 commit b78458c
Show file tree
Hide file tree
Showing 57 changed files with 909 additions and 1,417 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
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
31 changes: 15 additions & 16 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,30 @@
}
],
"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",
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
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;
}
}
33 changes: 8 additions & 25 deletions src/Annotation/Property.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,59 +18,42 @@ final class Property implements DumperInterface
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 = [];

/**
* 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;

Expand Down
29 changes: 4 additions & 25 deletions src/CacheWarmer/MetadataCacheWarmer.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,44 +4,23 @@

use Sineflow\ElasticsearchBundle\Mapping\DocumentMetadataCollector;
use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface;
use Symfony\Component\HttpKernel\CacheWarmer\WarmableInterface;

/**
* Class MetadataCacheWarmer
*/
class MetadataCacheWarmer implements CacheWarmerInterface
{
/**
* @var DocumentMetadataCollector
*/
private $metadataCollector;
private DocumentMetadataCollector $metadataCollector;

public function __construct(DocumentMetadataCollector $metadataCollector)
{
$this->metadataCollector = $metadataCollector;
}

/**
* @return bool
*/
public function isOptional()
public function isOptional(): bool
{
return true;
}

/**
* @param string $cacheDir
*
* @return array
*
* @throws \Psr\Cache\InvalidArgumentException
*/
public function warmUp($cacheDir)
public function warmUp(string $cacheDir): array
{
if ($this->metadataCollector instanceof WarmableInterface) {
return (array) $this->metadataCollector->warmUp($cacheDir);
}

throw new \LogicException(\sprintf('The metadata collector "%s" cannot be warmed up because it does not implement "%s".', \get_debug_type($this->metadataCollector), WarmableInterface::class));
return $this->metadataCollector->warmUp($cacheDir);
}
}
9 changes: 3 additions & 6 deletions src/Command/IndexBuildCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@ class IndexBuildCommand extends Command
{
protected static $defaultName = 'sineflow:es:index:build';

/**
* @var IndexManagerRegistry
*/
private $indexManagerRegistry;
private IndexManagerRegistry $indexManagerRegistry;

public function __construct(IndexManagerRegistry $indexManagerRegistry)
{
Expand All @@ -31,7 +28,7 @@ public function __construct(IndexManagerRegistry $indexManagerRegistry)
/**
* {@inheritdoc}
*/
protected function configure()
protected function configure(): void
{
parent::configure();

Expand Down Expand Up @@ -59,7 +56,7 @@ protected function configure()
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
$indexManagerName = $input->getArgument('index');
$indexManager = $this->indexManagerRegistry->get($indexManagerName);
Expand Down
9 changes: 3 additions & 6 deletions src/Command/IndexCreateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ class IndexCreateCommand extends Command
{
protected static $defaultName = 'sineflow:es:index:create';

/**
* @var IndexManagerRegistry
*/
private $indexManagerRegistry;
private IndexManagerRegistry $indexManagerRegistry;

public function __construct(IndexManagerRegistry $indexManagerRegistry)
{
Expand All @@ -30,7 +27,7 @@ public function __construct(IndexManagerRegistry $indexManagerRegistry)
/**
* {@inheritdoc}
*/
protected function configure()
protected function configure(): void
{
parent::configure();

Expand All @@ -46,7 +43,7 @@ protected function configure()
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
$indexManagerName = $input->getArgument('index');
$indexManager = $this->indexManagerRegistry->get($indexManagerName);
Expand Down
Loading

0 comments on commit b78458c

Please sign in to comment.