Skip to content

Commit

Permalink
feature #121 Add support for Symfony 6 (macintoshplus, loic425)
Browse files Browse the repository at this point in the history
This PR was merged into the 2.3 branch.

Discussion
----------

Continuation of #119 

Commits
-------

17de965 change version requirement
1adb5a0 first fix SF6 compatibility
d5f6ca2 Change to Symfony 6.0 requirement
8ecea4c Update CI configuration
efa8844 Update Psalm version
897a24b Add migration instruction on UPGRADE.md
814d55c Revert "first fix SF6 compatibility"
bb059fc Fix coding standard
53f3559 Revert changes on UPGRADE
43587bb Fix duplicate config key
ea10685 Fix Psalm errors
d8d76a7 Fix tests for SF6
  • Loading branch information
lchrusciel authored Jul 8, 2022
2 parents 88ab301 + d8d76a7 commit 4fee7f4
Show file tree
Hide file tree
Showing 14 changed files with 127 additions and 43 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ jobs:
include:
-
php: 8.0
symfony: ^4.4
twig: 2.*
symfony: ^5.4
twig: 3.*
-
php: 8.0
symfony: ^5.4
symfony: ^6.0
twig: 3.*

steps:
Expand Down
36 changes: 18 additions & 18 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,20 @@
],
"require": {
"php": "^8.0",
"symfony/asset": "^4.4 || ^5.4",
"symfony/config": "^4.4 || ^5.4",
"symfony/console": "^4.4 || ^5.4",
"symfony/dependency-injection": "^4.4 || ^5.4",
"symfony/filesystem": "^4.4 || ^5.4",
"symfony/finder": "^4.4 || ^5.4",
"symfony/form": "^4.4 || ^5.4",
"symfony/framework-bundle": "^4.4 || ^5.4",
"symfony/http-foundation": "^4.4 || ^5.4",
"symfony/http-kernel": "^4.4 || ^5.4",
"symfony/options-resolver": "^4.4 || ^5.4",
"symfony/service-contracts": "^1.1 || ^2.0",
"symfony/translation": "^4.4 || ^5.4",
"symfony/translation-contracts": "^1.1 || ^2.0"
"symfony/asset": "^5.4 || ^6.0",
"symfony/config": "^5.4 || ^6.0",
"symfony/console": "^5.4 || ^6.0",
"symfony/dependency-injection": "^5.4 || ^6.0",
"symfony/filesystem": "^5.4 || ^6.0",
"symfony/finder": "^5.4 || ^6.0",
"symfony/form": "^4.4 || ^5.4 || ^6.0",
"symfony/framework-bundle": "^5.4 || ^6.0",
"symfony/http-foundation": "^5.4 || ^6.0",
"symfony/http-kernel": "^5.4 || ^6.0",
"symfony/options-resolver": "^5.4 || ^6.0",
"symfony/service-contracts": "^1.1 || ^2.0 || ^3.0",
"symfony/translation": "^5.4 || ^6.0",
"symfony/translation-contracts": "^1.1 || ^2.0 || ^3.0"
},
"require-dev": {
"matthiasnoback/symfony-config-test": "^4.2",
Expand All @@ -46,11 +46,11 @@
"phpspec/phpspec": "^7.0",
"phpunit/phpunit": "^9.4",
"sylius-labs/coding-standard": "^4.0.2",
"symfony/browser-kit": "^4.4 || ^5.4",
"symfony/security-csrf": "^4.4 || ^5.4",
"symfony/twig-bundle": "^4.4 || ^5.4",
"symfony/browser-kit": "^5.4 || ^6.0",
"symfony/security-csrf": "^5.4 || ^6.0",
"symfony/twig-bundle": "^5.4 || ^6.0",
"twig/twig": "^2.0 || ^3.0",
"vimeo/psalm": "4.7.3",
"vimeo/psalm": "4.23.0",
"rector/rector": "^0.11.57"
},
"config": {
Expand Down
8 changes: 7 additions & 1 deletion psalm.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<psalm
totallyTyped="false"
errorLevel="2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
Expand Down Expand Up @@ -28,6 +28,12 @@
</errorLevel>
</DeprecatedClass>

<MissingReturnType>
<errorLevel type="suppress">
<file name="src/Filesystem/Filesystem.php" />
</errorLevel>
</MissingReturnType>

<PossiblyNullReference>
<errorLevel type="suppress">
<file name="src/DependencyInjection/Configuration.php" />
Expand Down
2 changes: 1 addition & 1 deletion src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function getConfigTreeBuilder(): TreeBuilder
$rootNode->children()
->booleanNode('legacy_mode')
->defaultFalse()
->setDeprecated('"%node%" at path "%path%" is deprecated since Sylius/ThemeBundle 2.0 and will be removed in 3.0.')
->setDeprecated('sylius/theme-bundle', '2.0', '"%node%" at path "%path%" is deprecated since Sylius/ThemeBundle 2.0 and will be removed in 3.0.')
;

return $treeBuilder;
Expand Down
2 changes: 1 addition & 1 deletion src/DependencyInjection/SyliusThemeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function load(array $configs, ContainerBuilder $container): void
$container->setAlias(ThemeContextInterface::class, $config['context']);
$container
->setAlias('sylius.context.theme', ThemeContextInterface::class)
->setDeprecated(true, '"%alias_id%" service is deprecated since Sylius/ThemeBundle 2.0 and will be removed in 3.0.')
->setDeprecated('sylius/theme-bundle', '2.0', '"%alias_id%" service is deprecated since Sylius/ThemeBundle 2.0 and will be removed in 3.0.')
;
}

