Skip to content

Commit 1851522

Browse files
committed
Update to symfony 6.0 and drop support for symfony 4 and php 7.Update to symfony 6.0 and drop support for symfony 4
1 parent f2ba556 commit 1851522

30 files changed

+168
-158
lines changed

DependencyInjection/Compiler/SetRouterPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
*/
2929
class SetRouterPass implements CompilerPassInterface
3030
{
31-
public function process(ContainerBuilder $container)
31+
public function process(ContainerBuilder $container): void
3232
{
3333
$container->setAlias('router', 'jms_i18n_routing.router')->setPublic(true);
3434

DependencyInjection/Configuration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
final class Configuration implements ConfigurationInterface
2626
{
27-
public function getConfigTreeBuilder()
27+
public function getConfigTreeBuilder(): \Symfony\Component\Config\Definition\Builder\TreeBuilder
2828
{
2929
$tb = new TreeBuilder('jms_i18n_routing');
3030

DependencyInjection/JMSI18nRoutingExtension.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
*/
3131
class JMSI18nRoutingExtension extends Extension
3232
{
33-
public function load(array $configs, ContainerBuilder $container)
33+
public function load(array $configs, ContainerBuilder $container): void
3434
{
3535
$config = $this->processConfiguration(new Configuration, $configs);
3636

@@ -84,7 +84,7 @@ public function load(array $configs, ContainerBuilder $container)
8484
}
8585
}
8686

87-
public function getAlias()
87+
public function getAlias(): string
8888
{
8989
return 'jms_i18n_routing';
9090
}

EventListener/CookieSettingListener.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,18 @@ public function __construct($cookieName, $cookieLifetime, $cookiePath, $cookieDo
3333
$this->cookieHttponly = $cookieHttponly;
3434
}
3535

36-
public function onKernelResponse(ResponseEvent $event)
36+
public function onKernelResponse(ResponseEvent $event): void
3737
{
3838
//Check if the current response contains an error. If it does, do not set the cookie as the Locale may not be properly set
39-
if (HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType() || !($event->getResponse()->isSuccessful() || $event->getResponse()->isRedirection())) {
39+
if (HttpKernelInterface::MAIN_REQUEST !== $event->getRequestType() || !($event->getResponse()->isSuccessful() || $event->getResponse()->isRedirection())) {
4040
return;
4141
}
4242

4343
$request = $event->getRequest();
4444

4545
if (!$request->cookies->has($this->cookieName)
4646
|| $request->cookies->get($this->cookieName) !== $request->getLocale()) {
47-
$event->getResponse()->headers->setCookie(new Cookie($this->cookieName, $request->getLocale(), time() + $this->cookieLifetime, $this->cookiePath, $this->cookieDomain, $this->cookieSecure, $this->cookieHttponly));
47+
$event->getResponse()->headers->setCookie(\Symfony\Component\HttpFoundation\Cookie::create($this->cookieName, $request->getLocale(), time() + $this->cookieLifetime, $this->cookiePath, $this->cookieDomain, $this->cookieSecure, $this->cookieHttponly));
4848
}
4949
}
5050
}

EventListener/LocaleChoosingListener.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ public function __construct($defaultLocale, array $locales, LocaleResolverInterf
4848
$this->localeResolver = $localeResolver;
4949
}
5050

51-
public function onKernelException(ExceptionEvent $event)
51+
public function onKernelException(ExceptionEvent $event): void
5252
{
53-
if (HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()) {
53+
if (HttpKernelInterface::MAIN_REQUEST !== $event->getRequestType()) {
5454
return;
5555
}
5656

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
<?php
2-
3-
/*
4-
* Copyright 2012 Johannes M. Schmitt <schmittjoh@gmail.com>
5-
*
6-
* Licensed under the Apache License, Version 2.0 (the "License");
7-
* you may not use this file except in compliance with the License.
8-
* You may obtain a copy of the License at
9-
*
10-
* http://www.apache.org/licenses/LICENSE-2.0
11-
*
12-
* Unless required by applicable law or agreed to in writing, software
13-
* distributed under the License is distributed on an "AS IS" BASIS,
14-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15-
* See the License for the specific language governing permissions and
16-
* limitations under the License.
17-
*/
18-
2+
3+
/*
4+
* Copyright 2012 Johannes M. Schmitt <schmittjoh@gmail.com>
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
1919
namespace JMS\I18nRoutingBundle\Exception;
2020

2121
class NotAcceptableLanguageException extends NotAcceptableException
@@ -36,8 +36,8 @@ public function getRequestedLanguage()
3636
return $this->requestedLanguage;
3737
}
3838

39-
public function getAvailableLanguages()
39+
public function getAvailableLanguages(): array
4040
{
4141
return $this->availableLanguages;
4242
}
43-
}
43+
}

JMSI18nRoutingBundle.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
use Symfony\Component\DependencyInjection\Compiler\ResolveDefinitionTemplatesPass;
2323
use JMS\I18nRoutingBundle\DependencyInjection\Compiler\SetRouterPass;
2424
use Symfony\Component\DependencyInjection\ContainerBuilder;
25+
use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
2526
use Symfony\Component\HttpKernel\Bundle\Bundle;
2627

2728
/**
@@ -31,13 +32,13 @@
3132
*/
3233
class JMSI18nRoutingBundle extends Bundle
3334
{
34-
public function build(ContainerBuilder $container)
35+
public function build(ContainerBuilder $container): void
3536
{
3637
$container->addCompilerPass(new SetRouterPass());
3738
}
3839

39-
public function getContainerExtension()
40+
public function getContainerExtension(): ?ExtensionInterface
4041
{
4142
return new JMSI18nRoutingExtension();
4243
}
43-
}
44+
}

Router/DefaultLocaleResolver.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function __construct($cookieName, array $hostMap = array())
3131
/**
3232
* {@inheritDoc}
3333
*/
34-
public function resolveLocale(Request $request, array $availableLocales)
34+
public function resolveLocale(Request $request, array $availableLocales): ?string
3535
{
3636
if ($this->hostMap && isset($this->hostMap[$host = $request->getHost()])) {
3737
return $this->hostMap[$host];
@@ -74,4 +74,4 @@ public function resolveLocale(Request $request, array $availableLocales)
7474

7575
return null;
7676
}
77-
}
77+
}

Router/DefaultPatternGenerationStrategy.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
*/
1717
class DefaultPatternGenerationStrategy implements PatternGenerationStrategyInterface
1818
{
19-
const STRATEGY_PREFIX = 'prefix';
20-
const STRATEGY_PREFIX_EXCEPT_DEFAULT = 'prefix_except_default';
21-
const STRATEGY_CUSTOM = 'custom';
19+
public const STRATEGY_PREFIX = 'prefix';
20+
public const STRATEGY_PREFIX_EXCEPT_DEFAULT = 'prefix_except_default';
21+
public const STRATEGY_CUSTOM = 'custom';
2222

2323
private $strategy;
2424
private $translator;
@@ -40,7 +40,7 @@ public function __construct($strategy, TranslatorInterface $translator, array $l
4040
/**
4141
* {@inheritDoc}
4242
*/
43-
public function generateI18nPatterns($routeName, Route $route)
43+
public function generateI18nPatterns($routeName, Route $route): array
4444
{
4545
$patterns = array();
4646
foreach ($route->getOption('i18n_locales') ?: $this->locales as $locale) {
@@ -81,12 +81,12 @@ public function generateI18nPatterns($routeName, Route $route)
8181
/**
8282
* {@inheritDoc}
8383
*/
84-
public function addResources(RouteCollection $i18nCollection)
84+
public function addResources(RouteCollection $i18nRouteCollection): void
8585
{
8686
foreach ($this->locales as $locale) {
8787
if (file_exists($metadata = $this->cacheDir.'/translations/catalogue.'.$locale.'.php.meta')) {
8888
foreach (unserialize(file_get_contents($metadata)) as $resource) {
89-
$i18nCollection->addResource($resource);
89+
$i18nRouteCollection->addResource($resource);
9090
}
9191
}
9292
}

Router/DefaultRouteExclusionStrategy.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
*/
3333
class DefaultRouteExclusionStrategy implements RouteExclusionStrategyInterface
3434
{
35-
public function shouldExcludeRoute($routeName, Route $route)
35+
public function shouldExcludeRoute($routeName, Route $route): bool
3636
{
3737
if ('_' === $routeName[0]) {
3838
return true;

0 commit comments

Comments
 (0)