Skip to content

Commit 4181c38

Browse files
ISSUE-193: Upgraded to PHP 7.2
1 parent 615fdbc commit 4181c38

13 files changed

+80
-114
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
/.phpunit.result.cache
2+
/build/
23
/composer.lock
34
/vendor/

src/Bsn.php

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
* SOFTWARE.
1919
*/
2020

21+
declare(strict_types=1);
22+
2123
namespace DarkWebDesign\SymfonyAddonConstraints;
2224

2325
use Symfony\Component\Validator\Constraint;

src/BsnValidator.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
* SOFTWARE.
1919
*/
2020

21+
declare(strict_types=1);
22+
2123
namespace DarkWebDesign\SymfonyAddonConstraints;
2224

2325
use Symfony\Component\Validator\Constraint;
@@ -47,11 +49,10 @@ class BsnValidator extends ConstraintValidator
4749
* Checks if the value is valid.
4850
*
4951
* @param mixed $value
50-
* @param \Symfony\Component\Validator\Constraint $constraint
5152
*
5253
* @throws \Symfony\Component\Validator\Exception\UnexpectedTypeException
5354
*/
54-
public function validate($value, Constraint $constraint)
55+
public function validate($value, Constraint $constraint): void
5556
{
5657
if (!$constraint instanceof Bsn) {
5758
throw new UnexpectedTypeException($constraint, Bsn::class);

src/Collection.php

+4-6
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
* SOFTWARE.
1919
*/
2020

21+
declare(strict_types=1);
22+
2123
namespace DarkWebDesign\SymfonyAddonConstraints;
2224

2325
use Symfony\Component\Validator\Constraint;
@@ -77,20 +79,16 @@ public function __construct($options = null)
7779

7880
/**
7981
* Returns the name of the default option.
80-
*
81-
* @return string
8282
*/
83-
public function getDefaultOption()
83+
public function getDefaultOption(): string
8484
{
8585
return 'constraints';
8686
}
8787

8888
/**
8989
* Returns the name of the required options.
90-
*
91-
* @return array
9290
*/
93-
public function getRequiredOptions()
91+
public function getRequiredOptions(): array
9492
{
9593
return ['constraints'];
9694
}

src/CollectionValidator.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
* SOFTWARE.
1919
*/
2020

21+
declare(strict_types=1);
22+
2123
namespace DarkWebDesign\SymfonyAddonConstraints;
2224

2325
use Symfony\Component\Validator\Constraint;
@@ -37,11 +39,10 @@ class CollectionValidator extends ConstraintValidator
3739
* Checks if the value is valid.
3840
*
3941
* @param mixed $value
40-
* @param \Symfony\Component\Validator\Constraint $constraint
4142
*
4243
* @throws \Symfony\Component\Validator\Exception\UnexpectedTypeException
4344
*/
44-
public function validate($value, Constraint $constraint)
45+
public function validate($value, Constraint $constraint): void
4546
{
4647
if (!$constraint instanceof Collection) {
4748
throw new UnexpectedTypeException($constraint, Collection::class);

src/Json.php

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
* SOFTWARE.
1919
*/
2020

21+
declare(strict_types=1);
22+
2123
namespace DarkWebDesign\SymfonyAddonConstraints;
2224

2325
use Symfony\Component\Validator\Constraint;

src/JsonValidator.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,10 @@ class JsonValidator extends ConstraintValidator
3737
* Checks if the value is valid.
3838
*
3939
* @param mixed $value
40-
* @param \Symfony\Component\Validator\Constraint $constraint
4140
*
4241
* @throws \Symfony\Component\Validator\Exception\UnexpectedTypeException
4342
*/
44-
public function validate($value, Constraint $constraint)
43+
public function validate($value, Constraint $constraint): void
4544
{
4645
if (!$constraint instanceof Json) {
4746
throw new UnexpectedTypeException($constraint, Json::class);

tests/BsnValidatorTest.php

+19-29
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
* SOFTWARE.
1919
*/
2020

21+
declare(strict_types=1);
22+
2123
namespace DarkWebDesign\SymfonyAddonConstraints\Tests;
2224

2325
use DarkWebDesign\SymfonyAddonConstraints\Bsn;
@@ -29,27 +31,24 @@
2931

3032
class BsnValidatorTest extends ConstraintValidatorTestCase
3133
{
32-
/**
33-
* @return \DarkWebDesign\SymfonyAddonConstraints\BsnValidator
34-
*/
35-
protected function createValidator()
34+
protected function createValidator(): BsnValidator
3635
{
3736
return new BsnValidator();
3837
}
3938

4039
/**
41-
* @param string $bsn
40+
* @param mixed $value
4241
*
4342
* @dataProvider providerValidBsn
4443
*/
45-
public function testValidate($bsn)
44+
public function testValidate($value): void
4645
{
47-
$this->validator->validate($bsn, new Bsn());
46+
$this->validator->validate($value, new Bsn());
4847

4948
$this->assertNoViolation();
5049
}
5150

52-
public function testValidateInvalidConstraint()
51+
public function testValidateInvalidConstraint(): void
5352
{
5453
$this->expectException(UnexpectedTypeException::class);
5554

@@ -58,54 +57,51 @@ public function testValidateInvalidConstraint()
5857
$this->assertNoViolation();
5958
}
6059

61-
public function testValidateNull()
60+
public function testValidateNull(): void
6261
{
6362
$this->validator->validate(null, new Bsn());
6463

6564
$this->assertNoViolation();
6665
}
6766

68-
public function testValidateEmptyString()
67+
public function testValidateEmptyString(): void
6968
{
7069
$this->validator->validate('', new Bsn());
7170

7271
$this->assertNoViolation();
7372
}
7473

7574
/**
76-
* @param string $bsn
75+
* @param mixed $value
7776
*
7877
* @dataProvider providerNoScalar
7978
*/
80-
public function testValidateNoScalar($bsn)
79+
public function testValidateNoScalar($value): void
8180
{
8281
$this->expectException(UnexpectedTypeException::class);
8382

84-
$this->validator->validate($bsn, new Bsn());
83+
$this->validator->validate($value, new Bsn());
8584

8685
$this->assertNoViolation();
8786
}
8887

8988
/**
90-
* @param string $bsn
89+
* @param mixed $value
9190
*
9291
* @dataProvider providerInvalidBsn
9392
*/
94-
public function testValidateViolation($bsn)
93+
public function testValidateViolation($value): void
9594
{
9695
$constraint = new Bsn();
9796

98-
$this->validator->validate($bsn, $constraint);
97+
$this->validator->validate($value, $constraint);
9998

10099
$this->buildViolation($constraint->message)
101-
->setParameter('{{ value }}', '"' . $bsn . '"')
100+
->setParameter('{{ value }}', '"' . $value . '"')
102101
->assertRaised();
103102
}
104103

105-
/**
106-
* @return array[]
107-
*/
108-
public function providerValidBsn()
104+
public function providerValidBsn(): array
109105
{
110106
return [
111107
'valid1' => ['111222333'],
@@ -114,10 +110,7 @@ public function providerValidBsn()
114110
];
115111
}
116112

117-
/**
118-
* @return array[]
119-
*/
120-
public function providerNoScalar()
113+
public function providerNoScalar(): array
121114
{
122115
return [
123116
'array' => [['foo', 'bar']],
@@ -127,10 +120,7 @@ public function providerNoScalar()
127120
];
128121
}
129122

130-
/**
131-
* @return array[]
132-
*/
133-
public function providerInvalidBsn()
123+
public function providerInvalidBsn(): array
134124
{
135125
return [
136126
'zeros' => ['000000000'],

tests/CollectionTest.php

+9-10
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
* SOFTWARE.
1919
*/
2020

21+
declare(strict_types=1);
22+
2123
namespace DarkWebDesign\SymfonyAddonConstraints\Tests;
2224

2325
use DarkWebDesign\SymfonyAddonConstraints\Collection;
@@ -28,7 +30,7 @@
2830

2931
class CollectionTest extends TestCase
3032
{
31-
public function testConstruct()
33+
public function testConstruct(): void
3234
{
3335
new Collection([
3436
'constraints' => [
@@ -39,7 +41,7 @@ public function testConstruct()
3941
$this->assertTrue(true);
4042
}
4143

42-
public function testConstructDefaultOption()
44+
public function testConstructDefaultOption(): void
4345
{
4446
new Collection([
4547
new Assert\NotBlank(),
@@ -48,7 +50,7 @@ public function testConstructDefaultOption()
4850
$this->assertTrue(true);
4951
}
5052

51-
public function testConstructMissingRequiredConstraintsOption()
53+
public function testConstructMissingRequiredConstraintsOption(): void
5254
{
5355
$this->expectException(MissingOptionsException::class);
5456

@@ -60,7 +62,7 @@ public function testConstructMissingRequiredConstraintsOption()
6062
*
6163
* @dataProvider providerNoArray
6264
*/
63-
public function testConstructConstraintsOptionNoArray($constraints)
65+
public function testConstructConstraintsOptionNoArray($constraints): void
6466
{
6567
$this->expectException(ConstraintDefinitionException::class);
6668

@@ -69,7 +71,7 @@ public function testConstructConstraintsOptionNoArray($constraints)
6971
]);
7072
}
7173

72-
public function testConstructNoConstraint()
74+
public function testConstructNoConstraint(): void
7375
{
7476
$this->expectException(ConstraintDefinitionException::class);
7577

@@ -80,7 +82,7 @@ public function testConstructNoConstraint()
8082
]);
8183
}
8284

83-
public function testConstructValidConstraint()
85+
public function testConstructValidConstraint(): void
8486
{
8587
$this->expectException(ConstraintDefinitionException::class);
8688

@@ -91,10 +93,7 @@ public function testConstructValidConstraint()
9193
]);
9294
}
9395

94-
/**
95-
* @return array[]
96-
*/
97-
public function providerNoArray()
96+
public function providerNoArray(): array
9897
{
9998
return [
10099
'bool' => [true],

0 commit comments

Comments
 (0)