Skip to content

Commit dbfd4e9

Browse files
committed
Code: apple codesniffer
1 parent 7b8b9af commit dbfd4e9

10 files changed

Lines changed: 41 additions & 49 deletions

‎ruleset.xml‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@
1717
</properties>
1818
</rule>
1919

20+
<rule ref="Squiz.Classes.ClassFileName.NoMatch">
21+
<exclude-pattern>tests</exclude-pattern>
22+
</rule>
23+
24+
<rule ref="SlevomatCodingStandard.Files.TypeNameMatchesFileName.NoMatchBetweenTypeNameAndFileName">
25+
<exclude-pattern>tests</exclude-pattern>
26+
</rule>
27+
2028
<!-- Excludes -->
2129
<exclude-pattern>/tests/tmp</exclude-pattern>
2230
</ruleset>

‎src/Forms/InvisibleReCaptchaField.php‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace Contributte\ReCaptcha\Forms;
44

5-
use Contributte\ReCaptcha\Exceptions\InvalidScoreException;
65
use Contributte\ReCaptcha\ReCaptchaProvider;
76
use Nette\Forms\Controls\HiddenField;
87
use Nette\Forms\Form;

‎src/ReCaptchaProvider.php‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,12 @@ class ReCaptchaProvider
2828

2929
private string $secretKey;
3030

31-
// Range 0..1 (1.0 is very likely a good interaction, 0.0 is very likely a bot)
31+
/**
32+
* Range 0..1 (1.0 is very likely a good interaction, 0.0 is very likely a bot)
33+
*/
3234
private float $minimalScore;
3335

