Skip to content

Commit

Permalink
Merge pull request #1 from llupa/only-php-bump
Browse files Browse the repository at this point in the history
Bump PHP
  • Loading branch information
llupa committed Dec 2, 2022
2 parents 9e8903a + de730b0 commit e4b7358
Show file tree
Hide file tree
Showing 56 changed files with 530 additions and 548 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/continous-integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: 'Continuous integration'
on: ['push', 'pull_request']
jobs:
phpunit:
runs-on: 'ubuntu-20.04'
name: 'PHPUnit (PHP ${{ matrix.php }}, ES ${{ matrix.elasticsearch }})'
timeout-minutes: 10
env:
SYMFONY_REQUIRE: "${{ matrix.symfony_require }}"
strategy:
matrix:
include:
- php: '8.1'
elasticsearch: '6.8.23'
dependencies: 'highest'
symfony_require: '4.4.*'
fail-fast: false
steps:
- name: 'Checkout'
uses: 'actions/checkout@v2'

- name: 'Setup PHP'
uses: 'shivammathur/setup-php@v2'
with:
php-version: '${{ matrix.php }}'
coverage: 'none'
tools: 'pecl, composer:v2, flex'
extensions: 'curl, json, mbstring, mongodb, openssl'

- name: "Install Composer dependencies (${{ matrix.dependencies }})"
uses: "ramsey/composer-install@v1"
with:
dependency-versions: "${{ matrix.dependencies }}"
composer-options: "--prefer-dist --prefer-stable"

- name: 'Setup Elasticsearch'
run: |
sudo swapoff -a
sudo sysctl -w vm.swappiness=1
sudo sysctl -w fs.file-max=262144
sudo sysctl -w vm.max_map_count=262144
docker network create elastic
docker run -d --name=elasticsearch --network=elastic -p 9200:9200 -e discovery.type=single-node -e node.name=es docker.elastic.co/elasticsearch/elasticsearch:${{ matrix.elasticsearch }} sh -c "./bin/elasticsearch-plugin install --batch ingest-attachment && /usr/local/bin/docker-entrypoint.sh"
docker run --rm --network=elastic curlimages/curl --max-time 120 --retry-max-time 120 --retry 120 --retry-delay 5 --retry-all-errors --show-error --silent http://elasticsearch:9200
- name: 'Run unit tests'
run: |
vendor/bin/phpunit
60 changes: 0 additions & 60 deletions .travis.yml

This file was deleted.

1 change: 0 additions & 1 deletion .travis/php.ini

This file was deleted.

33 changes: 0 additions & 33 deletions .travis/wait-for-elasticsearch.sh

This file was deleted.

