Skip to content

Commit d1e33b8

Browse files
Add return types to tests and final|internal|private methods
1 parent 1567c22 commit d1e33b8

26 files changed

+97
-104
lines changed

Mapping/Loader/PropertyInfoLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function __construct(PropertyListExtractorInterface $listExtractor, Prope
4444
/**
4545
* {@inheritdoc}
4646
*/
47-
public function loadClassMetadata(ClassMetadata $metadata)
47+
public function loadClassMetadata(ClassMetadata $metadata): bool
4848
{
4949
$className = $metadata->getClassName();
5050
if (null !== $this->classValidatorRegexp && !preg_match($this->classValidatorRegexp, $className)) {

Tests/Constraints/AbstractComparisonValidatorTestCase.php

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,7 @@ public function testValidComparisonToValue($dirtyValue, $comparisonValue)
114114
$this->assertNoViolation();
115115
}
116116

117-
/**
118-
* @return array
119-
*/
120-
public function provideAllValidComparisons()
117+
public function provideAllValidComparisons(): array
121118
{
122119
// The provider runs before setUp(), so we need to manually fix
123120
// the default timezone
@@ -171,15 +168,9 @@ public function testInvalidValuePath()
171168
$this->validator->validate(5, $constraint);
172169
}
173170

174-
/**
175-
* @return array
176-
*/
177-
abstract public function provideValidComparisons();
171+
abstract public function provideValidComparisons(): array;
178172

179-
/**
180-
* @return array
181-
*/
182-
abstract public function provideValidComparisonsToPropertyPath();
173+
abstract public function provideValidComparisonsToPropertyPath(): array;
183174

184175
/**
185176
* @dataProvider provideAllInvalidComparisons
@@ -233,10 +224,7 @@ public function testInvalidComparisonToPropertyPathAddsPathAsParameter()
233224
->assertRaised();
234225
}
235226

236-
/**
237-
* @return array
238-
*/
239-
public function provideAllInvalidComparisons()
227+
public function provideAllInvalidComparisons(): array
240228
{
241229
// The provider runs before setUp(), so we need to manually fix
242230
// the default timezone
@@ -249,22 +237,14 @@ public function provideAllInvalidComparisons()
249237
return $comparisons;
250238
}
251239

252-
/**
253-
* @return array
254-
*/
255-
abstract public function provideInvalidComparisons();
240+
abstract public function provideInvalidComparisons(): array;
256241

257242
/**
258243
* @param array|null $options Options for the constraint
259-
*
260-
* @return Constraint
261244
*/
262-
abstract protected function createConstraint(array $options = null);
245+
abstract protected function createConstraint(array $options = null): Constraint;
263246

264-
/**
265-
* @return string|null
266-
*/
267-
protected function getErrorCode()
247+
protected function getErrorCode(): ?string
268248
{
269249
return null;
270250
}

Tests/Constraints/CompositeTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ class ConcreteComposite extends Composite
2121
{
2222
public $constraints;
2323

24-
protected function getCompositeOption()
24+
protected function getCompositeOption(): string
2525
{
2626
return 'constraints';
2727
}
2828

29-
public function getDefaultOption()
29+
public function getDefaultOption(): ?string
3030
{
3131
return 'constraints';
3232
}

Tests/Constraints/DivisibleByValidatorTest.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\Validator\Tests\Constraints;
1313

14+
use Symfony\Component\Validator\Constraint;
1415
use Symfony\Component\Validator\Constraints\DivisibleBy;
1516
use Symfony\Component\Validator\Constraints\DivisibleByValidator;
1617

@@ -24,20 +25,20 @@ protected function createValidator()
2425
return new DivisibleByValidator();
2526
}
2627

27-
protected function createConstraint(array $options = null)
28+
protected function createConstraint(array $options = null): Constraint
2829
{
2930
return new DivisibleBy($options);
3031
}
3132

32-
protected function getErrorCode()
33+
protected function getErrorCode(): ?string
3334
{
3435
return DivisibleBy::NOT_DIVISIBLE_BY;
3536
}
3637

3738
/**
3839
* {@inheritdoc}
3940
*/
40-
public function provideValidComparisons()
41+
public function provideValidComparisons(): array
4142
{
4243
return [
4344
[-7, 1],
@@ -54,7 +55,7 @@ public function provideValidComparisons()
5455
/**
5556
* {@inheritdoc}
5657
*/
57-
public function provideValidComparisonsToPropertyPath()
58+
public function provideValidComparisonsToPropertyPath(): array
5859
{
5960
return [
6061
[25],
@@ -64,7 +65,7 @@ public function provideValidComparisonsToPropertyPath()
6465
/**
6566
* {@inheritdoc}
6667
*/
67-
public function provideInvalidComparisons()
68+
public function provideInvalidComparisons(): array
6869
{
6970
return [
7071
[1, '1', 2, '2', 'integer'],

Tests/Constraints/EqualToValidatorTest.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\Validator\Tests\Constraints;
1313

14+
use Symfony\Component\Validator\Constraint;
1415
use Symfony\Component\Validator\Constraints\EqualTo;
1516
use Symfony\Component\Validator\Constraints\EqualToValidator;
1617

@@ -24,20 +25,20 @@ protected function createValidator()
2425
return new EqualToValidator();
2526
}
2627

27-
protected function createConstraint(array $options = null)
28+
protected function createConstraint(array $options = null): Constraint
2829
{
2930
return new EqualTo($options);
3031
}
3132

32-
protected function getErrorCode()
33+
protected function getErrorCode(): ?string
3334
{
3435
return EqualTo::NOT_EQUAL_ERROR;
3536
}
3637

3738
/**
3839
* {@inheritdoc}
3940
*/
40-
public function provideValidComparisons()
41+
public function provideValidComparisons(): array
4142
{
4243
return [
4344
[3, 3],
@@ -54,7 +55,7 @@ public function provideValidComparisons()
5455
/**
5556
* {@inheritdoc}
5657
*/
57-
public function provideValidComparisonsToPropertyPath()
58+
public function provideValidComparisonsToPropertyPath(): array
5859
{
5960
return [
6061
[5],
@@ -64,7 +65,7 @@ public function provideValidComparisonsToPropertyPath()
6465
/**
6566
* {@inheritdoc}
6667
*/
67-
public function provideInvalidComparisons()
68+
public function provideInvalidComparisons(): array
6869
{
6970
return [
7071
[1, '1', 2, '2', 'integer'],

Tests/Constraints/GreaterThanOrEqualValidatorTest.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\Validator\Tests\Constraints;
1313

14+
use Symfony\Component\Validator\Constraint;
1415
use Symfony\Component\Validator\Constraints\GreaterThanOrEqual;
1516
use Symfony\Component\Validator\Constraints\GreaterThanOrEqualValidator;
1617

@@ -24,20 +25,20 @@ protected function createValidator()
2425
return new GreaterThanOrEqualValidator();
2526
}
2627

27-
protected function createConstraint(array $options = null)
28+
protected function createConstraint(array $options = null): Constraint
2829
{
2930
return new GreaterThanOrEqual($options);
3031
}
3132

32-
protected function getErrorCode()
33+
protected function getErrorCode(): ?string
3334
{
3435
return GreaterThanOrEqual::TOO_LOW_ERROR;
3536
}
3637

3738
/**
3839
* {@inheritdoc}
3940
*/
40-
public function provideValidComparisons()
41+
public function provideValidComparisons(): array
4142
{
4243
return [
4344
[3, 2],
@@ -57,7 +58,7 @@ public function provideValidComparisons()
5758
/**
5859
* {@inheritdoc}
5960
*/
60-
public function provideValidComparisonsToPropertyPath()
61+
public function provideValidComparisonsToPropertyPath(): array
6162
{
6263
return [
6364
[5],
@@ -68,7 +69,7 @@ public function provideValidComparisonsToPropertyPath()
6869
/**
6970
* {@inheritdoc}
7071
*/
71-
public function provideInvalidComparisons()
72+
public function provideInvalidComparisons(): array
7273
{
7374
return [
7475
[1, '1', 2, '2', 'integer'],

Tests/Constraints/GreaterThanOrEqualValidatorWithPositiveOrZeroConstraintTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,23 @@
1111

1212
namespace Symfony\Component\Validator\Tests\Constraints;
1313

14+
use Symfony\Component\Validator\Constraint;
1415
use Symfony\Component\Validator\Constraints\PositiveOrZero;
1516

1617
/**
1718
* @author Jan Schädlich <[email protected]>
1819
*/
1920
class GreaterThanOrEqualValidatorWithPositiveOrZeroConstraintTest extends GreaterThanOrEqualValidatorTest
2021
{
21-
protected function createConstraint(array $options = null)
22+
protected function createConstraint(array $options = null): Constraint
2223
{
2324
return new PositiveOrZero();
2425
}
2526

2627
/**
2728
* {@inheritdoc}
2829
*/
29-
public function provideValidComparisons()
30+
public function provideValidComparisons(): array
3031
{
3132
return [
3233
[0, 0],
@@ -42,7 +43,7 @@ public function provideValidComparisons()
4243
/**
4344
* {@inheritdoc}
4445
*/
45-
public function provideInvalidComparisons()
46+
public function provideInvalidComparisons(): array
4647
{
4748
return [
4849
[-1, '-1', 0, '0', 'integer'],

Tests/Constraints/GreaterThanValidatorTest.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\Validator\Tests\Constraints;
1313

14+
use Symfony\Component\Validator\Constraint;
1415
use Symfony\Component\Validator\Constraints\GreaterThan;
1516
use Symfony\Component\Validator\Constraints\GreaterThanValidator;
1617

@@ -24,20 +25,20 @@ protected function createValidator()
2425
return new GreaterThanValidator();
2526
}
2627

27-
protected function createConstraint(array $options = null)
28+
protected function createConstraint(array $options = null): Constraint
2829
{
2930
return new GreaterThan($options);
3031
}
3132

32-
protected function getErrorCode()
33+
protected function getErrorCode(): ?string
3334
{
3435
return GreaterThan::TOO_LOW_ERROR;
3536
}
3637

3738
/**
3839
* {@inheritdoc}
3940
*/
40-
public function provideValidComparisons()
41+
public function provideValidComparisons(): array
4142
{
4243
return [
4344
[2, 1],
@@ -53,7 +54,7 @@ public function provideValidComparisons()
5354
/**
5455
* {@inheritdoc}
5556
*/
56-
public function provideValidComparisonsToPropertyPath()
57+
public function provideValidComparisonsToPropertyPath(): array
5758
{
5859
return [
5960
[6],
@@ -63,7 +64,7 @@ public function provideValidComparisonsToPropertyPath()
6364
/**
6465
* {@inheritdoc}
6566
*/
66-
public function provideInvalidComparisons()
67+
public function provideInvalidComparisons(): array
6768
{
6869
return [
6970
[1, '1', 2, '2', 'integer'],

Tests/Constraints/GreaterThanValidatorWithPositiveConstraintTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,23 @@
1111

1212
namespace Symfony\Component\Validator\Tests\Constraints;
1313

14+
use Symfony\Component\Validator\Constraint;
1415
use Symfony\Component\Validator\Constraints\Positive;
1516

1617
/**
1718
* @author Jan Schädlich <[email protected]>
1819
*/
1920
class GreaterThanValidatorWithPositiveConstraintTest extends GreaterThanValidatorTest
2021
{
21-
protected function createConstraint(array $options = null)
22+
protected function createConstraint(array $options = null): Constraint
2223
{
2324
return new Positive();
2425
}
2526

2627
/**
2728
* {@inheritdoc}
2829
*/
29-
public function provideValidComparisons()
30+
public function provideValidComparisons(): array
3031
{
3132
return [
3233
[2, 0],
@@ -39,7 +40,7 @@ public function provideValidComparisons()
3940
/**
4041
* {@inheritdoc}
4142
*/
42-
public function provideInvalidComparisons()
43+
public function provideInvalidComparisons(): array
4344
{
4445
return [
4546
[0, '0', 0, '0', 'integer'],

0 commit comments

Comments
 (0)