Skip to content
This repository has been archived by the owner on Aug 1, 2024. It is now read-only.

Commit

Permalink
Update ci.yml with Symfony 6.2, 6.3 (#368)
Browse files Browse the repository at this point in the history
* Update ci.yml
  • Loading branch information
gilles-g authored May 19, 2023
1 parent 6638296 commit 6ea14ef
Show file tree
Hide file tree
Showing 71 changed files with 803 additions and 1,064 deletions.
24 changes: 13 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
env:
fail-fast: true
PHPUNIT_FLAGS: "-v"
SYMFONY_DEPRECATIONS_HELPER: 40
SYMFONY_DEPRECATIONS_HELPER: weak

jobs:
build:
Expand All @@ -17,11 +17,13 @@ jobs:
fail-fast: false
matrix:
include:
- { php: 7.3, mongodb: 3.6, symfony: "4.4.*", composer-flags: '--prefer-stable'}
- { php: 7.4, mongodb: 3.6, symfony: "5.4.*", composer-flags: '--prefer-stable'}
- { php: 8.0, mongodb: 3.6, symfony: "5.4.*", composer-flags: '--prefer-stable'}
- { php: 8.0, mongodb: 3.6, symfony: "6.0.*", composer-flags: '--prefer-stable'}
- { php: 8.1, mongodb: 3.6, symfony: "6.1.*@dev", composer-flags: '' }
- { php: 8.2, mongodb: 3.6, symfony: "5.4.*", composer-flags: '--prefer-stable'}
- { php: 8.2, mongodb: 3.6, symfony: "6.0.*", composer-flags: '--prefer-stable'}
- { php: 8.2, mongodb: 3.6, symfony: "6.1.*", composer-flags: '--prefer-stable' }
- { php: 8.2, mongodb: 3.6, symfony: "6.2.*", composer-flags: '--prefer-stable' }
- { php: 8.2, mongodb: 3.6, symfony: "6.3.*@dev", composer-flags: '' }

services:
mongo:
image: mongo:${{ matrix.mongodb }}
Expand All @@ -38,25 +40,25 @@ jobs:
ini-values: date.timezone="Europe/Paris"
coverage: xdebug
tools: "composer:v2,flex"

- name: Show PHP version
run: php -v && composer -V

- name: Download Composer cache dependencies from cache
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: "Require symfony/messenger"
run: "composer require --dev symfony/doctrine-messenger --no-update"
if: "${{ startsWith(matrix.symfony, '5.3') || startsWith(matrix.symfony, '5.4') }}"

- name: Cache Composer dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ matrix.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ matrix.os }}-composer-

- name: Install dependencies
run: |
perl -pi -e 's/^}$/,"minimum-stability":"dev"}/' composer.json
Expand All @@ -65,6 +67,6 @@ jobs:
composer update ${{ matrix.composer-flags }} --prefer-dist
env:
SYMFONY_REQUIRE: "${{ matrix.symfony }}"

- name: "Run PHPUnit Tests"
run: "composer test"
6 changes: 3 additions & 3 deletions DependencyInjection/Compiler/FormDataExtractorPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace Lexik\Bundle\FormFilterBundle\DependencyInjection\Compiler;

use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;