Expand Down
74 changes: 73 additions & 1 deletion src/Filesystem/Filesystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,82 @@

use Symfony\Component\Filesystem\Filesystem as BaseFilesystem;

final class Filesystem extends BaseFilesystem implements FilesystemInterface
final class Filesystem implements FilesystemInterface
{
private BaseFilesystem $filesystem;

public function __construct()
{
$this->filesystem = new BaseFilesystem();
}

public function getFileContents(string $file): string
{
return (string) file_get_contents($file);
}

public function copy(string $originFile, string $targetFile, bool $override = false)
{
$this->filesystem->copy($originFile, $targetFile, $override);
}

public function mkdir($dirs, int $mode = 0777)
{
$this->filesystem->mkdir($dirs, $mode);
}

public function exists($files)
{
return $this->filesystem->exists($files);
}

public function touch($files, int $time = null, int $atime = null)
{
$this->filesystem->touch($files, $time, $atime);
}

public function remove($files)
{
$this->filesystem->remove($files);
}

public function chmod($files, int $mode, int $umask = 0000, bool $recursive = false)
{
$this->filesystem->chmod($files, $mode, $umask, $recursive);
}

public function chown($files, string $user, bool $recursive = false)
{
$this->filesystem->chown($files, $user, $recursive);
}

public function chgrp($files, string $group, bool $recursive = false)
{
$this->filesystem->chgrp($files, $group, $recursive);
}

public function rename(string $origin, string $target, bool $overwrite = false)
{
$this->filesystem->rename($origin, $target, $overwrite);
}

public function symlink(string $originDir, string $targetDir, bool $copyOnWindows = false)
{
$this->filesystem->symlink($originDir, $targetDir, $copyOnWindows);
}

public function mirror(string $originDir, string $targetDir, \Traversable $iterator = null, array $options = [])
{
$this->filesystem->mirror($originDir, $targetDir, $iterator, $options);
}

public function makePathRelative(string $endPath, string $startPath)
{
return $this->filesystem->makePathRelative($endPath, $startPath);
}

public function isAbsolutePath(string $file)
{
return $this->filesystem->isAbsolutePath($file);
}
}
6 changes: 3 additions & 3 deletions src/Resources/config/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,19 @@
<argument type="service" id="sylius.theme.hierarchy_provider" />
</service>
<service id="sylius.theme.context.settable" alias="Sylius\Bundle\ThemeBundle\Context\SettableThemeContext">
<deprecated>"%alias_id%" service is deprecated since Sylius/ThemeBundle 2.0 and will be removed in 3.0.</deprecated>
<deprecated package="sylius/theme-bundle" version="2.0">"%alias_id%" service is deprecated since Sylius/ThemeBundle 2.0 and will be removed in 3.0.</deprecated>
</service>

<service id="Sylius\Bundle\ThemeBundle\Repository\ThemeRepositoryInterface" class="Sylius\Bundle\ThemeBundle\Repository\InMemoryThemeRepository">
<argument type="service" id="sylius.theme.loader" />
</service>
<service id="sylius.repository.theme" alias="Sylius\Bundle\ThemeBundle\Repository\ThemeRepositoryInterface">
<deprecated>"%alias_id%" service is deprecated since Sylius/ThemeBundle 2.0 and will be removed in 3.0.</deprecated>
<deprecated package="sylius/theme-bundle" version="2.0">"%alias_id%" service is deprecated since Sylius/ThemeBundle 2.0 and will be removed in 3.0.</deprecated>
</service>

