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

Commit 80730c4

Browse files
committed
Add types to classes that are not usually BC.
1 parent 02d6e91 commit 80730c4

9 files changed

Lines changed: 43 additions & 43 deletions

File tree

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/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
}

tests/DependencyInjection/EWZRecaptchaExtensionTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ protected function tearDown(): void
2121
$this->configuration = null;
2222
}
2323

24-
public function testSimpleConfiguration()
24+
public function testSimpleConfiguration(): void
2525
{
2626
$this->configuration = new ContainerBuilder();
2727
$loader = new EWZRecaptchaExtension();
@@ -57,7 +57,7 @@ public function testSimpleConfiguration()
5757
);
5858
}
5959

60-
public function testSimpleV3Configuration()
60+
public function testSimpleV3Configuration(): void
6161
{
6262
$this->configuration = new ContainerBuilder();
6363
$loader = new EWZRecaptchaExtension();
@@ -74,7 +74,7 @@ public function testSimpleV3Configuration()
7474

7575
}
7676

77-
public function testFullConfiguration()
77+
public function testFullConfiguration(): void
7878
{
7979
$this->configuration = new ContainerBuilder();
8080
$loader = new EWZRecaptchaExtension();
@@ -145,22 +145,22 @@ private function getFullConfig()
145145
return $parser->parse($yaml);
146146
}
147147

148-
private function assertParameter($value, $key)
148+
private function assertParameter($value, $key): void
149149
{
150150
$this->assertSame($value, $this->configuration->getParameter($key), sprintf('%s parameter is correct', $key));
151151
}
152152

153-
private function assertHasDefinition($id)
153+
private function assertHasDefinition($id): void
154154
{
155155
$this->assertTrue(($this->configuration->hasDefinition($id) ?: $this->configuration->hasAlias($id)));
156156
}
157157

158-
private function assertNotHasDefinition($id)
158+
private function assertNotHasDefinition($id): void
159159
{
160160
$this->assertFalse(($this->configuration->hasDefinition($id) ?: $this->configuration->hasAlias($id)));
161161
}
162162

163-
private function assertDefinitionHasReferenceArgument($id, $index, $expectedArgumentValue)
163+
private function assertDefinitionHasReferenceArgument($id, $index, $expectedArgumentValue): void
164164
{
165165
$definition = $this->configuration->getDefinition($id);
166166
$argumentValue = $definition->getArgument($index);

tests/Form/Type/EWZRecaptchaTypeTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ protected function setUp(): void
2626
/**
2727
* @test
2828
*/
29-
public function buildView()
29+
public function buildView(): void
3030
{
3131
$view = new FormView();
3232

@@ -45,23 +45,23 @@ public function buildView()
4545
/**
4646
* @test
4747
*/
48-
public function getParent()
48+
public function getParent(): void
4949
{
5050
$this->assertSame(TextType::class, $this->type->getParent());
5151
}
5252

5353
/**
5454
* @test
5555
*/
56-
public function getPublicKey()
56+
public function getPublicKey(): void
5757
{
5858
$this->assertSame('key', $this->type->getPublicKey());
5959
}
6060

6161
/**
6262
* @test
6363
*/
64-
public function configureOptions()
64+
public function configureOptions(): void
6565
{
6666
$optionsResolver = new OptionsResolver();
6767

@@ -96,7 +96,7 @@ public function configureOptions()
9696
/**
9797
* @test
9898
*/
99-
public function getBlockPrefix()
99+
public function getBlockPrefix(): void
100100
{
101101
$this->assertEquals('ewz_recaptcha', $this->type->getBlockPrefix());
102102
}

tests/Form/Type/EWZRecaptchaV3TypeTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ protected function setUp(): void
2525
/**
2626
* @test
2727
*/
28-
public function buildView()
28+
public function buildView(): void
2929
{
3030
$view = new FormView();
3131

@@ -44,23 +44,23 @@ public function buildView()
4444
/**
4545
* @test
4646
*/
47-
public function getParent()
47+
public function getParent(): void
4848
{
4949
$this->assertSame(HiddenType::class, $this->type->getParent());
5050
}
5151

5252
/**
5353
* @test
5454
*/
55-
public function getPublicKey()
55+
public function getPublicKey(): void
5656
{
5757
$this->assertSame('key', $this->type->getPublicKey());
5858
}
5959

6060
/**
6161
* @test
6262
*/
63-
public function configureOptions()
63+
public function configureOptions(): void
6464
{
6565
$optionsResolver = new OptionsResolver();
6666

@@ -82,7 +82,7 @@ public function configureOptions()
8282
/**
8383
* @test
8484
*/
85-
public function getBlockPrefix()
85+
public function getBlockPrefix(): void
8686
{
8787
$this->assertEquals('ewz_recaptcha', $this->type->getBlockPrefix());
8888
}

tests/Locale/LocaleResolverTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class LocaleResolverTest extends TestCase
1212
/**
1313
* @test
1414
*/
15-
public function resolveWithLocaleFromRequest()
15+
public function resolveWithLocaleFromRequest(): void
1616
{
1717
$request = $this->createMock(Request::class);
1818
$request->expects($this->once())->method('getLocale');
@@ -30,7 +30,7 @@ public function resolveWithLocaleFromRequest()
3030
/**
3131
* @test
3232
*/
33-
public function resolveWithDefaultLocale()
33+
public function resolveWithDefaultLocale(): void
3434
{
3535
$requestStack = $this->createMock(RequestStack::class);
3636
$requestStack

0 commit comments

Comments
 (0)