34-
public function __construct(string $siteKey, string $secretKey, float $minimalScore)
36+
public function __construct(string $siteKey, string $secretKey, float $minimalScore = 0)
3537
{
3638
$this->siteKey = $siteKey;
3739
$this->secretKey = $secretKey;

‎tests/Cases/DI/ReCaptchaExtension.phpt‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ use Tester\Assert;
1313

1414
require __DIR__ . '/../../bootstrap.php';
1515

16-
Toolkit::test(function () {
16+
Toolkit::test(function (): void {
1717
$loader = new ContainerLoader(Environment::getTestDir());
18-
$class = $loader->load(function (Compiler $compiler) {
18+
$class = $loader->load(function (Compiler $compiler): void {
1919
$compiler->addExtension('captcha', new ReCaptchaExtension());
2020

2121
$compiler->addConfig([
@@ -31,10 +31,10 @@ Toolkit::test(function () {
3131
Assert::equal('foobar', $container->getByType(ReCaptchaProvider::class)->getSiteKey());
3232
});
3333

34-
Toolkit::test(function () {
35-
Assert::exception(function () {
34+
Toolkit::test(function (): void {
35+
Assert::exception(function (): void {
3636
$loader = new ContainerLoader(Environment::getTestDir());
37-
$loader->load(function (Compiler $compiler) {
37+
$loader->load(function (Compiler $compiler): void {
3838
$compiler->addExtension('captcha', new ReCaptchaExtension());
3939
$compiler->addConfig([
4040
'captcha' => [

‎tests/Cases/Forms/InvisibleReCaptchField.phpt‎

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22

33
namespace Tests\Cases\Forms;
44

5-
/**
6-
* Test: ReCaptchaField
7-
*/
8-
95
use Contributte\ReCaptcha\Forms\InvisibleReCaptchaField;
106
use Contributte\ReCaptcha\ReCaptchaProvider;
117
use Contributte\Tester\Toolkit;
@@ -19,17 +15,14 @@ require __DIR__ . '/../../bootstrap.php';
1915
final class FormMock extends Form
2016
{
2117

22-
/**
23-
* @return mixed
24-
*/
25-
public function getHttpData(?int $type = null, ?string $htmlName = null)
18+
public function getHttpData(?int $type = null, ?string $htmlName = null): mixed
2619
{
2720
return $htmlName;
2821
}
2922

3023
}
3124

32-
Toolkit::test(function () {
25+
Toolkit::test(function (): void {
3326
$field = new InvisibleReCaptchaField(new ReCaptchaProvider('foobar', 'secret'));
3427
Assert::equal(['g-recaptcha' => true], $field->getControlPrototype()->getClass());
3528

@@ -40,7 +33,7 @@ Toolkit::test(function () {
4033
Assert::equal('foobar', $field->getControlPrototype()->getClass());
4134
});
4235

43-
Toolkit::test(function () {
36+
Toolkit::test(function (): void {
4437
$form = new FormMock('form');
4538

4639
$fieldName = 'captcha';
@@ -51,7 +44,7 @@ Toolkit::test(function () {
5144
Assert::equal(sprintf(BaseControl::$idMask, $form->getName() . '-' . $fieldName), $field->getHtmlId());
5245
});
5346

54-
Toolkit::test(function () {
47+
Toolkit::test(function (): void {
5548
$form = new FormMock('form');
5649

5750
$fieldName = 'captcha';
@@ -62,7 +55,7 @@ Toolkit::test(function () {
6255
Assert::equal($key, $field->getControl()->{'data-sitekey'});
6356
});
6457

65-
Toolkit::test(function () {
58+
Toolkit::test(function (): void {
6659
$form = new FormMock('form');
6760

6861
$fieldName = 'captcha';

‎tests/Cases/Forms/InvisibleReCaptchaBinding.phpt‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use Tester\Assert;
1111

1212
require __DIR__ . '/../../bootstrap.php';
1313

14-
Toolkit::test(function () {
14+
Toolkit::test(function (): void {
1515
$provider = new ReCaptchaProvider('foo', 'bar');
1616
InvisibleReCaptchaBinding::bind($provider);
1717

@@ -24,7 +24,7 @@ Toolkit::test(function () {
2424
Assert::same('foo', $recaptcha->getControl()->{'data-sitekey'});
2525
});
2626

27-
Toolkit::test(function () {
27+
Toolkit::test(function (): void {
2828
$provider = new ReCaptchaProvider('foo', 'bar');
2929
InvisibleReCaptchaBinding::bind($provider);
3030

@@ -33,7 +33,7 @@ Toolkit::test(function () {
3333
Assert::false($recaptcha->isRequired());
3434
});
3535

36-
Toolkit::test(function () {
36+
Toolkit::test(function (): void {
3737
$provider = new ReCaptchaProvider('foo', 'bar');
3838
InvisibleReCaptchaBinding::bind($provider);
3939

‎tests/Cases/Forms/ReCaptchField.phpt‎

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,14 @@ require __DIR__ . '/../../bootstrap.php';
1515
final class FormMock extends Form
1616
{
1717

18-
/**
19-
* @return mixed
20-
*/
21-
public function getHttpData(?int $type = null, ?string $htmlName = null)
18+
public function getHttpData(?int $type = null, ?string $htmlName = null): mixed
2219
{
2320
return $htmlName;
2421
}
2522

2623
}
2724

28-
Toolkit::test(function () {
25+
Toolkit::test(function (): void {
2926
$field = new ReCaptchaField(new ReCaptchaProvider('foobar', 'secret'));
3027
Assert::equal(['g-recaptcha' => true], $field->getControlPrototype()->getClass());
3128

@@ -36,7 +33,7 @@ Toolkit::test(function () {
3633
Assert::equal('foobar', $field->getControlPrototype()->getClass());
3734
});
3835

39-
Toolkit::test(function () {
36+
Toolkit::test(function (): void {
4037
$form = new FormMock('form');
4138

4239
$fieldName = 'captcha';
@@ -48,7 +45,7 @@ Toolkit::test(function () {
4845
Assert::equal(sprintf(BaseControl::$idMask, $form->getName() . '-' . $fieldName), $field->getHtmlId());
4946
});
5047

51-
Toolkit::test(function () {
48+
Toolkit::test(function (): void {
5249
$form = new FormMock('form');
5350

5451
$fieldName = 'captcha';
@@ -59,7 +56,7 @@ Toolkit::test(function () {
5956
Assert::equal($key, $field->getControl()->{'data-sitekey'});
6057
});
6158

62-
Toolkit::test(function () {
59+
Toolkit::test(function (): void {
6360
$form = new FormMock('form');
6461

6562
$fieldName = 'captcha';

‎tests/Cases/Forms/ReCaptchaBinding.phpt‎

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22

33
namespace Tests\Cases\Forms;
44

5-
/**
6-
* Test: ReCaptchaBinding
7-
*/
8-
95
use Contributte\ReCaptcha\Forms\ReCaptchaBinding;
106
use Contributte\ReCaptcha\Forms\ReCaptchaField;
117
use Contributte\ReCaptcha\ReCaptchaProvider;
@@ -15,7 +11,7 @@ use Tester\Assert;
1511

1612
require __DIR__ . '/../../bootstrap.php';
1713

18-
Toolkit::test(function () {
14+
Toolkit::test(function (): void {
1915
$provider = new ReCaptchaProvider('foo', 'bar');
2016
ReCaptchaBinding::bind($provider);
2117

@@ -29,7 +25,7 @@ Toolkit::test(function () {
2925
Assert::same('foo', $recaptcha->getControl()->{'data-sitekey'});
3026
});
3127

32-
Toolkit::test(function () {
28+
Toolkit::test(function (): void {
3329
$provider = new ReCaptchaProvider('foo', 'bar');
3430
ReCaptchaBinding::bind($provider);
3531

@@ -38,7 +34,7 @@ Toolkit::test(function () {
3834
Assert::same('My label', $recaptcha->getLabel()->getText());
3935
});
4036

41-
Toolkit::test(function () {
37+
Toolkit::test(function (): void {
4238
$provider = new ReCaptchaProvider('foo', 'bar');
4339
ReCaptchaBinding::bind($provider);
4440

@@ -47,7 +43,7 @@ Toolkit::test(function () {
4743
Assert::false($recaptcha->isRequired());
4844
});
4945

50-
Toolkit::test(function () {
46+
Toolkit::test(function (): void {
5147
$provider = new ReCaptchaProvider('foo', 'bar');
5248
ReCaptchaBinding::bind($provider);
5349

‎tests/Cases/ReCaptchResponse.phpt‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@ use Tester\Assert;
88

99
require __DIR__ . '/../bootstrap.php';
1010

11-
Toolkit::test(function () {
11+
Toolkit::test(function (): void {
1212
$response = new ReCaptchaResponse(true);
1313
Assert::true($response->isSuccess());
1414
});
1515

16-
Toolkit::test(function () {
16+
Toolkit::test(function (): void {
1717
$response = new ReCaptchaResponse(true);
1818
Assert::equal('1', (string) $response);
1919
});
2020

21-
Toolkit::test(function () {
21+
Toolkit::test(function (): void {
2222
$error = 'Some error';
2323
$response = new ReCaptchaResponse(false, $error);
2424
Assert::false($response->isSuccess());

‎tests/Cases/ReCaptchaProvider.phpt‎

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,14 @@ require __DIR__ . '/../bootstrap.php';
1313
final class ControlMock extends BaseControl
1414
{
1515

16-
/**
17-
* @return string
18-
*/
19-
public function getValue()
16+
public function getValue(): string
2017
{
2118
return 'test';
2219
}
2320

2421
}
2522

26-
Toolkit::test(function () {
23+
Toolkit::test(function (): void {
2724
$key = 'key';
2825
$validator = new ReCaptchaProvider($key, 'secret');
2926

@@ -34,14 +31,14 @@ Toolkit::test(function () {
3431
Assert::notEqual(null, $response->getError());
3532
});
3633

37-
Toolkit::test(function () {
34+
Toolkit::test(function (): void {
3835
$key = 'key';
3936
$validator = new ReCaptchaProvider($key, 'secret');
4037

4138
Assert::false($validator->validateControl(new ControlMock()));
4239
});
4340

44-
Toolkit::test(function () {
41+
Toolkit::test(function (): void {
4542
$key = 'key';
4643
$validator = new ReCaptchaProvider($key, 'secret');
4744

0 commit comments

Comments
 (0)