Skip to content

Commit

Permalink
Allow PHP 8.4
Browse files Browse the repository at this point in the history
  • Loading branch information
veewee committed Nov 21, 2024
1 parent 77af041 commit 819769a
Show file tree
Hide file tree
Showing 13 changed files with 59 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
matrix:
php-version:
- "8.3"
- "8.4"
operating-system:
- "ubuntu-latest"

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/code-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: "installing PHP"
uses: "shivammathur/setup-php@v2"
with:
php-version: "8.3"
php-version: "8.4"
ini-values: memory_limit=-1
tools: composer:v2, cs2pr
extensions: bcmath, mbstring, intl, sodium, json
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/coding-standards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: "installing PHP"
uses: "shivammathur/setup-php@v2"
with:
php-version: "8.3"
php-version: "8.4"
ini-values: memory_limit=-1
tools: composer:v2, cs2pr
extensions: bcmath, mbstring, intl, sodium, json
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/documentation-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: "installing PHP"
uses: "shivammathur/setup-php@v2"
with:
php-version: "8.3"
php-version: "8.4"
ini-values: memory_limit=-1
tools: composer:v2, cs2pr
extensions: bcmath, mbstring, intl, sodium, json
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/mutation-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
matrix:
php-version:
- "8.3"
- "8.4"
operating-system:
- "ubuntu-latest"

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/preload-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: "installing PHP"
uses: "shivammathur/setup-php@v2"
with:
php-version: "8.3"
php-version: "8.4"
ini-values: memory_limit=-1
tools: composer:v2, cs2pr
extensions: bcmath, mbstring, intl, sodium, json
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ jobs:
php-version:
- "8.2"
- "8.3"
- "8.4"
operating-system:
- "macos-latest"
- "ubuntu-latest"
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ help:
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_\-\.]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)

install: ## install all dependencies for a development environment
composer install
COMPOSER_IGNORE_PLATFORM_REQ=php+ composer install

coding-standard-fix: ## apply automated coding standard fixes
PHP_CS_FIXER_IGNORE_ENV=1 ./vendor/bin/php-cs-fixer fix --config=config/.php_cs.dist.php
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
}
],
"require": {
"php": "~8.2.0 || ~8.3.0",
"php": "~8.2.0 || ~8.3.0 || ~8.4.0",
"ext-bcmath": "*",
"ext-json": "*",
"ext-mbstring": "*",
Expand Down
8 changes: 4 additions & 4 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 1 addition & 8 deletions src/Psl/DateTime/DateTime.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,14 +172,7 @@ public static function fromParts(Timezone $timezone, int $year, Month|int $month
$month = $month->value;
}

/**
* @var IntlCalendar $calendar
*/
$calendar = IntlCalendar::createInstance(
Internal\to_intl_timezone($timezone),
);

$calendar->set($year, $month - 1, $day, $hours, $minutes, $seconds);
$calendar = Internal\create_intl_calendar_from_date_time($timezone, $year, $month, $day, $hours, $minutes, $seconds);

if ($seconds !== $calendar->get(IntlCalendar::FIELD_SECOND)) {
throw Exception\UnexpectedValueException::forSeconds($seconds, $calendar->get(IntlCalendar::FIELD_SECOND));
Expand Down
44 changes: 44 additions & 0 deletions src/Psl/DateTime/Internal/create_intl_calendar_from_date_time.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

declare(strict_types=1);

namespace Psl\DateTime\Internal;

use IntlCalendar;
use Psl\DateTime\Timezone;

/**
* @internal
*
* @psalm-mutation-free
*
* @psalm-suppress ImpureMethodCall - `IntlCalender::setDateTime()` is mutation free, as it performs a read-only operation.
*
* @infection-ignore-all
*/
function create_intl_calendar_from_date_time(
Timezone $timezone,
int $year,
int $month,
int $day,
int $hours,
int $minutes,
int $seconds
): IntlCalendar {
/**
* @var IntlCalendar $calendar
*/
$calendar = IntlCalendar::createInstance(
to_intl_timezone($timezone),
);

if (PHP_VERSION_ID >= 80300) {
$calendar->setDateTime($year, $month - 1, $day, $hours, $minutes, $seconds);
} else {
// @codeCoverageIgnoreStart
$calendar->set($year, $month - 1, $day, $hours, $minutes, $seconds);
// @codeCoverageIgnoreEnd
}

return $calendar;
}
1 change: 1 addition & 0 deletions src/Psl/Internal/Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,7 @@ final class Loader
'Psl\\DateTime\\Internal\\default_timezone' => 'Psl/DateTime/Internal/default_timezone.php',
'Psl\\DateTime\\Internal\\system_time' => 'Psl/DateTime/Internal/system_time.php',
'Psl\\DateTime\\Internal\\high_resolution_time' => 'Psl/DateTime/Internal/high_resolution_time.php',
'Psl\\DateTime\\Internal\\create_intl_calendar_from_date_time' => 'Psl/DateTime/Internal/create_intl_calendar_from_date_time.php',
'Psl\\DateTime\\Internal\\create_intl_date_formatter' => 'Psl/DateTime/Internal/create_intl_date_formatter.php',
'Psl\\DateTime\\Internal\\parse' => 'Psl/DateTime/Internal/parse.php',
'Psl\\DateTime\\Internal\\format_rfc3339' => 'Psl/DateTime/Internal/format_rfc3339.php',
Expand Down

0 comments on commit 819769a

Please sign in to comment.