From 9972225c4fa2173e09d21978b12a9787e9a93678 Mon Sep 17 00:00:00 2001 From: Corey Taylor Date: Wed, 18 Jun 2025 02:52:14 -0500 Subject: [PATCH] Allow float timestamp argument for createFromTimestamp to match PHP 8.4 --- .github/workflows/ci.yml | 11 ++++------- composer.json | 2 +- src/Traits/FactoryTrait.php | 4 ++-- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 57032c1c..25817813 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,11 +17,8 @@ jobs: strategy: fail-fast: false matrix: - php-version: ['7.4', '8.0', '8.1', '8.2'] + php-version: ['8.4'] prefer-lowest: [''] - include: - - php-version: '7.2' - prefer-lowest: 'prefer-lowest' steps: - uses: actions/checkout@v4 @@ -56,19 +53,19 @@ jobs: fi - name: Setup problem matchers for PHPUnit - if: matrix.php-version == '7.4' + if: matrix.php-version == '8.4' run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" - name: Run PHPUnit run: | - if [[ ${{ matrix.php-version }} == '7.4' ]]; then + if [[ ${{ matrix.php-version }} == '8.4' ]]; then export CODECOVERAGE=1 && vendor/bin/phpunit --verbose --coverage-clover=coverage.xml else vendor/bin/phpunit fi - name: Submit code coverage - if: matrix.php-version == '7.4' + if: matrix.php-version == '8.4' uses: codecov/codecov-action@v3 cs-stan: diff --git a/composer.json b/composer.json index 1bc16033..47742beb 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,7 @@ "source": "https://github.com/cakephp/chronos" }, "require": { - "php": ">=7.2" + "php": ">=8.0" }, "require-dev": { "phpunit/phpunit": "^8.0 || ^9.0", diff --git a/src/Traits/FactoryTrait.php b/src/Traits/FactoryTrait.php index e37295d5..4a036581 100644 --- a/src/Traits/FactoryTrait.php +++ b/src/Traits/FactoryTrait.php @@ -332,11 +332,11 @@ public static function createFromArray(array $values): ChronosInterface /** * Create a ChronosInterface instance from a timestamp * - * @param int $timestamp The timestamp to create an instance from. + * @param float|int $timestamp The timestamp to create an instance from. * @param \DateTimeZone|string|null $tz The DateTimeZone object or timezone name the new instance should use. * @return static */ - public static function createFromTimestamp(int $timestamp, $tz = null): ChronosInterface + public static function createFromTimestamp(float|int $timestamp, $tz = null): ChronosInterface { $instance = static::now($tz)->setTimestamp($timestamp); if (get_class($instance) === ChronosDate::class) {