Skip to content
This repository was archived by the owner on Feb 25, 2026. It is now read-only.

Commit f5fbc9e

Browse files
authored
Merge pull request #281 from biozshock/symfony6
Symfony6
2 parents c7e375a + afa0e1d commit f5fbc9e

20 files changed

Lines changed: 455 additions & 68 deletions

.github/workflows/build.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,21 @@ jobs:
1414
strategy:
1515
fail-fast: true
1616
matrix:
17-
php: [7.1, 7.2, 7.3, 7.4, 8.0]
18-
symfony: [2.8, 3.4, 4.4, 5.2]
17+
php: [7.1, 7.2, 7.3, 7.4, 8.0, 8.1]
18+
symfony: [2.8, 3.4, 4.4, 5.2, 6.0]
1919
exclude:
2020
- php: 7.1
2121
symfony: 5.2
2222
- php: 8.0
2323
symfony: 3.4
24+
- php: 7.1
25+
symfony: 6.0
26+
- php: 7.2
27+
symfony: 6.0
28+
- php: 7.3
29+
symfony: 6.0
30+
- php: 7.4
31+
symfony: 6.0
2432
steps:
2533
- name: Checkout
2634
uses: actions/checkout@v2

composer.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@
1717
"require": {
1818
"php": "^7.1 || ^8.0",
1919
"google/recaptcha": "^1.1",
20-
"symfony/form": "^2.8 || ^3.0 || ^4.0 || ^5.0",
21-
"symfony/framework-bundle": "^2.8 || ^3.0 || ^4.0 || ^5.0",
22-
"symfony/security-bundle": "^2.8 || ^3.0 || ^4.0 || ^5.0",
23-
"symfony/validator": "^2.8 || ^3.0 || ^4.0 || ^5.0",
24-
"symfony/yaml": "^2.8 || ^3.0 || ^4.0 || ^5.0",
20+
"symfony/form": "^2.8 || ^3.0 || ^4.0 || ^5.0 || ^6.0",
21+
"symfony/framework-bundle": "^2.8 || ^3.0 || ^4.0 || ^5.0 || ^6.0",
22+
"symfony/security-bundle": "^2.8 || ^3.0 || ^4.0 || ^5.0 || ^6.0",
23+
"symfony/validator": "^2.8 || ^3.0 || ^4.0 || ^5.0 || ^6.0",
24+
"symfony/yaml": "^2.8 || ^3.0 || ^4.0 || ^5.0 || ^6.0",
2525
"twig/twig": "^1.40 || ^2.9 || ^3.0"
2626
},
2727
"require-dev": {
28-
"phpunit/phpunit": "^7 || ^8"
28+
"phpunit/phpunit": "^7 || ^8 || ^9.5"
2929
},
3030
"autoload": {
3131
"psr-4": {

src/DependencyInjection/Configuration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class Configuration implements ConfigurationInterface
1414
/**
1515
* {@inheritdoc}
1616
*/
17-
public function getConfigTreeBuilder()
17+
public function getConfigTreeBuilder(): TreeBuilder
1818
{
1919
$treeBuilder = new TreeBuilder('ewz_recaptcha');
2020

src/DependencyInjection/EWZRecaptchaExtension.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class EWZRecaptchaExtension extends Extension
1919
/**
2020
* {@inheritdoc}
2121
*/
22-
public function load(array $configs, ContainerBuilder $container)
22+
public function load(array $configs, ContainerBuilder $container): void
2323
{
2424
$configuration = new Configuration();
2525
$config = $this->processConfiguration($configuration, $configs);
@@ -38,7 +38,7 @@ public function load(array $configs, ContainerBuilder $container)
3838
$recaptchaService->replaceArgument(1, new Reference('ewz_recaptcha.extension.recaptcha.request_method.proxy_post'));
3939
}
4040

41-
if (3 == $config['version']) {
41+
if (3 === $config['version']) {
4242
$container->register('ewz_recaptcha.form_builder_factory', EWZRecaptchaV3FormBuilderFactory::class)
4343
->addArgument(new Reference('form.factory'));
4444
} else {
@@ -61,13 +61,13 @@ public function load(array $configs, ContainerBuilder $container)
6161
*
6262
* @param ContainerBuilder $container
6363
*/
64-
protected function registerWidget(ContainerBuilder $container, $version = 2)
64+
protected function registerWidget(ContainerBuilder $container, int $version = 2): void
6565
{
6666
$templatingEngines = $container->hasParameter('templating.engines')
6767
? $container->getParameter('templating.engines')
6868
: array('twig');
6969

70-
if (in_array('php', $templatingEngines)) {
70+
if (in_array('php', $templatingEngines, true)) {
7171
$formResource = 'EWZRecaptchaBundle:Form';
7272

7373
$container->setParameter('templating.helper.form.resources', array_merge(
@@ -76,7 +76,7 @@ protected function registerWidget(ContainerBuilder $container, $version = 2)
7676
));
7777
}
7878

79-
if (in_array('twig', $templatingEngines)) {
79+
if (in_array('twig', $templatingEngines, true)) {
8080
$formResource = '@EWZRecaptcha/Form/ewz_recaptcha_widget.html.twig';
8181
if (3 === $version) {
8282
$formResource = '@EWZRecaptcha/Form/v3/ewz_recaptcha_widget.html.twig';

src/Extension/ReCaptcha/RequestMethod/Post.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class Post implements RequestMethod
3333
* @param string $recaptchaVerifyServer
3434
* @param int|null $timeout
3535
*/
36-
public function __construct($recaptchaVerifyServer, $timeout)
36+
public function __construct(string $recaptchaVerifyServer, ?int $timeout)
3737
{
3838
$this->recaptchaVerifyUrl = ($recaptchaVerifyServer ?: 'https://www.google.com').'/recaptcha/api/siteverify';
3939
$this->timeout = $timeout;
@@ -47,7 +47,7 @@ public function __construct($recaptchaVerifyServer, $timeout)
4747
*
4848
* @return string Body of the reCAPTCHA response
4949
*/
50-
public function submit(RequestParameters $params)
50+
public function submit(RequestParameters $params): string
5151
{
5252
$cacheKey = $params->toQueryString();
5353
if (isset($this->cache[$cacheKey])) {

src/Extension/ReCaptcha/RequestMethod/ProxyPost.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class ProxyPost implements RequestMethod
4141
* @param string $recaptchaVerifyServer
4242
* @param int|null $timeout
4343
*/
44-
public function __construct(array $httpProxy, $recaptchaVerifyServer, $timeout)
44+
public function __construct(array $httpProxy, string $recaptchaVerifyServer, ?int $timeout)
4545
{
4646
$this->httpProxy = $httpProxy;
4747
$this->recaptchaVerifyUrl = ($recaptchaVerifyServer ?: 'https://www.google.com').'/recaptcha/api/siteverify';
@@ -56,7 +56,7 @@ public function __construct(array $httpProxy, $recaptchaVerifyServer, $timeout)
5656
*
5757
* @return string Body of the reCAPTCHA response
5858
*/
59-
public function submit(RequestParameters $params)
59+
public function submit(RequestParameters $params): string
6060
{
6161
$cacheKey = $params->toQueryString();
6262
if (isset($this->cache[$cacheKey])) {

src/Form/Type/AbstractEWZRecaptchaType.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ abstract class AbstractEWZRecaptchaType extends AbstractType
3838

3939
/**
4040
* @param string $publicKey Recaptcha public key
41-
* @param bool $enabled Recaptcha status
41+
* @param bool $enabled Recaptcha status
4242
* @param string $apiHost Api host
4343
*/
44-
public function __construct($publicKey, $enabled, $apiHost = 'www.google.com')
44+
public function __construct(string $publicKey, bool $enabled, string $apiHost = 'www.google.com')
4545
{
4646
$this->publicKey = $publicKey;
4747
$this->enabled = $enabled;
@@ -52,7 +52,7 @@ public function __construct($publicKey, $enabled, $apiHost = 'www.google.com')
5252
/**
5353
* {@inheritdoc}
5454
*/
55-
public function buildView(FormView $view, FormInterface $form, array $options)
55+
public function buildView(FormView $view, FormInterface $form, array $options): void
5656
{
5757
$view->vars = array_replace($view->vars, array(
5858
'ewz_recaptcha_enabled' => $this->enabled,
@@ -71,7 +71,7 @@ public function buildView(FormView $view, FormInterface $form, array $options)
7171
/**
7272
* {@inheritdoc}
7373
*/
74-
public function getBlockPrefix()
74+
public function getBlockPrefix(): string
7575
{
7676
return 'ewz_recaptcha';
7777
}
@@ -81,7 +81,7 @@ public function getBlockPrefix()
8181
*
8282
* @return string The javascript source URL
8383
*/
84-
public function getPublicKey()
84+
public function getPublicKey(): string
8585
{
8686
return $this->publicKey;
8787
}
@@ -91,10 +91,10 @@ public function getPublicKey()
9191
*
9292
* @return string The hostname for API
9393
*/
94-
public function getApiHost()
94+
public function getApiHost(): string
9595
{
9696
return $this->apiHost;
9797
}
9898

99-
abstract protected function addCustomVars(FormView $view, FormInterface $form, array $options);
99+
abstract protected function addCustomVars(FormView $view, FormInterface $form, array $options): void;
100100
}

src/Form/Type/EWZRecaptchaType.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class EWZRecaptchaType extends AbstractEWZRecaptchaType
2929
* @param bool $ajax Ajax status
3030
* @param LocaleResolver $localeResolver
3131
*/
32-
public function __construct($publicKey, $enabled, $ajax, LocaleResolver $localeResolver, $apiHost = 'www.google.com')
32+
public function __construct(string $publicKey, bool $enabled, bool $ajax, LocaleResolver $localeResolver, string $apiHost = 'www.google.com')
3333
{
3434
parent::__construct($publicKey, $enabled, $apiHost);
3535

@@ -40,7 +40,7 @@ public function __construct($publicKey, $enabled, $ajax, LocaleResolver $localeR
4040
/**
4141
* {@inheritdoc}
4242
*/
43-
public function configureOptions(OptionsResolver $resolver)
43+
public function configureOptions(OptionsResolver $resolver): void
4444
{
4545
$resolver->setDefaults(array(
4646
'compound' => false,
@@ -67,7 +67,7 @@ public function configureOptions(OptionsResolver $resolver)
6767
/**
6868
* {@inheritdoc}
6969
*/
70-
public function getParent()
70+
public function getParent(): string
7171
{
7272
return TextType::class;
7373
}
@@ -87,7 +87,7 @@ public function getScriptURL($key)
8787
/**
8888
* {@inheritdoc}
8989
*/
90-
protected function addCustomVars(FormView $view, FormInterface $form, array $options)
90+
protected function addCustomVars(FormView $view, FormInterface $form, array $options): void
9191
{
9292
$view->vars = array_replace($view->vars, array(
9393
'ewz_recaptcha_ajax' => $this->ajax,

src/Form/Type/EWZRecaptchaV3Type.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ class EWZRecaptchaV3Type extends AbstractEWZRecaptchaType
1818
* EWZRecaptchaV3Type constructor.
1919
*
2020
* @param string $publicKey
21-
* @param bool $enabled
21+
* @param bool $enabled
2222
* @param bool $hideBadge
2323
* @param string $apiHost
2424
*/
25-
public function __construct($publicKey, $enabled, $hideBadge, $apiHost = 'www.google.com')
25+
public function __construct(string $publicKey, bool $enabled, bool $hideBadge, string $apiHost = 'www.google.com')
2626
{
2727
parent::__construct($publicKey, $enabled, $apiHost);
2828

@@ -32,7 +32,7 @@ public function __construct($publicKey, $enabled, $hideBadge, $apiHost = 'www.go
3232
/**
3333
* {@inheritdoc}
3434
*/
35-
public function configureOptions(OptionsResolver $resolver)
35+
public function configureOptions(OptionsResolver $resolver): void
3636
{
3737
$resolver->setDefaults([
3838
'label' => false,
@@ -49,20 +49,20 @@ public function configureOptions(OptionsResolver $resolver)
4949
/**
5050
* {@inheritdoc}
5151
*/
52-
public function getParent()
52+
public function getParent(): string
5353
{
5454
return HiddenType::class;
5555
}
5656

5757
/**
5858
* {@inheritdoc}
5959
*/
60-
protected function addCustomVars(FormView $view, FormInterface $form, array $options)
60+
protected function addCustomVars(FormView $view, FormInterface $form, array $options): void
6161
{
6262
$view->vars = array_replace($view->vars, [
6363
'ewz_recaptcha_hide_badge' => $this->hideBadge,
64-
'script_nonce_csp' => isset($options['script_nonce_csp']) ? $options['script_nonce_csp'] : '',
65-
'action_name' => isset($options['action_name']) ? $options['action_name'] : '',
64+
'script_nonce_csp' => $options['script_nonce_csp'] ?? '',
65+
'action_name' => $options['action_name'] ?? '',
6666
]);
6767
}
6868
}

src/Locale/LocaleResolver.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ final class LocaleResolver
2323
* @param bool $useLocaleFromRequest
2424
* @param RequestStack $requestStack
2525
*/
26-
public function __construct($defaultLocale, $useLocaleFromRequest, RequestStack $requestStack)
26+
public function __construct(string $defaultLocale, bool $useLocaleFromRequest, RequestStack $requestStack)
2727
{
2828
$this->defaultLocale = $defaultLocale;
2929
$this->useLocaleFromRequest = $useLocaleFromRequest;
@@ -33,7 +33,7 @@ public function __construct($defaultLocale, $useLocaleFromRequest, RequestStack
3333
/**
3434
* @return string The resolved locale key, depending on configuration
3535
*/
36-
public function resolve()
36+
public function resolve(): string
3737
{
3838
return $this->useLocaleFromRequest
3939
? $this->requestStack->getCurrentRequest()->getLocale()

0 commit comments

Comments
 (0)