Skip to content

Commit

Permalink
Merge pull request fightbulc#209 from blacknell/master
Browse files Browse the repository at this point in the history
fix: PHP 8.1 deprecation warnings
  • Loading branch information
fightbulc authored Jan 26, 2023
2 parents 435d68e + a8f1239 commit c813018
Show file tree
Hide file tree
Showing 15 changed files with 99 additions and 234 deletions.
151 changes: 6 additions & 145 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
@@ -1,147 +1,8 @@
name: qa
on: [push, pull_request]
jobs:
PHP5_3:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '5.3'

- name: Validate composer.json and composer.lock
run: composer validate

- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-suggest

- name: Run PHPUnit
run: vendor/bin/phpunit -c tests/build.xml

PHP5_4:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '5.4'

- name: Validate composer.json and composer.lock
run: composer validate

- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-suggest

- name: Run PHPUnit
run: vendor/bin/phpunit -c tests/build.xml

PHP5_5:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '5.5'

- name: Validate composer.json and composer.lock
run: composer validate

- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-suggest

- name: Run PHPUnit
run: vendor/bin/phpunit -c tests/build.xml

PHP5_6:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '5.6'

- name: Validate composer.json and composer.lock
run: composer validate

- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-suggest

- name: Run PHPUnit
run: vendor/bin/phpunit -c tests/build.xml

PHP7_0:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.0'

- name: Validate composer.json and composer.lock
run: composer validate

- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-suggest

- name: Run PHPUnit
run: vendor/bin/phpunit -c tests/build.xml

PHP7_1:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.1'

- name: Validate composer.json and composer.lock
run: composer validate

- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-suggest

- name: Run PHPUnit
run: vendor/bin/phpunit -c tests/build.xml

PHP7_2:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.2'

- name: Validate composer.json and composer.lock
run: composer validate

- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-suggest

- name: Run PHPUnit
run: vendor/bin/phpunit -c tests/build.xml

PHP7_3:
PHP7_4:
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -150,7 +11,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.3'
php-version: '7.4'

- name: Validate composer.json and composer.lock
run: composer validate
Expand All @@ -161,7 +22,7 @@ jobs:
- name: Run PHPUnit
run: vendor/bin/phpunit -c tests/build.xml

PHP7_4:
PHP8_0:
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -170,7 +31,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
php-version: '8.0'

- name: Validate composer.json and composer.lock
run: composer validate
Expand All @@ -181,7 +42,7 @@ jobs:
- name: Run PHPUnit
run: vendor/bin/phpunit -c tests/build.xml

PHP8_0:
PHP8_1:
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -190,7 +51,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.0'
php-version: '8.1'

