Skip to content

Commit

Permalink
Merge pull request #2810 from briannesbitt/drop-php-8.0
Browse files Browse the repository at this point in the history
Drop PHP 8.0
  • Loading branch information
kylekatarnls authored Jun 22, 2023
2 parents 52ada2e + f437417 commit e44b7fa
Show file tree
Hide file tree
Showing 46 changed files with 269 additions and 310 deletions.
20 changes: 3 additions & 17 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,9 @@ jobs:
fail-fast: false
matrix:
include:
- php: 8.0
coverage: true

- php: 8.0
- php: 8.1
classmap-authoritative: true

- php: 8.0
- php: 8.0
setup: lowest

- php: 8.1
- php: 8.1
setup: lowest
Expand All @@ -59,11 +52,11 @@ jobs:
- php: 8.3
setup: lowest

- php: 8.0
- php: 8.1
laravel: true
reference: 9.x

- php: 8.0
- php: 8.1
laravel: true
reference: 9.x
classmap-authoritative: true
Expand Down Expand Up @@ -132,7 +125,6 @@ jobs:
if [[ "${{ matrix.laravel }}" != 'true' ]]; then
composer remove --no-update kylekatarnls/multi-tester --no-interaction --dev;
fi;
${{ matrix.php >= 8.1 && 'composer require --no-update phpunit/phpunit:^9.5.20 --no-interaction --dev;' || '' }}
composer update --prefer-dist --no-progress --prefer-${{ matrix.setup || 'stable' }} ${{ matrix.classmap-authoritative && '--classmap-authoritative' || '' }}${{ matrix.php >= 8.2 && ' --ignore-platform-reqs' || '' }};
- name: Run test suite
Expand Down Expand Up @@ -174,11 +166,6 @@ jobs:
fail-fast: false
matrix:
include:
- php: 8.0
coverage: true
- php: 8.0
setup: lowest

- php: 8.1
- php: 8.1
setup: lowest
Expand Down Expand Up @@ -223,7 +210,6 @@ jobs:
max_attempts: 3
command: |
composer remove --no-update kylekatarnls/multi-tester phpmd/phpmd friendsofphp/php-cs-fixer --no-interaction --dev;
${{ matrix.php >= 8.1 && 'composer require --no-update phpunit/phpunit:^9.5.20 --no-interaction --dev;' || '' }}
composer update --prefer-dist --no-progress --prefer-${{ matrix.setup || 'stable' }}${{ matrix.php >= 8.2 && ' --ignore-platform-reqs' || '' }};
- name: Run test suite
Expand Down
23 changes: 11 additions & 12 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,23 +40,22 @@
}
],
"require": {
"php": "^8.0",
"php": "^8.1",
"ext-json": "*",
"symfony/polyfill-mbstring": "^1.0",
"symfony/translation": "^4.4.18 || ^5.2.1|| ^6.0"
},
"require-dev": {
"doctrine/dbal": "^2.0 || ^3.1.4",
"doctrine/orm": "^2.7",
"friendsofphp/php-cs-fixer": "^3.4",
"kylekatarnls/multi-tester": "^2.2",
"ondrejmirtes/better-reflection": "*",
"phpmd/phpmd": "^2.11.1",
"phpstan/extension-installer": "^1.1",
"phpstan/phpstan": "^1.4.9",
"phpunit/php-file-iterator": "^2.0.5 || ^3.0.6",
"phpunit/phpunit": "^9.5.18",
"squizlabs/php_codesniffer": "^3.4"
"doctrine/dbal": "^3.6.3",
"doctrine/orm": "^2.15.2",
"friendsofphp/php-cs-fixer": "^3.18.0",
"kylekatarnls/multi-tester": "^2.2.0",
"ondrejmirtes/better-reflection": "^6.11.0.0",
"phpmd/phpmd": "^2.13.0",
"phpstan/extension-installer": "^1.3.0",
"phpstan/phpstan": "^1.10.20",
"phpunit/phpunit": "^10.2.2",
"squizlabs/php_codesniffer": "^3.7.2"
},
"minimum-stability": "dev",
"prefer-stable": true,
Expand Down
27 changes: 14 additions & 13 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,21 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.2/phpunit.xsd"
bootstrap="tests/bootstrap.php"
colors="true"
cacheDirectory=".phpunit.cache"
>
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">src/Carbon</directory>
</include>
<exclude>
<file>src/Carbon/PHPStan/Macro.php</file>
<file>src/Carbon/Translator.php</file>
<file>src/Carbon/TranslatorStrongType.php</file>
<file>src/Carbon/TranslatorWeakType.php</file>
</exclude>
</coverage>
<coverage/>
<testsuites>
<testsuite name="carbon">
<directory>tests/Carbon</directory>
Expand Down Expand Up @@ -58,8 +49,18 @@
<directory>tests/PHPStan</directory>
</testsuite>
</testsuites>

