Skip to content

Commit

Permalink
Merge pull request #88 from lruozzi9/support-symfony-6
Browse files Browse the repository at this point in the history
Support Symfony 6 and drop Symfony 4 and PHP < 8.1
  • Loading branch information
loevgaard authored Jan 30, 2024
2 parents 4f7e406 + 7dc5e76 commit 078f73a
Show file tree
Hide file tree
Showing 63 changed files with 320 additions and 265 deletions.
28 changes: 11 additions & 17 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
strategy:
matrix:
php-version:
- "7.4"
- "8.1"

dependencies:
- "highest"
Expand Down Expand Up @@ -64,16 +64,15 @@ jobs:
strategy:
matrix:
php-version:
- "7.4"
- "8.0"
- "8.1"
- "8.2"

dependencies:
- "highest"

symfony:
- "^4.4"
- "^5.4"
- "^6.3"

steps:
- name: "Checkout"
Expand Down Expand Up @@ -108,16 +107,15 @@ jobs:
strategy:
matrix:
php-version:
- "7.4"
- "8.0"
- "8.1"
- "8.2"

dependencies:
- "highest"

symfony:
- "^4.4"
- "^5.4"
- "^6.3"

steps:
- name: "Checkout"
Expand Down Expand Up @@ -152,16 +150,15 @@ jobs:
strategy:
matrix:
php-version:
- "7.4"
- "8.0"
- "8.1"
- "8.2"

dependencies:
- "highest"

symfony:
- "^4.4"
- "^5.4"
- "^6.3"

steps:
- name: "Checkout"
Expand Down Expand Up @@ -193,16 +190,15 @@ jobs:
strategy:
matrix:
php-version:
- "7.4"
- "8.0"
- "8.1"
- "8.2"

dependencies:
- "highest"

symfony:
- "^4.4"
- "^5.4"
- "^6.3"

steps:
- name: "Start MySQL"
Expand All @@ -227,9 +223,7 @@ jobs:
dependency-versions: "${{ matrix.dependencies }}"

- name: "Lint container"
# Do not lint on SF4 because we get this error: Invalid definition for service "doctrine.migrations.dependency_factory": argument 2 of "Doctrine\Migrations\DependencyFactory::setDefinition()" accepts "callable", "SyliusLabs\DoctrineMigrationsExtraBundle\Factory\ContainerAwareVersionFactory" passed.
# Note: We cannot use the if statement here, because of https://github.community/t/matrix-cannot-be-used-in-jobs-level-if/17177/10
run: 'if [ "${{ matrix.symfony }}" != "^4.4" ]; then (cd tests/Application && bin/console lint:container); fi'
run: "(cd tests/Application && bin/console lint:container)"

- name: "Create database"
run: "(cd tests/Application && bin/console doctrine:database:create -vvv)"
Expand All @@ -251,7 +245,7 @@ jobs:
strategy:
matrix:
php-version:
- "8.1"
- "8.2"