/**
* Add extraction methods to the data extraction service.
Expand All @@ -16,13 +16,13 @@ class FormDataExtractorPass implements CompilerPassInterface
/**
* {@inheritdoc}
*/
public function process(ContainerBuilder $container)
public function process(ContainerBuilder $container): void
{
if ($container->hasDefinition('lexik_form_filter.form_data_extractor')) {
$definition = $container->getDefinition('lexik_form_filter.form_data_extractor');

foreach ($container->findTaggedServiceIds('lexik_form_filter.data_extraction_method') as $id => $attributes) {
$definition->addMethodCall('addMethod', array(new Reference($id)));
$definition->addMethodCall('addMethod', [new Reference($id)]);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function getConfigTreeBuilder(): TreeBuilder
->defaultValue('and')
->info('Defined the doctrine query builder method the bundle will use to add the entire filter condition.')
->validate()
->ifNotInArray(array(null, 'and', 'or'))
->ifNotInArray([null, 'and', 'or'])
->thenInvalid('Invalid value, please use "null", "and", "or".')
->end()
->end()
Expand All @@ -44,7 +44,7 @@ public function getConfigTreeBuilder(): TreeBuilder
->defaultValue('text.starts')
->info('Default condition pattern for TextFilterType')
->validate()
->ifNotInArray(array(null, 'text.equals', 'text.ends', 'text.contains', 'text.starts'))
->ifNotInArray([null, 'text.equals', 'text.ends', 'text.contains', 'text.starts'])
->thenInvalid('Invalid value, please use "null", "text.contains", "text.starts", "text.ends", "text.equals".')
->end()
->end()
Expand Down
17 changes: 9 additions & 8 deletions DependencyInjection/LexikFormFilterExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@

namespace Lexik\Bundle\FormFilterBundle\DependencyInjection;

use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\Loader;
use Lexik\Bundle\FormFilterBundle\DependencyInjection\Configuration;
use Lexik\Bundle\FormFilterBundle\Filter\FilterOperands;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;

/**
* This is the class that loads and manages your bundle configuration
Expand All @@ -21,12 +22,12 @@ class LexikFormFilterExtension extends Extension
/**
* {@inheritDoc}
*/
public function load(array $configs, ContainerBuilder $container)
public function load(array $configs, ContainerBuilder $container): void
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);

$loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader->load('services.xml');
$loader->load('form.xml');

Expand All @@ -40,15 +41,15 @@ public function load(array $configs, ContainerBuilder $container)
$filterPrepareDef = $container->getDefinition('lexik_form_filter.filter_prepare');
$filterPrepareDef->addMethodCall(
'setForceCaseInsensitivity',
array($config['force_case_insensitivity'])
[$config['force_case_insensitivity']]
);
}

if (isset($config['encoding'])) {
$filterPrepareDef = $container->getDefinition('lexik_form_filter.filter_prepare');
$filterPrepareDef->addMethodCall(
'setEncoding',
array($config['encoding'])
[$config['encoding']]
);
}

Expand Down
2 changes: 1 addition & 1 deletion Event/FilterEvents.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
*/
class FilterEvents
{
const PREPARE = 'lexik_filter.prepare';
public const PREPARE = 'lexik_filter.prepare';
}
8 changes: 4 additions & 4 deletions Event/GetFilterConditionEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace Lexik\Bundle\FormFilterBundle\Event;

use Symfony\Contracts\EventDispatcher\Event;
use Lexik\Bundle\FormFilterBundle\Filter\Condition\Condition;
use Lexik\Bundle\FormFilterBundle\Filter\Condition\ConditionInterface;
use Lexik\Bundle\FormFilterBundle\Filter\Query\QueryInterface;
use Symfony\Contracts\EventDispatcher\Event;

/**
* @author Jeremy Barthe <[email protected]>
Expand Down Expand Up @@ -42,8 +42,8 @@ class GetFilterConditionEvent extends Event
public function __construct(QueryInterface $filterQuery, $field, $values)
{
$this->filterQuery = $filterQuery;
$this->field = $field;
$this->values = $values;
$this->field = $field;
$this->values = $values;
}

/**
Expand Down Expand Up @@ -82,7 +82,7 @@ public function getValues()
* @param string $expression
* @param array $parameters
*/
public function setCondition($expression, array $parameters = array())
public function setCondition($expression, array $parameters = [])
{
$this->condition = new Condition($expression, $parameters);
}
Expand Down
6 changes: 3 additions & 3 deletions Event/Listener/DoctrineApplyFilterListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Lexik\Bundle\FormFilterBundle\Event\Listener;

use Doctrine\ORM\Query\Expr\Composite;
use Doctrine\DBAL\Query\Expression\CompositeExpression;
use Doctrine\ORM\Query\Expr\Composite;
use Lexik\Bundle\FormFilterBundle\Event\ApplyFilterConditionEvent;
use Lexik\Bundle\FormFilterBundle\Filter\Condition\ConditionInterface;
use Lexik\Bundle\FormFilterBundle\Filter\Condition\ConditionNodeInterface;
Expand Down Expand Up @@ -42,15 +42,15 @@ public function onApplyFilterCondition(ApplyFilterConditionEvent $event)
$qbAdapter = new DoctrineQueryBuilderAdapter($event->getQueryBuilder());
$conditionBuilder = $event->getConditionBuilder();

$this->parameters = array();
$this->parameters = [];
$expression = $this->computeExpression($qbAdapter, $conditionBuilder->getRoot());

if (null !== $expression && $expression->count()) {
$qbAdapter->{$this->whereMethod}($expression);

foreach ($this->parameters as $name => $value) {
if (is_array($value)) {
list($value, $type) = $value;
[$value, $type] = $value;
$qbAdapter->setParameter($name, $value, $type);
} else {
$qbAdapter->setParameter($name, $value);
Expand Down
2 changes: 1 addition & 1 deletion Event/Listener/DoctrineMongoDBApplyFilterListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ protected function computeExpression(Builder $queryBuilder, ConditionNodeInterfa

$method = ($node->getOperator() === ConditionNodeInterface::EXPR_AND) ? 'addAnd' : 'addOr';

$expression = (null === $expr) ? $queryBuilder : $expr;
$expression = $expr ?? $queryBuilder;
$count = 0;

foreach ($node->getFields() as $condition) {
Expand Down
17 changes: 9 additions & 8 deletions Event/Listener/PrepareListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@

namespace Lexik\Bundle\FormFilterBundle\Event\Listener;

use Lexik\Bundle\FormFilterBundle\Event\PrepareEvent;
use Doctrine\DBAL\Platforms\PostgreSqlPlatform;
use Doctrine\ODM\MongoDB\Query\Builder;
use Doctrine\ORM\QueryBuilder;
use Lexik\Bundle\FormFilterBundle\Event\PrepareEvent;
use Lexik\Bundle\FormFilterBundle\Filter\Doctrine\DBALQuery;
use Lexik\Bundle\FormFilterBundle\Filter\Doctrine\MongodbQuery;
use Lexik\Bundle\FormFilterBundle\Filter\Doctrine\ORMQuery;

/**
* Prepare listener event
Expand Down Expand Up @@ -41,11 +46,11 @@ public function getForceCaseInsensitivity($qb)
return $this->forceCaseInsensitivity;
}

if (class_exists('\Doctrine\ORM\QueryBuilder') && $qb instanceof \Doctrine\ORM\QueryBuilder) {
if (class_exists('\\' . QueryBuilder::class) && $qb instanceof QueryBuilder) {
return ($qb->getEntityManager()->getConnection()->getDatabasePlatform() instanceof PostgreSqlPlatform);
}

if (class_exists('\Doctrine\DBAL\Query\QueryBuilder') && $qb instanceof \Doctrine\DBAL\Query\QueryBuilder) {
if (class_exists('\\' . \Doctrine\DBAL\Query\QueryBuilder::class) && $qb instanceof \Doctrine\DBAL\Query\QueryBuilder) {
return ($qb->getConnection()->getDatabasePlatform() instanceof PostgreSqlPlatform);
}
}
Expand Down Expand Up @@ -79,11 +84,7 @@ public function onFilterBuilderPrepare(PrepareEvent $event)
{
$qb = $event->getQueryBuilder();

$queryClasses = array(
'Doctrine\ORM\QueryBuilder' => 'Lexik\Bundle\FormFilterBundle\Filter\Doctrine\ORMQuery',
'Doctrine\DBAL\Query\QueryBuilder' => 'Lexik\Bundle\FormFilterBundle\Filter\Doctrine\DBALQuery',
'Doctrine\ODM\MongoDB\Query\Builder' => 'Lexik\Bundle\FormFilterBundle\Filter\Doctrine\MongodbQuery',
);
$queryClasses = [QueryBuilder::class => ORMQuery::class, \Doctrine\DBAL\Query\QueryBuilder::class => DBALQuery::class, Builder::class => MongodbQuery::class];

foreach ($queryClasses as $builderClass => $queryClass) {
if (class_exists($builderClass) && $qb instanceof $builderClass) {
Expand Down
2 changes: 1 addition & 1 deletion Event/PrepareEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Lexik\Bundle\FormFilterBundle\Event;

use Symfony\Contracts\EventDispatcher\Event;
use Lexik\Bundle\FormFilterBundle\Filter\Query\QueryInterface;
use Symfony\Contracts\EventDispatcher\Event;

/**
* Get alias and expression builder for filter builder
Expand Down
Loading

0 comments on commit 6ea14ef

Please sign in to comment.