<php>
<ini name="max_execution_time" value="0"/>
</php>
<source>
<include>
<directory suffix=".php">src/Carbon</directory>
</include>
<exclude>
<file>src/Carbon/PHPStan/Macro.php</file>
<file>src/Carbon/Translator.php</file>
<file>src/Carbon/TranslatorStrongType.php</file>
<file>src/Carbon/TranslatorWeakType.php</file>
</exclude>
</source>
</phpunit>
14 changes: 2 additions & 12 deletions src/Carbon/CarbonImmutable.php
Original file line number Diff line number Diff line change
Expand Up @@ -551,24 +551,14 @@ public static function endOfTime(): static
*/
private static function getEndOfTimeYear(): int
{
// Remove if https://bugs.php.net/bug.php?id=81107 is fixed
if (version_compare(PHP_VERSION, '8.1.0-dev', '>=')) {
return 1118290769066902787;
}

return PHP_INT_MAX;
return 1118290769066902787; // PHP_INT_MAX no longer work since PHP 8.1
}

/**
* @codeCoverageIgnore
*/
private static function getStartOfTimeYear(): int
{
// Remove if https://bugs.php.net/bug.php?id=81107 is fixed
if (version_compare(PHP_VERSION, '8.1.0-dev', '>=')) {
return -1118290769066898816;
}

return max(PHP_INT_MIN, -9223372036854773760);
return -1118290769066898816; // PHP_INT_MIN no longer work since PHP 8.1
}
}
13 changes: 1 addition & 12 deletions src/Carbon/Traits/Difference.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,9 @@ public function diffAsDateInterval($date = null, bool $absolute = false): DateIn
// It was initially introduced for https://bugs.php.net/bug.php?id=80998
// The very specific case of 80998 was fixed in PHP 8.1beta3, but it introduced 81458
// So we still need to keep this for now
// @codeCoverageIgnoreStart
if (version_compare(PHP_VERSION, '8.1.0-dev', '>=') && $other->tz !== $this->tz) {
if ($other->tz !== $this->tz) {
$other = $other->avoidMutation()->tz($this->tz);
}
// @codeCoverageIgnoreEnd

return parent::diff($other, $absolute);
}
Expand Down Expand Up @@ -820,15 +818,6 @@ private function getIntervalDayDiff(DateInterval $interval): int
$daysDiff = (int) $interval->format('%a');
$sign = $interval->format('%r') === '-' ? -1 : 1;

if (\is_int($interval->days) &&
$interval->y === 0 &&
$interval->m === 0 &&
version_compare(PHP_VERSION, '8.1.0-dev', '<') &&
abs($interval->d - $daysDiff) === 1
) {
$daysDiff = abs($interval->d); // @codeCoverageIgnore
}

return $daysDiff * $sign;
}
}
2 changes: 1 addition & 1 deletion tests/AbstractTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ abstract class AbstractTestCase extends TestCase
/**
* @var class-string<CarbonPeriod>
*/
protected $periodClass = CarbonPeriod::class;
protected static $periodClass = CarbonPeriod::class;