<service id="Sylius\Bundle\ThemeBundle\HierarchyProvider\ThemeHierarchyProviderInterface" class="Sylius\Bundle\ThemeBundle\HierarchyProvider\ThemeHierarchyProvider" />
<service id="sylius.theme.hierarchy_provider" alias="Sylius\Bundle\ThemeBundle\HierarchyProvider\ThemeHierarchyProviderInterface" >
<deprecated>"%alias_id%" service is deprecated since Sylius/ThemeBundle 2.0 and will be removed in 3.0.</deprecated>
<deprecated package="sylius/theme-bundle" version="2.0">"%alias_id%" service is deprecated since Sylius/ThemeBundle 2.0 and will be removed in 3.0.</deprecated>
</service>
</services>
</container>
6 changes: 3 additions & 3 deletions src/Resources/config/services/configuration.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<services>
<service id="Sylius\Bundle\ThemeBundle\Configuration\ThemeConfiguration" />
<service id="sylius.theme.configuration" alias="Sylius\Bundle\ThemeBundle\Configuration\ThemeConfiguration">
<deprecated>"%alias_id%" service is deprecated since Sylius/ThemeBundle 2.0 and will be removed in 3.0.</deprecated>
<deprecated package="sylius/theme-bundle" version="2.0">"%alias_id%" service is deprecated since Sylius/ThemeBundle 2.0 and will be removed in 3.0.</deprecated>
</service>

<service id="Sylius\Bundle\ThemeBundle\Configuration\ConfigurationProcessorInterface" class="Sylius\Bundle\ThemeBundle\Configuration\SymfonyConfigurationProcessor">
Expand All @@ -25,14 +25,14 @@
</argument>
</service>
<service id="sylius.theme.configuration.processor" alias="Sylius\Bundle\ThemeBundle\Configuration\ConfigurationProcessorInterface">
<deprecated>"%alias_id%" service is deprecated since Sylius/ThemeBundle 2.0 and will be removed in 3.0.</deprecated>
<deprecated package="sylius/theme-bundle" version="2.0">"%alias_id%" service is deprecated since Sylius/ThemeBundle 2.0 and will be removed in 3.0.</deprecated>
</service>

<service id="Sylius\Bundle\ThemeBundle\Configuration\ConfigurationProviderInterface" class="Sylius\Bundle\ThemeBundle\Configuration\CompositeConfigurationProvider">
<argument type="collection" /> <!-- an array of configuration providers -->
</service>
<service id="sylius.theme.configuration.provider" alias="Sylius\Bundle\ThemeBundle\Configuration\ConfigurationProviderInterface">
<deprecated>"%alias_id%" service is deprecated since Sylius/ThemeBundle 2.0 and will be removed in 3.0.</deprecated>
<deprecated package="sylius/theme-bundle" version="2.0">"%alias_id%" service is deprecated since Sylius/ThemeBundle 2.0 and will be removed in 3.0.</deprecated>
</service>
</services>
</container>
10 changes: 5 additions & 5 deletions src/Resources/config/services/loader.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,22 @@
<services>
<service id="Sylius\Bundle\ThemeBundle\Factory\ThemeFactoryInterface" class="Sylius\Bundle\ThemeBundle\Factory\ThemeFactory" />
<service id="sylius.factory.theme" alias="Sylius\Bundle\ThemeBundle\Factory\ThemeFactoryInterface">
<deprecated>"%alias_id%" service is deprecated since Sylius/ThemeBundle 2.0 and will be removed in 3.0.</deprecated>
<deprecated package="sylius/theme-bundle" version="2.0">"%alias_id%" service is deprecated since Sylius/ThemeBundle 2.0 and will be removed in 3.0.</deprecated>
</service>

<service id="Sylius\Bundle\ThemeBundle\Factory\ThemeAuthorFactoryInterface" class="Sylius\Bundle\ThemeBundle\Factory\ThemeAuthorFactory" />
<service id="sylius.factory.theme_author" alias="Sylius\Bundle\ThemeBundle\Factory\ThemeAuthorFactoryInterface">
<deprecated>"%alias_id%" service is deprecated since Sylius/ThemeBundle 2.0 and will be removed in 3.0.</deprecated>
<deprecated package="sylius/theme-bundle" version="2.0">"%alias_id%" service is deprecated since Sylius/ThemeBundle 2.0 and will be removed in 3.0.</deprecated>
</service>

<service id="Sylius\Bundle\ThemeBundle\Factory\ThemeScreenshotFactoryInterface" class="Sylius\Bundle\ThemeBundle\Factory\ThemeScreenshotFactory" />
<service id="sylius.factory.theme_screenshot" alias="Sylius\Bundle\ThemeBundle\Factory\ThemeScreenshotFactoryInterface">
<deprecated>"%alias_id%" service is deprecated since Sylius/ThemeBundle 2.0 and will be removed in 3.0.</deprecated>
<deprecated package="sylius/theme-bundle" version="2.0">"%alias_id%" service is deprecated since Sylius/ThemeBundle 2.0 and will be removed in 3.0.</deprecated>
</service>

