Skip to content

Commit a136842

Browse files
authored
PHP 8.4 Support (#904)
1 parent 5c89067 commit a136842

26 files changed

+45
-41
lines changed

.github/workflows/tests.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ jobs:
2323
- "8.1"
2424
- "8.2"
2525
- "8.3"
26+
- "8.4"
2627

2728
runs-on: "ubuntu-latest"
2829

.php-cs-fixer.dist.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@
126126
'no_whitespace_in_blank_line' => true,
127127
'non_printable_character' => true,
128128
'normalize_index_brace' => true,
129+
'nullable_type_declaration_for_default_null_value' => true,
129130
'operator_linebreak' => [
130131
'only_booleans' => true,
131132
'position' => 'beginning',

CHANGELOG.md

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

33
## [Unreleased](https://github.com/FakerPHP/Faker/compare/v1.23.1...1.23)
44

5+
- Added support for PHP 8.4 (#904)
6+
57
## [2023-09-29, v1.23.1](https://github.com/FakerPHP/Faker/compare/v1.23.0..v1.23.1)
68

79
- Fixed double `а` female lastName in `ru_RU/Person::name()` (#832)

psalm.baseline.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@
125125
<file src="src/Faker/ORM/Spot/Populator.php">
126126
<UndefinedClass>
127127
<code><![CDATA[$this->locator]]></code>
128-
<code>Locator</code>
128+
<code>?Locator</code>
129129
</UndefinedClass>
130130
<UndefinedDocblockClass>
131131
<code>Locator</code>

src/Faker/Core/Barcode.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ final class Barcode implements Extension\BarcodeExtension
1414
{
1515
private Extension\NumberExtension $numberExtension;
1616

17-
public function __construct(Extension\NumberExtension $numberExtension = null)
17+
public function __construct(?Extension\NumberExtension $numberExtension = null)
1818
{
1919
$this->numberExtension = $numberExtension ?: new Number();
2020
}

src/Faker/Core/Color.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ final class Color implements Extension\ColorExtension
5454
'Turquoise', 'Violet', 'Wheat', 'White', 'WhiteSmoke', 'Yellow', 'YellowGreen',
5555
];
5656

57-
public function __construct(Extension\NumberExtension $numberExtension = null)
57+
public function __construct(?Extension\NumberExtension $numberExtension = null)
5858
{
5959
$this->numberExtension = $numberExtension ?: new Number();
6060
}

src/Faker/Core/Coordinates.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ final class Coordinates implements Extension\Extension
1313
{
1414
private Extension\NumberExtension $numberExtension;
1515

16-
public function __construct(Extension\NumberExtension $numberExtension = null)
16+
public function __construct(?Extension\NumberExtension $numberExtension = null)
1717
{
1818
$this->numberExtension = $numberExtension ?: new Number();
1919
}

src/Faker/Core/DateTime.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,15 @@ private function setTimezone(\DateTime $dateTime, ?string $timezone): \DateTime
7272
return $dateTime->setTimezone(new \DateTimeZone($timezone));
7373
}
7474

75-
public function dateTime($until = 'now', string $timezone = null): \DateTime
75+
public function dateTime($until = 'now', ?string $timezone = null): \DateTime
7676
{
7777
return $this->setTimezone(
7878
$this->getTimestampDateTime($this->unixTime($until)),
7979
$timezone,
8080
);
8181
}
8282

83-
public function dateTimeAD($until = 'now', string $timezone = null): \DateTime
83+
public function dateTimeAD($until = 'now', ?string $timezone = null): \DateTime
8484
{
8585
$min = (PHP_INT_SIZE > 4) ? -62135597361 : -PHP_INT_MAX;
8686

@@ -90,7 +90,7 @@ public function dateTimeAD($until = 'now', string $timezone = null): \DateTime
9090
);
9191
}
9292

93-
public function dateTimeBetween($from = '-30 years', $until = 'now', string $timezone = null): \DateTime
93+
public function dateTimeBetween($from = '-30 years', $until = 'now', ?string $timezone = null): \DateTime
9494
{
9595
$start = $this->getTimestamp($from);
9696
$end = $this->getTimestamp($until);
@@ -107,7 +107,7 @@ public function dateTimeBetween($from = '-30 years', $until = 'now', string $tim
107107
);
108108
}
109109

110-
public function dateTimeInInterval($from = '-30 years', string $interval = '+5 days', string $timezone = null): \DateTime
110+
public function dateTimeInInterval($from = '-30 years', string $interval = '+5 days', ?string $timezone = null): \DateTime
111111
{
112112
$intervalObject = \DateInterval::createFromDateString($interval);
113113
$datetime = $from instanceof \DateTime ? $from : new \DateTime($from);
@@ -120,29 +120,29 @@ public function dateTimeInInterval($from = '-30 years', string $interval = '+5 d
120120
return $this->dateTimeBetween($begin, $end, $timezone);
121121
}
122122

123-
public function dateTimeThisWeek($until = 'sunday this week', string $timezone = null): \DateTime
123+
public function dateTimeThisWeek($until = 'sunday this week', ?string $timezone = null): \DateTime
124124
{
125125
return $this->dateTimeBetween('monday this week', $until, $timezone);
126126
}
127127

128-
public function dateTimeThisMonth($until = 'last day of this month', string $timezone = null): \DateTime
128+
public function dateTimeThisMonth($until = 'last day of this month', ?string $timezone = null): \DateTime
129129
{
130130
return $this->dateTimeBetween('first day of this month', $until, $timezone);
131131
}
132132

133-
public function dateTimeThisYear($until = 'last day of december', string $timezone = null): \DateTime
133+
public function dateTimeThisYear($until = 'last day of december', ?string $timezone = null): \DateTime
134134
{
135135
return $this->dateTimeBetween('first day of january', $until, $timezone);
136136
}
137137

138-
public function dateTimeThisDecade($until = 'now', string $timezone = null): \DateTime
138+
public function dateTimeThisDecade($until = 'now', ?string $timezone = null): \DateTime
139139
{
140140
$year = floor(date('Y') / 10) * 10;
141141

142142
return $this->dateTimeBetween("first day of january $year", $until, $timezone);
143143
}
144144

145-
public function dateTimeThisCentury($until = 'now', string $timezone = null): \DateTime
145+
public function dateTimeThisCentury($until = 'now', ?string $timezone = null): \DateTime
146146
{
147147
$year = floor(date('Y') / 100) * 100;
148148

@@ -204,7 +204,7 @@ public function century(): string
204204
return Helper::randomElement($this->centuries);
205205
}
206206

207-
public function timezone(string $countryCode = null): string
207+
public function timezone(?string $countryCode = null): string
208208
{
209209
if ($countryCode) {
210210
$timezones = \DateTimeZone::listIdentifiers(\DateTimeZone::PER_COUNTRY, $countryCode);

src/Faker/Core/Number.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function randomFloat(?int $nbMaxDecimals = null, float $min = 0, ?float $
6363
return round($min + $this->numberBetween() / mt_getrandmax() * ($max - $min), $nbMaxDecimals);
6464
}
6565

66-
public function randomNumber(int $nbDigits = null, bool $strict = false): int
66+
public function randomNumber(?int $nbDigits = null, bool $strict = false): int
6767
{
6868
if (null === $nbDigits) {
6969
$nbDigits = $this->randomDigitNotZero();

src/Faker/Core/Uuid.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ final class Uuid implements Extension\UuidExtension
1111
{
1212
private Extension\NumberExtension $numberExtension;
1313

14-
public function __construct(Extension\NumberExtension $numberExtension = null)
14+
public function __construct(?Extension\NumberExtension $numberExtension = null)
1515
{
1616

1717
$this->numberExtension = $numberExtension ?: new Number();

0 commit comments

Comments
 (0)