- name: Validate composer.json and composer.lock
run: composer validate
Expand Down
5 changes: 5 additions & 0 deletions src/Moment.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ public static function fromDateTime(\DateTimeInterface $date)
* @return static|false Returns a new Moment instance or FALSE on failure.
* @throws MomentException
*/
#[\ReturnTypeWillChange]
public static function createFromFormat($format, $time, $timezone = null, FormatsInterface $formatsInterface = null)
{
// handle diverse format types
Expand Down Expand Up @@ -212,6 +213,7 @@ public function resetDateTime($dateTime = 'now', $timezone = null)
*
* @return \DateTime|Moment
*/
#[\ReturnTypeWillChange]
public function setTimezone($timezone)
{
if ($this->immutableMode)
Expand All @@ -238,6 +240,7 @@ public function setTimezone($timezone)
* @return string
* @throws MomentException
*/
#[\ReturnTypeWillChange]
public function format($format = null, $formatsInterface = null)
{
// set default format
Expand Down Expand Up @@ -591,6 +594,7 @@ public function getYear()
*
* @return self|\DateTime
*/
#[\ReturnTypeWillChange]
public function setDate($year, $month, $day)
{
if ($this->immutableMode)
Expand Down Expand Up @@ -692,6 +696,7 @@ public function getHour()
*
* @return $this|\DateTime
*/
#[\ReturnTypeWillChange]
public function setTime($hour, $minute, $second = null, $microseconds = null)
{
if ($this->immutableMode)
Expand Down
23 changes: 11 additions & 12 deletions tests/build.xml
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit bootstrap="bootstrap.php" backupGlobals="false" colors="true" backupStaticAttributes="false" strict="true" verbose="true">
<testsuites>
<testsuite name="unit">
<directory>unit</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="false">
<directory suffix=".php">../src/</directory>
</whitelist>
</filter>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="bootstrap.php" backupGlobals="false" colors="true" backupStaticAttributes="false" verbose="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage processUncoveredFiles="false">
<include>
<directory suffix=".php">../src/</directory>
</include>
</coverage>
<testsuites>
<testsuite name="unit">
<directory>unit</directory>
</testsuite>
</testsuites>
</phpunit>
12 changes: 6 additions & 6 deletions tests/unit/Moment/MomentBritishEnglishLocaleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@

class MomentBritishEnglishLocaleTest extends TestCase
{
public function setUp()
public function setUp(): void
{
Moment::setLocale('en_GB');
}

public function testWeekdayNames()
public function testWeekdayNames(): void
{
$startingDate = '2015-01-04T00:00:00+0000';

Expand All @@ -39,7 +39,7 @@ public function testWeekdayNames()
}
}

public function testMonthNames()
public function testMonthNames(): void
{
$startingDate = '2015-01-04T00:00:00+0000';

Expand Down Expand Up @@ -68,7 +68,7 @@ public function testMonthNames()
}
}

public function testFormat()
public function testFormat(): void
{
$a = array(
array('l, d F Y, G:i:s', 'Saturday, 12 June 2010, 22:00:00'),
Expand Down Expand Up @@ -105,15 +105,15 @@ public function testFormat()
// }
// }

public function testOrdinalsFormat()
public function testOrdinalsFormat(): void
{
$moment = new Moment('2010-06-02T00:00:00+0000');
self::assertEquals('2nd', $moment->format('jS'));
$moment = new Moment('2010-06-12T00:00:00+0000');
self::assertEquals('12th', $moment->format('jS'));
}

public function testRelative()
public function testRelative(): void
{
Moment::setLocale('en_GB');

Expand Down
14 changes: 7 additions & 7 deletions tests/unit/Moment/MomentCanadianEnglishLocaleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@

class MomentCanadianEnglishLocaleTest extends TestCase
{
public function setUp()
public function setUp(): void
{
Moment::setLocale('en_CA');
}

public function testWeekdayNames()
public function testWeekdayNames(): void
{
$startingDate = '2015-01-04T00:00:00+0000';

Expand All @@ -48,7 +48,7 @@ public function testWeekdayNames()
}
}

public function testMonthNames()
public function testMonthNames(): void
{
$startingDate = '2015-01-04T00:00:00+0000';

Expand Down Expand Up @@ -77,7 +77,7 @@ public function testMonthNames()
}
}

public function testFormat()
public function testFormat(): void
{
$a = array(
array('l, d F Y, G:i:s', 'Saturday, 12 June 2010, 22:00:00'),
Expand All @@ -93,7 +93,7 @@ public function testFormat()
}
}

public function testCustomLocaleFormat()
public function testCustomLocaleFormat(): void
{
$a = array(
array('LT', '10:00 PM',),
Expand All @@ -114,15 +114,15 @@ public function testCustomLocaleFormat()
}
}

public function testOrdinalsFormat()
public function testOrdinalsFormat(): void
{
$moment = new Moment('2010-06-02T00:00:00+0000');
self::assertEquals('2nd', $moment->format('jS'));
$moment = new Moment('2010-06-12T00:00:00+0000');
self::assertEquals('12th', $moment->format('jS'));
}

public function testRelative()
public function testRelative(): void
{
$beginningMoment = new Moment('2010-06-12 00:00:00', 'Europe/London');

Expand Down
Loading

0 comments on commit c813018

Please sign in to comment.