<service id="Sylius\Bundle\ThemeBundle\Loader\CircularDependencyCheckerInterface" class="Sylius\Bundle\ThemeBundle\Loader\CircularDependencyChecker" />
<service id="sylius.theme.circular_dependency_checker" alias="Sylius\Bundle\ThemeBundle\Loader\CircularDependencyCheckerInterface">
<deprecated>"%alias_id%" service is deprecated since Sylius/ThemeBundle 2.0 and will be removed in 3.0.</deprecated>
<deprecated package="sylius/theme-bundle" version="2.0">"%alias_id%" service is deprecated since Sylius/ThemeBundle 2.0 and will be removed in 3.0.</deprecated>
</service>

<service id="Sylius\Bundle\ThemeBundle\Loader\ThemeLoaderInterface" class="Sylius\Bundle\ThemeBundle\Loader\ThemeLoader">
Expand All @@ -41,7 +41,7 @@
<argument type="service" id="Sylius\Bundle\ThemeBundle\Loader\CircularDependencyCheckerInterface" />
</service>
<service id="sylius.theme.loader" alias="Sylius\Bundle\ThemeBundle\Loader\ThemeLoaderInterface">
<deprecated>"%alias_id%" service is deprecated since Sylius/ThemeBundle 2.0 and will be removed in 3.0.</deprecated>
<deprecated package="sylius/theme-bundle" version="2.0">"%alias_id%" service is deprecated since Sylius/ThemeBundle 2.0 and will be removed in 3.0.</deprecated>
</service>
</services>
</container>
12 changes: 9 additions & 3 deletions src/Translation/ThemeAwareTranslator.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

use Sylius\Bundle\ThemeBundle\Context\ThemeContextInterface;
use Symfony\Component\HttpKernel\CacheWarmer\WarmableInterface;
use Symfony\Component\Translation\MessageCatalogueInterface;
use Symfony\Component\Translation\TranslatorBagInterface;
use Symfony\Contracts\Translation\LocaleAwareInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
Expand Down Expand Up @@ -61,7 +62,7 @@ public function __call(string $method, array $arguments)
/**
* @psalm-suppress MissingParamType Two interfaces defining the same method
*/
public function trans($id, array $parameters = [], $domain = null, $locale = null)
public function trans($id, array $parameters = [], $domain = null, $locale = null): string
{
return $this->translator->trans($id, $parameters, $domain, $this->transformLocale($locale));
}
Expand All @@ -75,7 +76,7 @@ public function transChoice(string $id, int $number, array $parameters = [], ?st
return $this->translator->transChoice($id, $number, $parameters, $domain, $this->transformLocale($locale));
}

public function getLocale()
public function getLocale(): string
{
return $this->translator->getLocale();
}
Expand All @@ -94,7 +95,7 @@ public function setLocale($locale): void
/**
* @param string|null $locale
*/
public function getCatalogue($locale = null)
public function getCatalogue($locale = null): MessageCatalogueInterface
{
return $this->translator->getCatalogue($locale);
}
Expand Down Expand Up @@ -126,4 +127,9 @@ private function transformLocale(?string $locale): ?string

return $locale . '@' . str_replace('/', '-', $theme->getName());
}

public function getCatalogues(): array
{
return $this->translator->getCatalogues();
}
}
2 changes: 1 addition & 1 deletion tests/Application/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

final class Kernel extends HttpKernel
{
public function registerBundles()
public function registerBundles(): iterable
{
return [
new \Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
Expand Down
2 changes: 1 addition & 1 deletion tests/Application/TestBundle/Resources/config/routing.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
template:
path: /template/{templateName}
defaults: { _controller: Sylius\Bundle\ThemeBundle\Tests\Application\TestBundle\Controller\TemplatingController:renderTemplateAction }
defaults: { _controller: Sylius\Bundle\ThemeBundle\Tests\Application\TestBundle\Controller\TemplatingController::renderTemplateAction }
requirements:
templateName: .+
2 changes: 1 addition & 1 deletion tests/Application/config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ framework:
default_locale: "%locale%"
session:
handler_id: ~
storage_id: session.storage.mock_file
storage_factory_id: session.storage.factory.mock_file
http_method_override: true
test: ~

Expand Down
2 changes: 1 addition & 1 deletion tests/Functional/AssetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ private function assertFileContent(array $lines, string $publicDirectory): void

private function getThemeAssetsInstaller(KernelBrowser $client): AssetsInstallerInterface
{
$themeAssetsInstaller = static::$container->get(AssetsInstallerInterface::class);
$themeAssetsInstaller = static::getContainer()->get(AssetsInstallerInterface::class);

assert($themeAssetsInstaller instanceof AssetsInstallerInterface);

Expand Down

0 comments on commit 4fee7f4

Please sign in to comment.