protected function getTimestamp()
{
Expand Down
4 changes: 1 addition & 3 deletions tests/Carbon/ModifyNearDSTChangeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,7 @@ public static function dataForTransitionTests(): Generator
yield [
'2010-03-14T00:00:00',
24,
version_compare(PHP_VERSION, '8.1.0-dev', '>=')
? '2010-03-15T01:00:00-04:00'
: '2010-03-15T00:00:00-04:00',
'2010-03-15T01:00:00-04:00',
];

// testBackwardTransition
Expand Down
2 changes: 1 addition & 1 deletion tests/Carbon/ModifyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function testSimpleModify()
/** @group php-8.1 */
public function testTimezoneModify()
{
$php81Fix = version_compare(PHP_VERSION, '8.1.0-dev', '>=') ? 1.0 : 0.0;
$php81Fix = 1.0;
// For daylight saving time reason 2014-03-30 0h59 is immediately followed by 2h00

$a = new Carbon('2014-03-30 00:00:00', 'Europe/London');
Expand Down
24 changes: 12 additions & 12 deletions tests/Carbon/ObjectsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,40 +29,40 @@ public function testToObject()

$this->assertInstanceOf(stdClass::class, $dtToObject);

$this->assertObjectHasAttribute('year', $dtToObject);
$this->assertObjectHasProperty('year', $dtToObject);
$this->assertSame($dt->year, $dtToObject->year);

$this->assertObjectHasAttribute('month', $dtToObject);
$this->assertObjectHasProperty('month', $dtToObject);
$this->assertSame($dt->month, $dtToObject->month);

$this->assertObjectHasAttribute('day', $dtToObject);
$this->assertObjectHasProperty('day', $dtToObject);
$this->assertSame($dt->day, $dtToObject->day);

$this->assertObjectHasAttribute('dayOfWeek', $dtToObject);
$this->assertObjectHasProperty('dayOfWeek', $dtToObject);
$this->assertSame($dt->dayOfWeek, $dtToObject->dayOfWeek);

$this->assertObjectHasAttribute('dayOfYear', $dtToObject);
$this->assertObjectHasProperty('dayOfYear', $dtToObject);
$this->assertSame($dt->dayOfYear, $dtToObject->dayOfYear);

$this->assertObjectHasAttribute('hour', $dtToObject);
$this->assertObjectHasProperty('hour', $dtToObject);
$this->assertSame($dt->hour, $dtToObject->hour);

$this->assertObjectHasAttribute('minute', $dtToObject);
$this->assertObjectHasProperty('minute', $dtToObject);
$this->assertSame($dt->minute, $dtToObject->minute);

$this->assertObjectHasAttribute('second', $dtToObject);
$this->assertObjectHasProperty('second', $dtToObject);
$this->assertSame($dt->second, $dtToObject->second);

$this->assertObjectHasAttribute('micro', $dtToObject);
$this->assertObjectHasProperty('micro', $dtToObject);
$this->assertSame($dt->micro, $dtToObject->micro);

$this->assertObjectHasAttribute('timestamp', $dtToObject);
$this->assertObjectHasProperty('timestamp', $dtToObject);
$this->assertSame($dt->timestamp, $dtToObject->timestamp);

$this->assertObjectHasAttribute('timezone', $dtToObject);
$this->assertObjectHasProperty('timezone', $dtToObject);
$this->assertEquals($dt->timezone, $dtToObject->timezone);

$this->assertObjectHasAttribute('formatted', $dtToObject);
$this->assertObjectHasProperty('formatted', $dtToObject);
$this->assertSame($dt->format(Carbon::DEFAULT_TO_STRING_FORMAT), $dtToObject->formatted);
}

Expand Down
8 changes: 3 additions & 5 deletions tests/Carbon/StringsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,9 @@ public function testToLocalizedFormattedDateString()

public function testToLocalizedFormattedDeprecation()
{
if (version_compare(PHP_VERSION, '8.1.0-dev', '>=')) {
$this->expectExceptionObject(
new ErrorException('Function strftime() is deprecated', E_DEPRECATED)
);
}
$this->expectExceptionObject(
new ErrorException('Function strftime() is deprecated', E_DEPRECATED)
);

$this->wrapWithUtf8LcTimeLocale('fr_FR', function () {
$date = Carbon::parse('2021-05-26')->formatLocalized('%A %d %B %Y');
Expand Down
4 changes: 2 additions & 2 deletions tests/Carbon/WeekTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5470,7 +5470,7 @@ public function testGetDaysFromStartOfWeek(string $locale, string $date, int $da
);
}

public function getDaysFromStartOfWeekDataProvider(): array
public static function getDaysFromStartOfWeekDataProvider(): array
{
return [
'Monday en_US' => ['en_US', '2022-11-21', 1],
Expand Down Expand Up @@ -5510,7 +5510,7 @@ public function testGetDaysFromStartOfWeekExplicit(int $start, string $date, int
$this->assertSame($daysCount, $carbon->getDaysFromStartOfWeek($start));
}

public function getDaysFromStartOfWeekDataProviderExplicit(): array
public static function getDaysFromStartOfWeekDataProviderExplicit(): array
{
return [
'Monday 0' => [0, '2022-11-21', 1],
Expand Down
4 changes: 1 addition & 3 deletions tests/CarbonImmutable/ModifyNearDSTChangeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,7 @@ public static function dataForTransitionTests(): Generator
yield [
'2010-03-14T00:00:00',
24,
version_compare(PHP_VERSION, '8.1.0-dev', '>=')
? '2010-03-15T01:00:00-04:00'
: '2010-03-15T00:00:00-04:00',
'2010-03-15T01:00:00-04:00',
];

// testBackwardTransition
Expand Down
2 changes: 1 addition & 1 deletion tests/CarbonImmutable/ModifyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function testSimpleModifyWithNamedParameter()
/** @group php-8.1 */
public function testTimezoneModify()
{
$php81Fix = version_compare(PHP_VERSION, '8.1.0-dev', '>=') ? 1.0 : 0.0;
$php81Fix = 1.0;
// For daylight saving time reason 2014-03-30 0h59 is immediately followed by 2h00

$a = new Carbon('2014-03-30 00:00:00', 'Europe/London');
Expand Down
24 changes: 12 additions & 12 deletions tests/CarbonImmutable/ObjectsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,40 +28,40 @@ public function testToObject()

$this->assertInstanceOf(stdClass::class, $dtToObject);

$this->assertObjectHasAttribute('year', $dtToObject);
$this->assertObjectHasProperty('year', $dtToObject);
$this->assertSame($dt->year, $dtToObject->year);

$this->assertObjectHasAttribute('month', $dtToObject);
$this->assertObjectHasProperty('month', $dtToObject);
$this->assertSame($dt->month, $dtToObject->month);

$this->assertObjectHasAttribute('day', $dtToObject);
$this->assertObjectHasProperty('day', $dtToObject);
$this->assertSame($dt->day, $dtToObject->day);

$this->assertObjectHasAttribute('dayOfWeek', $dtToObject);
$this->assertObjectHasProperty('dayOfWeek', $dtToObject);
$this->assertSame($dt->dayOfWeek, $dtToObject->dayOfWeek);

$this->assertObjectHasAttribute('dayOfYear', $dtToObject);
$this->assertObjectHasProperty('dayOfYear', $dtToObject);
$this->assertSame($dt->dayOfYear, $dtToObject->dayOfYear);

$this->assertObjectHasAttribute('hour', $dtToObject);
$this->assertObjectHasProperty('hour', $dtToObject);
$this->assertSame($dt->hour, $dtToObject->hour);

$this->assertObjectHasAttribute('minute', $dtToObject);
$this->assertObjectHasProperty('minute', $dtToObject);
$this->assertSame($dt->minute, $dtToObject->minute);

$this->assertObjectHasAttribute('second', $dtToObject);
$this->assertObjectHasProperty('second', $dtToObject);
$this->assertSame($dt->second, $dtToObject->second);

$this->assertObjectHasAttribute('micro', $dtToObject);
$this->assertObjectHasProperty('micro', $dtToObject);
$this->assertSame($dt->micro, $dtToObject->micro);

$this->assertObjectHasAttribute('timestamp', $dtToObject);
$this->assertObjectHasProperty('timestamp', $dtToObject);
$this->assertSame($dt->timestamp, $dtToObject->timestamp);

$this->assertObjectHasAttribute('timezone', $dtToObject);
$this->assertObjectHasProperty('timezone', $dtToObject);
$this->assertEquals($dt->timezone, $dtToObject->timezone);

$this->assertObjectHasAttribute('formatted', $dtToObject);
$this->assertObjectHasProperty('formatted', $dtToObject);
$this->assertSame($dt->format(Carbon::DEFAULT_TO_STRING_FORMAT), $dtToObject->formatted);
}

Expand Down
Loading

0 comments on commit e44b7fa

Please sign in to comment.