Skip to content

Commit

Permalink
Fix coding standard
Browse files Browse the repository at this point in the history
  • Loading branch information
loic425 committed Jul 7, 2022
1 parent 814d55c commit bb059fc
Show file tree
Hide file tree
Showing 10 changed files with 102 additions and 19 deletions.
5 changes: 5 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,10 @@
"vendor/bin/phpunit --colors=always",
"APP_ENV=test_legacy vendor/bin/phpunit --colors=always --exclude-group=none"
]
},
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
}
}
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)
{
$this->filesystem->mirror($endPath, $startPath);
}

public function isAbsolutePath(string $file)
{
$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/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

0 comments on commit bb059fc

Please sign in to comment.