Skip to content

Commit

Permalink
Partial PHP 8.1 compatibility (#373)
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-doehring authored Sep 29, 2021
1 parent 79f28d0 commit 8d6044a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
15 changes: 9 additions & 6 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ jobs:
- '7.3'
- '7.4'
- '8.0'
- '8.1'
include:
- operating-system: 'windows-latest'
php-version: '7.1'
Expand Down Expand Up @@ -55,10 +56,12 @@ jobs:
composer-
- name: Download dependencies
run: |
composer update --no-interaction --no-progress --optimize-autoloader
./vendor/bin/simple-phpunit install
run: composer update --no-interaction --no-progress --optimize-autoloader

- name: Run tests with PHPUnit
run: |
./vendor/bin/simple-phpunit
- name: Run tests
if: ${{ '8.1' != matrix.php-version }}
run: ./vendor/bin/simple-phpunit

- name: Run tests for php 8.1
if: ${{ '8.1' == matrix.php-version }}
run: SYMFONY_PHPUNIT_VERSION=9.5 ./vendor/bin/simple-phpunit
2 changes: 1 addition & 1 deletion src/Faker/Provider/en_ZA/Person.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public function idNumber(\DateTime $birthdate = null, $citizen = true, $gender =
}
$birthDateString = $birthdate->format('ymd');

switch (strtolower($gender)) {
switch (strtolower($gender ?: '')) {
case static::GENDER_FEMALE:
$genderDigit = self::numberBetween(0, 4);

Expand Down
2 changes: 1 addition & 1 deletion test/Faker/Provider/DateTimeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ public function testDateTimeBetween($start, $end)
$date = DateTimeProvider::dateTimeBetween($start, $end);
self::assertInstanceOf('\DateTime', $date);
self::assertGreaterThanOrEqual(new \DateTime($start), $date);
self::assertLessThanOrEqual(new \DateTime($end), $date);
self::assertLessThanOrEqual(new \DateTime($end ?: 'now'), $date);
self::assertEquals(new \DateTimeZone($this->defaultTz), $date->getTimezone());
}

Expand Down
2 changes: 1 addition & 1 deletion test/Faker/Provider/nl_NL/PersonTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function testGenerateValidIdNumber()
$sum = -1 * $idNumber % 10;

for ($multiplier = 2; $idNumber > 0; ++$multiplier) {
$val = ($idNumber /= 10) % 10;
$val = (int) ($idNumber /= 10) % 10;
$sum += $multiplier * $val;
}
self::assertTrue($sum != 0 && $sum % 11 == 0);
Expand Down

0 comments on commit 8d6044a

Please sign in to comment.