Skip to content

Commit 6b9c45e

Browse files
author
Robin Chalas
committed
Add scalar typehints/return types on final/internal/private code
1 parent d71357e commit 6b9c45e

19 files changed

+57
-65
lines changed

Data/Provider/LanguageDataProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class LanguageDataProvider
4141
* @param BundleEntryReaderInterface $reader The reader for reading the .res
4242
* files.
4343
*/
44-
public function __construct($path, BundleEntryReaderInterface $reader)
44+
public function __construct(string $path, BundleEntryReaderInterface $reader)
4545
{
4646
$this->path = $path;
4747
$this->reader = $reader;

DateFormatter/DateFormat/AmPmTransformer.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,23 @@ class AmPmTransformer extends Transformer
2323
/**
2424
* {@inheritdoc}
2525
*/
26-
public function format(\DateTime $dateTime, $length)
26+
public function format(\DateTime $dateTime, int $length): string
2727
{
2828
return $dateTime->format('A');
2929
}
3030

3131
/**
3232
* {@inheritdoc}
3333
*/
34-
public function getReverseMatchingRegExp($length)
34+
public function getReverseMatchingRegExp(int $length): string
3535
{
3636
return 'AM|PM';
3737
}
3838

3939
/**
4040
* {@inheritdoc}
4141
*/
42-
public function extractDateOptions($matched, $length)
42+
public function extractDateOptions(string $matched, int $length): array
4343
{
4444
return array(
4545
'marker' => $matched,

DateFormatter/DateFormat/DayOfWeekTransformer.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class DayOfWeekTransformer extends Transformer
2323
/**
2424
* {@inheritdoc}
2525
*/
26-
public function format(\DateTime $dateTime, $length)
26+
public function format(\DateTime $dateTime, int $length): string
2727
{
2828
$dayOfWeek = $dateTime->format('l');
2929
switch ($length) {
@@ -41,7 +41,7 @@ public function format(\DateTime $dateTime, $length)
4141
/**
4242
* {@inheritdoc}
4343
*/
44-
public function getReverseMatchingRegExp($length)
44+
public function getReverseMatchingRegExp(int $length): string
4545
{
4646
switch ($length) {
4747
case 4:
@@ -58,7 +58,7 @@ public function getReverseMatchingRegExp($length)
5858
/**
5959
* {@inheritdoc}
6060
*/
61-
public function extractDateOptions($matched, $length)
61+
public function extractDateOptions(string $matched, int $length): array
6262
{
6363
return array();
6464
}

DateFormatter/DateFormat/DayOfYearTransformer.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class DayOfYearTransformer extends Transformer
2323
/**
2424
* {@inheritdoc}
2525
*/
26-
public function format(\DateTime $dateTime, $length)
26+
public function format(\DateTime $dateTime, int $length): string
2727
{
2828
$dayOfYear = $dateTime->format('z') + 1;
2929

@@ -33,15 +33,15 @@ public function format(\DateTime $dateTime, $length)
3333
/**
3434
* {@inheritdoc}
3535
*/
36-
public function getReverseMatchingRegExp($length)
36+
public function getReverseMatchingRegExp(int $length): string
3737
{
3838
return '\d{'.$length.'}';
3939
}
4040

4141
/**
4242
* {@inheritdoc}
4343
*/
44-
public function extractDateOptions($matched, $length)
44+
public function extractDateOptions(string $matched, int $length): array
4545
{
4646
return array();
4747
}

DateFormatter/DateFormat/DayTransformer.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,23 @@ class DayTransformer extends Transformer
2323
/**
2424
* {@inheritdoc}
2525
*/
26-
public function format(\DateTime $dateTime, $length)
26+
public function format(\DateTime $dateTime, int $length): string
2727
{
2828
return $this->padLeft($dateTime->format('j'), $length);
2929
}
3030

3131
/**
3232
* {@inheritdoc}
3333
*/
34-
public function getReverseMatchingRegExp($length)
34+
public function getReverseMatchingRegExp(int $length): string
3535
{
3636
return 1 === $length ? '\d{1,2}' : '\d{'.$length.'}';
3737
}
3838

3939
/**
4040
* {@inheritdoc}
4141
*/
42-
public function extractDateOptions($matched, $length)
42+
public function extractDateOptions(string $matched, int $length): array
4343
{
4444
return array(
4545
'day' => (int) $matched,

DateFormatter/DateFormat/Hour1200Transformer.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class Hour1200Transformer extends HourTransformer
2323
/**
2424
* {@inheritdoc}
2525
*/
26-
public function format(\DateTime $dateTime, $length)
26+
public function format(\DateTime $dateTime, int $length): string
2727
{
2828
$hourOfDay = $dateTime->format('g');
2929
$hourOfDay = '12' == $hourOfDay ? '0' : $hourOfDay;
@@ -34,7 +34,7 @@ public function format(\DateTime $dateTime, $length)
3434
/**
3535
* {@inheritdoc}
3636
*/
37-
public function normalizeHour($hour, $marker = null)
37+
public function normalizeHour(int $hour, string $marker = null): int
3838
{
3939
if ('PM' === $marker) {
4040
$hour += 12;
@@ -46,15 +46,15 @@ public function normalizeHour($hour, $marker = null)
4646
/**
4747
* {@inheritdoc}
4848
*/
49-
public function getReverseMatchingRegExp($length)
49+
public function getReverseMatchingRegExp(int $length): string
5050
{
5151
return '\d{1,2}';
5252
}
5353

5454
/**
5555
* {@inheritdoc}
5656
*/
57-
public function extractDateOptions($matched, $length)
57+
public function extractDateOptions(string $matched, int $length): array
5858
{
5959
return array(
6060
'hour' => (int) $matched,

DateFormatter/DateFormat/Hour1201Transformer.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ class Hour1201Transformer extends HourTransformer
2323
/**
2424
* {@inheritdoc}
2525
*/
26-
public function format(\DateTime $dateTime, $length)
26+
public function format(\DateTime $dateTime, int $length): string
2727
{
2828
return $this->padLeft($dateTime->format('g'), $length);
2929
}
3030

3131
/**
3232
* {@inheritdoc}
3333
*/
34-
public function normalizeHour($hour, $marker = null)
34+
public function normalizeHour(int $hour, string $marker = null): int
3535
{
3636
if ('PM' !== $marker && 12 === $hour) {
3737
$hour = 0;
@@ -46,15 +46,15 @@ public function normalizeHour($hour, $marker = null)
4646
/**
4747
* {@inheritdoc}
4848
*/
49-
public function getReverseMatchingRegExp($length)
49+
public function getReverseMatchingRegExp(int $length): string
5050
{
5151
return '\d{1,2}';
5252
}
5353

5454
/**
5555
* {@inheritdoc}
5656
*/
57-
public function extractDateOptions($matched, $length)
57+
public function extractDateOptions(string $matched, int $length): array
5858
{
5959
return array(
6060
'hour' => (int) $matched,

DateFormatter/DateFormat/Hour2400Transformer.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ class Hour2400Transformer extends HourTransformer
2323
/**
2424
* {@inheritdoc}
2525
*/
26-
public function format(\DateTime $dateTime, $length)
26+
public function format(\DateTime $dateTime, int $length): string
2727
{
2828
return $this->padLeft($dateTime->format('G'), $length);
2929
}
3030

3131
/**
3232
* {@inheritdoc}
3333
*/
34-
public function normalizeHour($hour, $marker = null)
34+
public function normalizeHour(int $hour, string $marker = null): int
3535
{
3636
if ('AM' == $marker) {
3737
$hour = 0;
@@ -45,15 +45,15 @@ public function normalizeHour($hour, $marker = null)
4545
/**
4646
* {@inheritdoc}
4747
*/
48-
public function getReverseMatchingRegExp($length)
48+
public function getReverseMatchingRegExp(int $length): string
4949
{
5050
return '\d{1,2}';
5151
}
5252

5353
/**
5454
* {@inheritdoc}
5555
*/
56-
public function extractDateOptions($matched, $length)
56+
public function extractDateOptions(string $matched, int $length): array
5757
{
5858
return array(
5959
'hour' => (int) $matched,

DateFormatter/DateFormat/Hour2401Transformer.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class Hour2401Transformer extends HourTransformer
2323
/**
2424
* {@inheritdoc}
2525
*/
26-
public function format(\DateTime $dateTime, $length)
26+
public function format(\DateTime $dateTime, int $length): string
2727
{
2828
$hourOfDay = $dateTime->format('G');
2929
$hourOfDay = ('0' == $hourOfDay) ? '24' : $hourOfDay;
@@ -34,7 +34,7 @@ public function format(\DateTime $dateTime, $length)
3434
/**
3535
* {@inheritdoc}
3636
*/
37-
public function normalizeHour($hour, $marker = null)
37+
public function normalizeHour(int $hour, string $marker = null): int
3838
{
3939
if ((null === $marker && 24 === $hour) || 'AM' == $marker) {
4040
$hour = 0;
@@ -48,15 +48,15 @@ public function normalizeHour($hour, $marker = null)
4848
/**
4949
* {@inheritdoc}
5050
*/
51-
public function getReverseMatchingRegExp($length)
51+
public function getReverseMatchingRegExp(int $length): string
5252
{
5353
return '\d{1,2}';
5454
}
5555

5656
/**
5757
* {@inheritdoc}
5858
*/
59-
public function extractDateOptions($matched, $length)
59+
public function extractDateOptions(string $matched, int $length): array
6060
{
6161
return array(
6262
'hour' => (int) $matched,

DateFormatter/DateFormat/HourTransformer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@ abstract class HourTransformer extends Transformer
2828
*
2929
* @return int The normalized hour value
3030
*/
31-
abstract public function normalizeHour($hour, $marker = null);
31+
abstract public function normalizeHour(int $hour, string $marker = null): int;
3232
}

0 commit comments

Comments
 (0)