dependencies:
- "highest"
Expand Down
3 changes: 2 additions & 1 deletion composer-require-checker.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"Sylius\\Component\\Product\\Resolver\\ProductVariantResolverInterface",
"League\\Flysystem\\FileNotFoundException",
"League\\Flysystem\\FilesystemInterface",
"League\\Flysystem\\RootViolationException"
"League\\Flysystem\\RootViolationException",
"Symfony\\Component\\HttpFoundation\\Session\\FlashBagAwareSessionInterface"
]
}
2 changes: 1 addition & 1 deletion composer-unused.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
return $config
->addNamedFilter(NamedFilter::fromString('league/flysystem-bundle'))
->addNamedFilter(NamedFilter::fromString('setono/doctrine-orm-batcher-bundle'))
;
;
};
56 changes: 27 additions & 29 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"license": "MIT",
"type": "symfony-bundle",
"require": {
"php": ">=7.4",
"php": ">=8.1",
"ext-json": "*",
"doctrine/collections": "^1.6",
"doctrine/orm": "^2.7",
Expand All @@ -16,49 +16,47 @@
"psr/event-dispatcher": "^1.0",
"psr/log": "^1.0 || ^2.0 || ^3.0",
"setono/doctrine-orm-batcher": "^0.6",
"setono/doctrine-orm-batcher-bundle": "^0.3.1",
"setono/doctrine-orm-batcher-bundle": "^0.3.4",
"setono/symfony-main-request-trait": "^1.0",
"spatie/enum": "^3.7",
"sylius/resource-bundle": "^1.6",
"symfony/config": "^4.4 || ^5.4",
"symfony/console": "^4.4 || ^5.4",
"symfony/dependency-injection": "^4.4 || ^5.4",
"symfony/event-dispatcher": "^4.4 || ^5.4",
"symfony/config": "^5.4 || ^6.3",
"symfony/console": "^5.4 || ^6.3",
"symfony/dependency-injection": "^5.4 || ^6.3",
"symfony/event-dispatcher": "^5.4 || ^6.3",
"symfony/event-dispatcher-contracts": "^1.1 || ^2.2",
"symfony/form": "^4.4 || ^5.4",
"symfony/http-foundation": "^4.4 || ^5.4.7",
"symfony/http-kernel": "^4.4 || ^5.4",
"symfony/messenger": "^4.4 || ^5.4",
"symfony/mime": "^4.4 || ^5.4",
"symfony/options-resolver": "^4.4 || ^5.4",
"symfony/routing": "^4.4 || ^5.4",
"symfony/serializer": "^4.4 || ^5.4",
"symfony/translation-contracts": "^1.1 || ^2.3",
"symfony/uid": "^5.4",
"symfony/validator": "^4.4 || ^5.4",
"symfony/workflow": "^4.4 || ^5.4",
"symfony/form": "^5.4 || ^6.3",
"symfony/http-foundation": "^5.4.7 || ^6.3",
"symfony/http-kernel": "^5.4 || ^6.3",
"symfony/messenger": "^5.4 || ^6.3",
"symfony/mime": "^5.4 || ^6.3",
"symfony/options-resolver": "^5.4 || ^6.3",
"symfony/routing": "^5.4 || ^6.3",
"symfony/serializer": "^5.4 || ^6.3",
"symfony/translation-contracts": "^1.1 || ^2.3 || ^3.0",
"symfony/uid": "^5.4 || ^6.3",
"symfony/validator": "^5.4 || ^6.3",
"symfony/workflow": "^5.4 || ^6.3",
"twig/twig": "^2.14",
"webmozart/assert": "^1.1"
},
"require-dev": {
"api-platform/core": "^2.6",
"friendsofsymfony/oauth-server-bundle": ">2.0.0-alpha.0 ^2.0@dev",
"lexik/jwt-authentication-bundle": "^2.15",
"php-http/message-factory": "^1.1",
"phpspec/phpspec": "^7.2",
"phpunit/phpunit": "^9.5",
"polishsymfonycommunity/symfony-mocker-container": "^1.0",
"psalm/plugin-phpunit": "^0.16",
"psalm/plugin-symfony": "^3.0",
"roave/security-advisories": "dev-latest",
"setono/code-quality-pack": "^2.2",
"psalm/plugin-phpunit": "^0.18",
"psalm/plugin-symfony": "^5.0",
"setono/code-quality-pack": "^2.4",
"setono/sylius-behat-pack": "^0.2",
"sylius/admin-api-bundle": "^1.11",
"sylius/sylius": "~1.10.14",
"symfony/debug-bundle": "^4.4 || ^5.4",
"symfony/dotenv": "^4.4 || ^5.4",
"symfony/intl": "^4.4 || ^5.4",
"symfony/web-profiler-bundle": "^4.4 || ^5.4",
"sylius/sylius": "^1.11",
"symfony/debug-bundle": "^5.4 || ^6.3",
"symfony/dotenv": "^5.4 || ^6.3",
"symfony/intl": "^5.4 || ^6.3",
"symfony/web-profiler-bundle": "^5.4 || ^6.3",
"symfony/webpack-encore-bundle": "^1.17",
"weirdan/doctrine-psalm-plugin": "^2.2"
},
"prefer-stable": true,
Expand Down
11 changes: 5 additions & 6 deletions ecs.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@

declare(strict_types=1);

use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symplify\EasyCodingStandard\ValueObject\Option;
use Symplify\EasyCodingStandard\Config\ECSConfig;

