diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 2ead43a..e2dda12 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -6,29 +6,29 @@ on: jobs: tests: - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 strategy: matrix: php: - - '7.3' - - '7.4' - - '8.0' + - '8.1' + - '8.2' + - '8.3' include: - - description: 'Symfony 4.4' - php: '7.3' - composer_option: '--prefer-lowest' - description: 'Symfony 5.4' - php: '7.4' - symfony: 5.4.* - - description: 'Symfony 6.0' - php: '8.0' - symfony: 6.0.* + php: '8.1' + composer_option: '--prefer-lowest' + - description: 'Symfony 6.4' + php: '8.2' + symfony: 6.4.* + - description: 'Symfony 7.1' + php: '8.3' + symfony: 7.1.* name: PHP ${{ matrix.php }} tests (${{ matrix.description }}) steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Cache - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: ~/.composer/cache/files key: ${{ matrix.php }}-${{ matrix.symfony }}-${{ matrix.composer_option }} diff --git a/.php_cs b/.php-cs-fixer.php similarity index 60% rename from .php_cs rename to .php-cs-fixer.php index 11be47a..b46948b 100644 --- a/.php_cs +++ b/.php-cs-fixer.php @@ -5,17 +5,15 @@ ->in([__DIR__.'/src', __DIR__.'/tests']) ; -return PhpCsFixer\Config::create() +return (new PhpCsFixer\Config()) ->setRiskyAllowed(true) ->setRules([ '@Symfony' => true, '@Symfony:risky' => true, - '@PHP71Migration:risky' => true, - '@PHPUnit60Migration:risky' => true, - 'array_syntax' => ['syntax' => 'short'], - 'ordered_imports' => true, + '@PHP81Migration' => true, + '@PHPUnit84Migration:risky' => true, 'declare_strict_types' => false, - 'native_function_invocation' => true, + 'native_function_invocation' => ['include' => ['@all']], 'php_unit_mock_short_will_return' => true, ]) ->setFinder($finder) diff --git a/README.md b/README.md index 7aa6d33..845fa9b 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,4 @@ -PUGXAutocompleterBundle -======================= +# PUGXAutocompleterBundle This bundle has a simple, specific purpose: adding an "autocomplete" (also known as "type-ahead") field. @@ -9,29 +8,23 @@ classic select is not suitable. Here comes this bundle. ![Build Status](https://github.com/PUGX/PUGXAutoCompleterBundle/workflows/build/badge.svg) -Documentation -------------- +## Documentation [Read the documentation](https://github.com/PUGX/PUGXAutoCompleterBundle/tree/master/docs/index.md) -Installation ------------- +## Installation All the installation instructions are located in [documentation](https://github.com/PUGX/PUGXAutoCompleterBundle/tree/master/docs/index.md). -License -------- +## License This bundle is released under the LGPL license. See the [complete license text](https://github.com/PUGX/PUGXAutoCompleterBundle/tree/master/LICENSE). -About ------ +## About PUGXAutocompleterBundle is a [PUGX](http://pugx.org/) initiative. - -Reporting an issue or a feature request ---------------------------------------- +## Reporting an issue or a feature request Issues and feature requests are tracked in the [Github issue tracker](https://github.com/PUGX/PUGXAutocompleterBundle/issues). diff --git a/composer.json b/composer.json index d019941..7caa028 100644 --- a/composer.json +++ b/composer.json @@ -11,20 +11,20 @@ } ], "require": { - "php": "^7.3 || ^8.0", - "doctrine/persistence": "^3.0.1", - "symfony/config": "^4.4 || ^5.4 || ^6.0", - "symfony/dependency-injection": "^4.4 || ^5.4 || ^6.0", - "symfony/event-dispatcher": "^4.4 || ^5.4 || ^6.0", - "symfony/form": "^4.4 || ^5.4 || ^6.0", - "symfony/http-kernel": "^4.4 || ^5.4 || ^6.0" + "php": "^8.1", + "doctrine/persistence": "^3.3", + "symfony/config": "^5.4 || ^6.4 || ^7.0", + "symfony/dependency-injection": "^5.4 || ^6.4 || ^7.0", + "symfony/event-dispatcher": "^5.4 || ^6.4 || ^7.0", + "symfony/form": "^5.4 || ^6.4 || ^7.0", + "symfony/http-kernel": "^5.4 || ^6.4 || ^7.0" }, "require-dev": { - "lexik/form-filter-bundle": "^6.0 || ^7.0", - "phpunit/phpunit": "^9.5" + "phpunit/phpunit": "^9.6", + "spiriitlabs/form-filter-bundle": "^11.0" }, "suggest": { - "lexik/form-filter-bundle" : "To use autocomplete on a filter." + "spiriitlabs/form-filter-bundle" : "To use autocomplete on a filter." }, "autoload": { "psr-4": { "PUGX\\AutocompleterBundle\\": "src" } diff --git a/docs/index.md b/docs/index.md index 0db41b2..c973464 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,5 +1,4 @@ -PUGXAutocompleterBundle Documentation -===================================== +# PUGXAutocompleterBundle Documentation ## 1. Installation diff --git a/src/DependencyInjection/PUGXAutocompleterExtension.php b/src/DependencyInjection/PUGXAutocompleterExtension.php index d9d915b..f235f95 100644 --- a/src/DependencyInjection/PUGXAutocompleterExtension.php +++ b/src/DependencyInjection/PUGXAutocompleterExtension.php @@ -17,11 +17,11 @@ final class PUGXAutocompleterExtension extends ConfigurableExtension { /** - * @param array $configs + * @param array $mergedConfig * * @throws \Exception */ - public function loadInternal(array $configs, ContainerBuilder $container): void + public function loadInternal(array $mergedConfig, ContainerBuilder $container): void { $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../../config')); $loader->load('services.xml'); diff --git a/src/Form/Transformer/ObjectToIdTransformer.php b/src/Form/Transformer/ObjectToIdTransformer.php index addd53f..bf0a243 100644 --- a/src/Form/Transformer/ObjectToIdTransformer.php +++ b/src/Form/Transformer/ObjectToIdTransformer.php @@ -8,52 +8,40 @@ class ObjectToIdTransformer implements DataTransformerInterface { - /** - * @var ManagerRegistry - */ - private $registry; - - /** - * @var string - */ - private $class; - - public function __construct(ManagerRegistry $registry, string $class) + public function __construct(private ManagerRegistry $registry, private string $class) { - $this->registry = $registry; - $this->class = $class; } /** * Transforms an object (object) to a string (id). * - * @param object|null $object + * @param object|null $value */ - public function transform($object): string + public function transform($value): string { - if (null === $object) { + if (null === $value) { return ''; } - return $object->getId(); + return $value->getId(); } /** * Transforms a string (id) to an object (object). * - * @param string|int|null $id + * @param string|int|null $value * * @throws TransformationFailedException if object (object) is not found */ - public function reverseTransform($id): ?object + public function reverseTransform($value): ?object { - if (empty($id)) { + if (empty($value)) { return null; } - $object = $this->registry->getManagerForClass($this->class)->getRepository($this->class)->find($id); + $object = $this->registry->getManagerForClass($this->class)->getRepository($this->class)->find($value); if (null === $object) { $msg = 'Object from class %s with id "%s" not found'; - throw new TransformationFailedException(\sprintf($msg, $this->class, $id)); + throw new TransformationFailedException(\sprintf($msg, $this->class, $value)); } return $object; diff --git a/src/Form/Type/AutocompleteType.php b/src/Form/Type/AutocompleteType.php index 151a44a..9a673f6 100644 --- a/src/Form/Type/AutocompleteType.php +++ b/src/Form/Type/AutocompleteType.php @@ -11,14 +11,8 @@ class AutocompleteType extends AbstractType { - /** - * @var ManagerRegistry - */ - private $registry; - - public function __construct(ManagerRegistry $registry) + public function __construct(private ManagerRegistry $registry) { - $this->registry = $registry; } /** diff --git a/src/Listener/FilterSubscriber.php b/src/Listener/FilterSubscriber.php index 431ea9c..7bd1e3e 100644 --- a/src/Listener/FilterSubscriber.php +++ b/src/Listener/FilterSubscriber.php @@ -2,11 +2,11 @@ namespace PUGX\AutocompleterBundle\Listener; -use Lexik\Bundle\FormFilterBundle\Event\GetFilterConditionEvent; +use Spiriit\Bundle\FormFilterBundle\Event\GetFilterConditionEvent; use Symfony\Component\EventDispatcher\EventSubscriberInterface; /** - * See https://github.com/lexik/LexikFormFilterBundle for this custom filter. + * See https://github.com/SpiriitLabs/form-filter-bundle for this custom filter. */ final class FilterSubscriber implements EventSubscriberInterface { @@ -26,12 +26,12 @@ public static function getSubscribedEvents(): array } /** - * Apply a filter for a filter_autcomplete type. + * Apply a filter for a filter_autocomplete type. * This method should work with both ORM and DBAL query builder. */ public function filterAutocomplete(GetFilterConditionEvent $event): void { - /** @var \Lexik\Bundle\FormFilterBundle\Filter\Doctrine\ORMQuery|\Lexik\Bundle\FormFilterBundle\Filter\Doctrine\DBALQuery $query */ + /** @var \Spiriit\Bundle\FormFilterBundle\Filter\Doctrine\ORMQuery|\Spiriit\Bundle\FormFilterBundle\Filter\Doctrine\DBALQuery $query */ $query = $event->getFilterQuery(); $expr = $query->getExpr(); $values = $event->getValues(); diff --git a/src/Resources b/src/Resources deleted file mode 120000 index 8fee7ab..0000000 --- a/src/Resources +++ /dev/null @@ -1 +0,0 @@ -../Resources/ \ No newline at end of file diff --git a/tests/Listener/FilterSubscriberTest.php b/tests/Listener/FilterSubscriberTest.php index 413b58d..c5ae6a8 100644 --- a/tests/Listener/FilterSubscriberTest.php +++ b/tests/Listener/FilterSubscriberTest.php @@ -3,10 +3,10 @@ namespace PUGX\AutocompleterBundle\Tests\Listener; use Doctrine\ORM\Query\Expr; -use Lexik\Bundle\FormFilterBundle\Event\GetFilterConditionEvent; -use Lexik\Bundle\FormFilterBundle\Filter\Doctrine\ORMQuery; use PHPUnit\Framework\TestCase; use PUGX\AutocompleterBundle\Listener\FilterSubscriber; +use Spiriit\Bundle\FormFilterBundle\Event\GetFilterConditionEvent; +use Spiriit\Bundle\FormFilterBundle\Filter\Doctrine\ORMQuery; final class FilterSubscriberTest extends TestCase {