37 changes: 21 additions & 16 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,36 @@
{ "name": "Jeremy Mikola", "email": "[email protected]" }
],
"require": {
"php": "^7.1",
"symfony/framework-bundle": "^3.4|^4.3|^5",
"symfony/console": "^3.4|^4.3|^5",
"symfony/dependency-injection": "^3.4|^4.3|^5",
"symfony/property-access": "^3.4|^4.3|^5",
"pagerfanta/pagerfanta": "^1.0.5|^2.0",
"php": "^8.0",
"symfony/framework-bundle": "^4.4",
"symfony/console": "^4.4",
"symfony/dependency-injection": "^4.4",
"symfony/property-access": "^4.4",
"pagerfanta/pagerfanta": "^3.6",
"psr/log": "^1.0",
"ruflin/elastica": "^5.3.5|^6.1.1"
"ruflin/elastica": "^6.2"
},
"require-dev": {
"doctrine/orm": "^2.5",
"doctrine/doctrine-bundle": "^1.6|^2",
"doctrine/persistence": "^1.3.4",
"doctrine/orm": "^2.8",
"doctrine/doctrine-bundle": "^2.1.1",
"doctrine/persistence": "^2.0",
"doctrine/phpcr-bundle": "^1.3|^2.0",
"doctrine/phpcr-odm": "^1.4",
"jackalope/jackalope-doctrine-dbal": "^1.2",
"jms/serializer-bundle": "^2.4|^3.5",
"phpunit/phpunit": "^6.5.14",
"jms/serializer-bundle": "^3.5",
"phpunit/phpunit": "^9.5",
"knplabs/knp-components": "^1.2|^2.3",
"symfony/expression-language" : "^3.4|^4.3|^5",
"symfony/twig-bundle": "^3.4|^4.3|^5",
"symfony/serializer": "^3.4|^4.3|^5",
"symfony/yaml": "^3.4|^4.3|^5",
"symfony/twig-bundle": "^4.4",
"symfony/serializer": "^4.4",
"symfony/yaml": "^4.4",
"friendsofphp/php-cs-fixer": "^2.2",
"symfony/web-profiler-bundle": "^3.4|^4.3|^5"
"symfony/web-profiler-bundle": "^4.4",
"doctrine/mongodb-odm-bundle": "^4.5",
"phpspec/prophecy-phpunit": "^2.0",
"pagerfanta/doctrine-mongodb-odm-adapter": "^3.6",
"pagerfanta/doctrine-orm-adapter": "^3.6",
"pagerfanta/doctrine-phpcr-odm-adapter": "^3.6"
},
"suggest": {
"enqueue/elastica-bundle": "The bundle adds extra features to FOSElasticaBundle bundle. Aimed to improve performance."
Expand Down
11 changes: 6 additions & 5 deletions src/Doctrine/AbstractElasticaToModelTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,14 @@ public function transform(array $elasticaObjects)
$objects,
function ($a, $b) use ($idPos, $identifier, $propertyAccessor) {
if ($this->options['hydrate']) {
return $idPos[(string) $propertyAccessor->getValue(
$a,
$identifier
)] > $idPos[(string) $propertyAccessor->getValue($b, $identifier)];
return (
$idPos[(string) $propertyAccessor->getValue($a, $identifier)]
>
$idPos[(string) $propertyAccessor->getValue($b, $identifier)]
) ? 1 : -1;
}

return $idPos[$a[$identifier]] > $idPos[$b[$identifier]];
return ($idPos[$a[$identifier]] > $idPos[$b[$identifier]]) ? 1 : -1;
}
);