return static function (ContainerConfigurator $config): void {
$config->import('vendor/sylius-labs/coding-standard/ecs.php');
$config->parameters()->set(Option::PATHS, [
return static function (ECSConfig $config): void {
$config->sets(['vendor/sylius-labs/coding-standard/ecs.php']);
$config->paths([
'src', 'tests', 'spec'
]);
$config->parameters()->set(Option::SKIP, [
$config->skip([
'tests/Application/**',
]);
};
12 changes: 8 additions & 4 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,20 @@
</projectFiles>
<plugins>
<pluginClass class="Psalm\SymfonyPsalmPlugin\Plugin">
<!-- Symfony 4 container XML -->
<containerXml>tests/Application/var/cache/test/ApplicationTests_Setono_SyliusFeedPlugin_Application_KernelTestDebugContainer.xml</containerXml>

<!-- Symfony 5 container XML -->
<containerXml>tests/Application/var/cache/test/Tests_Setono_SyliusFeedPlugin_Application_KernelTestDebugContainer.xml</containerXml>
<extraFiles>
<directory name="var/cache/dev/Symfony/Config" /> <!-- https://github.com/psalm/psalm-plugin-symfony/issues/201 -->
</extraFiles>
</pluginClass>
<pluginClass class="Psalm\PhpUnitPlugin\Plugin"/>
<pluginClass class="Weirdan\DoctrinePsalmPlugin\Plugin"/>
</plugins>
<issueHandlers>
<MethodSignatureMismatch>
<errorLevel type="suppress">
<file name="src/Feed/Model/Google/Shopping/DateTime.php" />
</errorLevel>
</MethodSignatureMismatch>
<PluginIssue name="QueryBuilderSetParameter" errorLevel="info"/>
<UnnecessaryVarAnnotation errorLevel="suppress"/>
</issueHandlers>
Expand Down
2 changes: 1 addition & 1 deletion spec/Controller/Action/Admin/ProcessFeedActionSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function let(
MessageBusInterface $commandBus,
UrlGeneratorInterface $urlGenerator,
FlashBagInterface $flashBag,
TranslatorInterface $translator
TranslatorInterface $translator,
): void {
$this->beConstructedWith($commandBus, $urlGenerator, $flashBag, $translator);
}
Expand Down
23 changes: 19 additions & 4 deletions src/Controller/Action/Admin/ProcessFeedAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,20 @@

use Setono\SyliusFeedPlugin\Message\Command\ProcessFeed;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface;
use Symfony\Component\HttpFoundation\Session\FlashBagAwareSessionInterface;
use Symfony\Component\Messenger\MessageBusInterface;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Contracts\Translation\TranslatorInterface;

use Webmozart\Assert\Assert;

/**
* @psalm-suppress UndefinedClass
* @psalm-suppress MixedArgument
* @psalm-suppress UndefinedInterfaceMethod
* @psalm-suppress MixedAssignment
*/
final class ProcessFeedAction
{
private MessageBusInterface $commandBus;
Expand All @@ -24,12 +33,18 @@ final class ProcessFeedAction
public function __construct(
MessageBusInterface $commandBus,
UrlGeneratorInterface $urlGenerator,
FlashBagInterface $flashBag,
TranslatorInterface $translator
FlashBagInterface|RequestStack $requestStackOrFlashBag,
TranslatorInterface $translator,
) {
$this->commandBus = $commandBus;
$this->urlGenerator = $urlGenerator;
$this->flashBag = $flashBag;
if ($requestStackOrFlashBag instanceof FlashBagInterface) {
$this->flashBag = $requestStackOrFlashBag;
} else {
$session = $requestStackOrFlashBag->getSession();
Assert::isInstanceOf($session, FlashBagAwareSessionInterface::class);
$this->flashBag = $session->getFlashBag();
}
$this->translator = $translator;
}

Expand Down
4 changes: 2 additions & 2 deletions src/Controller/Action/Shop/ShowFeedAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function __construct(
LocaleContextInterface $localeContext,
FeedPathGeneratorInterface $feedPathGenerator,
$filesystem,
MimeTypesInterface $mimeTypes
MimeTypesInterface $mimeTypes,
) {
$this->repository = $repository;
$this->channelContext = $channelContext;
Expand All @@ -60,7 +60,7 @@ public function __construct(
throw new InvalidArgumentException(sprintf(
'The filesystem must be an instance of %s or %s',
FilesystemInterface::class,
FilesystemOperator::class
FilesystemOperator::class,
));
}
$this->mimeTypes = $mimeTypes;
Expand Down
2 changes: 1 addition & 1 deletion src/DataProvider/DataProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function __construct(
EventDispatcherInterface $eventDispatcher,
ManagerRegistry $managerRegistry,
string $class,
int $batchSize = 100
int $batchSize = 100,
) {
$this->batcherFactory = $batcherFactory;
$this->queryRebuilder = $queryRebuilder;
Expand Down
9 changes: 7 additions & 2 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,17 @@

final class Configuration implements ConfigurationInterface
{
/**
* @psalm-suppress MixedMethodCall
* @psalm-suppress UndefinedInterfaceMethod
*/
public function getConfigTreeBuilder(): TreeBuilder
{
$treeBuilder = new TreeBuilder('setono_sylius_feed');

/** @var ArrayNodeDefinition $rootNode */
$rootNode = $treeBuilder->getRootNode();

/** @psalm-suppress MixedMethodCall */
$rootNode
->addDefaultsIfNotSet()
->children()
Expand All @@ -53,9 +56,11 @@ public function getConfigTreeBuilder(): TreeBuilder
return $treeBuilder;
}

/**
* @psalm-suppress MixedMethodCall, UndefinedInterfaceMethod
*/
private function addResourcesSection(ArrayNodeDefinition $node): void
{
/** @psalm-suppress MixedMethodCall */
$node
->children()
->arrayNode('resources')
Expand Down
2 changes: 1 addition & 1 deletion src/Event/QueryBuilderEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function __construct(
DataProviderInterface $dataProvider,
QueryBuilder $queryBuilder,
ChannelInterface $channel,
LocaleInterface $locale
LocaleInterface $locale,
) {
$this->dataProvider = $dataProvider;
$this->queryBuilder = $queryBuilder;
Expand Down
2 changes: 1 addition & 1 deletion src/EventListener/DeleteGeneratedFilesSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function __construct($filesystem)
throw new InvalidArgumentException(sprintf(
'The filesystem must be an instance of %s or %s',
FilesystemInterface::class,
FilesystemOperator::class
FilesystemOperator::class,
));
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/EventListener/Filter/AbstractFilterListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ protected function getAlias(QueryBuilder $queryBuilder): string
throw new InvalidArgumentException('This filter only works with one root alias');
}

return $aliases[0];
return reset($aliases);
}

protected function getClassMetadata(QueryBuilderEvent $event): ClassMetadata
Expand Down
Loading

0 comments on commit 078f73a

Please sign in to comment.