Expand Down
14 changes: 6 additions & 8 deletions src/Doctrine/MongoDBPagerProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/*
* This file is part of the FOSElasticaBundle package.
*
* (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
* (c) FriendsOfSymfony <https://friendsofsymfony.github.com/>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand All @@ -13,8 +13,9 @@

use Doctrine\Persistence\ManagerRegistry;
use FOS\ElasticaBundle\Provider\PagerfantaPager;
use FOS\ElasticaBundle\Provider\PagerInterface;
use FOS\ElasticaBundle\Provider\PagerProviderInterface;
use Pagerfanta\Adapter\DoctrineODMMongoDBAdapter;
use Pagerfanta\Doctrine\MongoDBODM\QueryAdapter;
use Pagerfanta\Pagerfanta;

final class MongoDBPagerProvider implements PagerProviderInterface
Expand All @@ -40,10 +41,7 @@ final class MongoDBPagerProvider implements PagerProviderInterface
private $registerListenersService;

/**
* @param ManagerRegistry $doctrine
* @param RegisterListenersService $registerListenersService
* @param string $objectClass
* @param array $baseOptions
*/
public function __construct(ManagerRegistry $doctrine, RegisterListenersService $registerListenersService, $objectClass, array $baseOptions)
{
Expand All @@ -56,15 +54,15 @@ public function __construct(ManagerRegistry $doctrine, RegisterListenersService
/**
* {@inheritdoc}
*/
public function provide(array $options = array())
public function provide(array $options = []): PagerInterface
{
$options = array_replace($this->baseOptions, $options);
$options = \array_replace($this->baseOptions, $options);

$manager = $this->doctrine->getManagerForClass($this->objectClass);
$repository = $manager->getRepository($this->objectClass);

$pager = new PagerfantaPager(new Pagerfanta(
new DoctrineODMMongoDBAdapter(call_user_func([$repository, $options['query_builder_method']]))
new QueryAdapter(\call_user_func([$repository, $options['query_builder_method']]))
));

$this->registerListenersService->register($manager, $pager, $options);
Expand Down
16 changes: 7 additions & 9 deletions src/Doctrine/ORMPagerProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/*
* This file is part of the FOSElasticaBundle package.
*
* (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
* (c) FriendsOfSymfony <https://friendsofsymfony.github.com/>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand All @@ -15,13 +15,14 @@
use Doctrine\ORM\QueryBuilder;
use Doctrine\Persistence\ManagerRegistry;
use FOS\ElasticaBundle\Provider\PagerfantaPager;
use FOS\ElasticaBundle\Provider\PagerInterface;
use FOS\ElasticaBundle\Provider\PagerProviderInterface;
use Pagerfanta\Adapter\DoctrineORMAdapter;
use Pagerfanta\Doctrine\ORM\QueryAdapter;
use Pagerfanta\Pagerfanta;

final class ORMPagerProvider implements PagerProviderInterface
{
const ENTITY_ALIAS = 'a';
public const ENTITY_ALIAS = 'a';

/**
* @var string
Expand All @@ -44,10 +45,7 @@ final class ORMPagerProvider implements PagerProviderInterface
private $registerListenersService;

/**
* @param ManagerRegistry $doctrine
* @param RegisterListenersService $registerListenersService
* @param string $objectClass
* @param array $baseOptions
*/
public function __construct(ManagerRegistry $doctrine, RegisterListenersService $registerListenersService, $objectClass, array $baseOptions)
{
Expand All @@ -60,9 +58,9 @@ public function __construct(ManagerRegistry $doctrine, RegisterListenersService
/**
* {@inheritdoc}
*/
public function provide(array $options = array())
public function provide(array $options = []): PagerInterface
{
$options = array_replace($this->baseOptions, $options);
$options = \array_replace($this->baseOptions, $options);

$manager = $this->doctrine->getManagerForClass($this->objectClass);
$repository = $manager->getRepository($this->objectClass);
Expand Down Expand Up @@ -92,7 +90,7 @@ public function provide(array $options = array())
}
}

$pager = new PagerfantaPager(new Pagerfanta(new DoctrineORMAdapter($qb)));
$pager = new PagerfantaPager(new Pagerfanta(new QueryAdapter($qb)));

$this->registerListenersService->register($manager, $pager, $options);

Expand Down
25 changes: 15 additions & 10 deletions src/Doctrine/PHPCRPagerProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,25 @@
/*
* This file is part of the FOSElasticaBundle package.
*
* (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
* (c) FriendsOfSymfony <https://friendsofsymfony.github.com/>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace FOS\ElasticaBundle\Doctrine;

use Doctrine\ODM\PHPCR\Translation\LocaleChooser\LocaleChooser;
use Doctrine\Persistence\ManagerRegistry;
use FOS\ElasticaBundle\Provider\PagerfantaPager;
use FOS\ElasticaBundle\Provider\PagerInterface;
use FOS\ElasticaBundle\Provider\PagerProviderInterface;
use Pagerfanta\Adapter\DoctrineODMPhpcrAdapter;
use Pagerfanta\Doctrine\PHPCRODM\QueryAdapter;
use Pagerfanta\Pagerfanta;

final class PHPCRPagerProvider implements PagerProviderInterface
{
const ENTITY_ALIAS = 'a';
public const ENTITY_ALIAS = 'a';

/**
* @var string
Expand All @@ -42,10 +44,7 @@ final class PHPCRPagerProvider implements PagerProviderInterface
private $registerListenersService;

/**
* @param ManagerRegistry $doctrine
* @param RegisterListenersService $registerListenersService
* @param string $objectClass
* @param array $baseOptions
*/
public function __construct(ManagerRegistry $doctrine, RegisterListenersService $registerListenersService, $objectClass, array $baseOptions)
{
Expand All @@ -58,15 +57,21 @@ public function __construct(ManagerRegistry $doctrine, RegisterListenersService
/**
* {@inheritdoc}
*/
public function provide(array $options = array())
public function provide(array $options = []): PagerInterface
{
$options = array_replace($this->baseOptions, $options);
$options = \array_replace($this->baseOptions, $options);

$manager = $this->doctrine->getManagerForClass($this->objectClass);
if (isset($options['locale'])) {
/** @var LocaleChooser $localeChooser */
$localeChooser = $manager->getLocaleChooserStrategy();
$localeChooser->setLocale($options['locale']);
$manager->setLocaleChooserStrategy($localeChooser);
}
$repository = $manager->getRepository($this->objectClass);

$adapter = new DoctrineODMPhpcrAdapter(
call_user_func([$repository, $options['query_builder_method']], static::ENTITY_ALIAS)
$adapter = new QueryAdapter(
\call_user_func([$repository, $options['query_builder_method']], static::ENTITY_ALIAS)
);

$pager = new PagerfantaPager(new Pagerfanta($adapter));
Expand Down
Loading

0 comments on commit e4b7358

Please sign in to comment.