From 19b4feac518d1ca3313c5be2e76d51f62d11ce22 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Fri, 8 Nov 2024 11:00:17 +0000 Subject: [PATCH 1/7] Add PHP 8.4 build --- .github/workflows/build.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 742843c..bb61d39 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -25,6 +25,7 @@ jobs: - '8.1' - '8.2' - '8.3' + - '8.4' php-zts: - nts - ts @@ -33,6 +34,8 @@ jobs: php-zts: 'ts' - php-version: '8.3' php-zts: 'ts' + - php-version: '8.4' + php-zts: 'ts' steps: - name: Setup PHP uses: shivammathur/setup-php@v2 From 86d78fce94fc293fb0492d8ec6ed33afb226492a Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Fri, 15 Nov 2024 17:36:23 +0000 Subject: [PATCH 2/7] Update function definitions to match 8.4 --- timecop_php7.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/timecop_php7.c b/timecop_php7.c index ff416dd..573689d 100644 --- a/timecop_php7.c +++ b/timecop_php7.c @@ -112,7 +112,10 @@ const zend_function_entry timecop_functions[] = { PHP_FE(timecop_getdate, arginfo_timecop_getdate) PHP_FE(timecop_localtime, arginfo_timecop_localtime) PHP_FE(timecop_strtotime, arginfo_timecop_strtotime) -#if PHP_VERSION_ID >= 80100 +#if PHP_VERSION_ID >= 80400 + ZEND_RAW_FENTRY("timecop_strftime", zif_timecop_strftime, arginfo_timecop_strftime, ZEND_ACC_DEPRECATED, NULL, NULL) + ZEND_RAW_FENTRY("timecop_gmstrftime", zif_timecop_gmstrftime, arginfo_timecop_gmstrftime, ZEND_ACC_DEPRECATED, NULL, NULL) +#elif PHP_VERSION_ID >= 80100 PHP_DEP_FE(timecop_strftime, arginfo_timecop_strftime) PHP_DEP_FE(timecop_gmstrftime, arginfo_timecop_gmstrftime) #else From 4c99f76510395dc505d31021dc56d07dd5be307c Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Fri, 21 Mar 2025 12:38:35 +0000 Subject: [PATCH 3/7] =?UTF-8?q?Remove=20support=20for=20`gmstrftime()`=20a?= =?UTF-8?q?nd=20`strftime()`=20on=20PHP=20=E2=89=A5=208.4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 ++-- php_timecop.h | 2 ++ tests/func_override_010.phpt | 1 + tests/func_override_011.phpt | 1 + tests/refl_002.phpt | 1 + tests/refl_002_php84.phpt | 43 ++++++++++++++++++++++++++++++++++++ timecop_php7.c | 8 +++++-- 7 files changed, 56 insertions(+), 4 deletions(-) create mode 100644 tests/refl_002_php84.phpt diff --git a/README.md b/README.md index 830cc4f..a0ce51e 100644 --- a/README.md +++ b/README.md @@ -48,8 +48,8 @@ extension=timecop.so - `getdate()` - `localtime()` - `strtotime()` - - `strftime()` - - `gmstrftime()` + - `strftime()` (PHP < 8.4.0) + - `gmstrftime()` (PHP < 8.4.0) - `microtime()` - `gettimeofday()` - `unixtojd()` diff --git a/php_timecop.h b/php_timecop.h index e57d232..4bda128 100644 --- a/php_timecop.h +++ b/php_timecop.h @@ -70,8 +70,10 @@ PHP_FUNCTION(timecop_idate); PHP_FUNCTION(timecop_getdate); PHP_FUNCTION(timecop_localtime); PHP_FUNCTION(timecop_strtotime); +#if PHP_VERSION_ID < 80400 PHP_FUNCTION(timecop_strftime); PHP_FUNCTION(timecop_gmstrftime); +#endif #ifdef HAVE_GETTIMEOFDAY PHP_FUNCTION(timecop_microtime); PHP_FUNCTION(timecop_gettimeofday); diff --git a/tests/func_override_010.phpt b/tests/func_override_010.phpt index df43b63..b2c1052 100644 --- a/tests/func_override_010.phpt +++ b/tests/func_override_010.phpt @@ -2,6 +2,7 @@ Function overrideing test for strftime --SKIPIF-- 'timecop_time', + 'date' => 'timecop_date', + 'gmdate' => 'timecop_gmdate', + 'idate' => 'timecop_idate', + 'getdate' => 'timecop_getdate', + 'localtime' => 'timecop_localtime', + 'strtotime' => 'timecop_strtotime', + 'date_create' => 'timecop_date_create', + 'date_create_from_format' => 'timecop_date_create_from_format', + 'date_create_immutable' => 'timecop_date_create_immutable', + 'date_create_immutable_from_format' => 'timecop_date_create_immutable_from_format', +]; + +require __DIR__.'/check-func-refl.inc.php'; + +--EXPECT-- +Checking time vs timecop_time +Checking date vs timecop_date +Checking gmdate vs timecop_gmdate +Checking idate vs timecop_idate +Checking getdate vs timecop_getdate +Checking localtime vs timecop_localtime +Checking strtotime vs timecop_strtotime +Checking date_create vs timecop_date_create +Checking date_create_from_format vs timecop_date_create_from_format +Checking date_create_immutable vs timecop_date_create_immutable +Checking date_create_immutable_from_format vs timecop_date_create_immutable_from_format diff --git a/timecop_php7.c b/timecop_php7.c index 573689d..0d69a33 100644 --- a/timecop_php7.c +++ b/timecop_php7.c @@ -69,8 +69,10 @@ static const struct timecop_override_func_entry timecop_override_func_table[] = TIMECOP_OFE("getdate"), TIMECOP_OFE("localtime"), TIMECOP_OFE("strtotime"), +#if PHP_VERSION_ID < 80400 TIMECOP_OFE("strftime"), TIMECOP_OFE("gmstrftime"), +#endif #ifdef HAVE_GETTIMEOFDAY TIMECOP_OFE("microtime"), TIMECOP_OFE("gettimeofday"), @@ -113,8 +115,6 @@ const zend_function_entry timecop_functions[] = { PHP_FE(timecop_localtime, arginfo_timecop_localtime) PHP_FE(timecop_strtotime, arginfo_timecop_strtotime) #if PHP_VERSION_ID >= 80400 - ZEND_RAW_FENTRY("timecop_strftime", zif_timecop_strftime, arginfo_timecop_strftime, ZEND_ACC_DEPRECATED, NULL, NULL) - ZEND_RAW_FENTRY("timecop_gmstrftime", zif_timecop_gmstrftime, arginfo_timecop_gmstrftime, ZEND_ACC_DEPRECATED, NULL, NULL) #elif PHP_VERSION_ID >= 80100 PHP_DEP_FE(timecop_strftime, arginfo_timecop_strftime) PHP_DEP_FE(timecop_gmstrftime, arginfo_timecop_gmstrftime) @@ -1145,6 +1145,8 @@ PHP_FUNCTION(timecop_strtotime) } /* }}} */ +#if PHP_VERSION_ID < 80400 + /* {{{ proto string timecop_strftime(string format [, int timestamp]) Format a local time/date according to locale settings */ PHP_FUNCTION(timecop_strftime) @@ -1177,6 +1179,8 @@ PHP_FUNCTION(timecop_gmstrftime) } /* }}} */ +#endif + /* * get_mock_timeval(fixed, now) * From 19a66257b3a3d5d4dd686ba210c88411eaea0ae4 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Fri, 21 Mar 2025 12:44:11 +0000 Subject: [PATCH 4/7] Fix test using deprecated syntax --- tests/issue_009.phpt | 1 + tests/issue_009_php71.phpt | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 tests/issue_009_php71.phpt diff --git a/tests/issue_009.phpt b/tests/issue_009.phpt index e71f071..22e5881 100644 --- a/tests/issue_009.phpt +++ b/tests/issue_009.phpt @@ -3,6 +3,7 @@ Check for issue #9 (Issue with using timecop constructor) --SKIPIF-- setTime(0, 0, 0); + } + + public function __toString() { + return $this->format('Y-m-d'); + } +} +timecop_freeze(strtotime("2010-01-01")); +$dt1 = new Date(); +echo $dt1, "\n"; +$dt2 = new Date("2020-12-31"); +echo $dt2, "\n"; +$dt3 = new Date("2030-06-15", new \DateTimeZone("UTC")); +echo $dt3, "\n"; +--EXPECT-- +2010-01-01 +2020-12-31 +2030-06-15 From 0bd28dcb49bc905e8666fffdd99f177589af1e66 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Fri, 21 Mar 2025 12:47:35 +0000 Subject: [PATCH 5/7] Add valgrind build for PHP 8.4 --- .github/workflows/valgrind.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/valgrind.yml b/.github/workflows/valgrind.yml index 4bcf9dd..f54e2b4 100644 --- a/.github/workflows/valgrind.yml +++ b/.github/workflows/valgrind.yml @@ -17,6 +17,7 @@ jobs: - '7.4.19' - '8.1.25' - '8.2.12' + - '8.4.5' os: - 'ubuntu-22.04' steps: @@ -62,6 +63,11 @@ jobs: gpg_fetch_key 39B641343D8C104B2B146DC3F9C39DC0B9698544 gpg_fetch_key E60913E4DF209907D8E30D96659A97C9CF2A795A ;; + 8.4.*) + gpg_fetch_key AFD8691FDAEDF03BDF6E460563F15A9B715376CA + gpg_fetch_key 9D7F99A0CB8F05C8A6958D6256A97AF7600A39A6 + gpg_fetch_key 0616E93D95AF471243E26761770426E17EBBB3DD + ;; *) echo "::warning::No keys imported!" ;; From a6b8db587c5fa84e39d61c81a128735393bf85e5 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Fri, 21 Mar 2025 12:49:46 +0000 Subject: [PATCH 6/7] Add missing valgrind build for PHP 8.3 --- .github/workflows/valgrind.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/valgrind.yml b/.github/workflows/valgrind.yml index f54e2b4..259d692 100644 --- a/.github/workflows/valgrind.yml +++ b/.github/workflows/valgrind.yml @@ -17,6 +17,7 @@ jobs: - '7.4.19' - '8.1.25' - '8.2.12' + - '8.3.19' - '8.4.5' os: - 'ubuntu-22.04' @@ -63,6 +64,11 @@ jobs: gpg_fetch_key 39B641343D8C104B2B146DC3F9C39DC0B9698544 gpg_fetch_key E60913E4DF209907D8E30D96659A97C9CF2A795A ;; + 8.3.*) + gpg_fetch_key 1198C0117593497A5EC5C199286AF1F9897469DC + gpg_fetch_key AFD8691FDAEDF03BDF6E460563F15A9B715376CA + gpg_fetch_key C28D937575603EB4ABB725861C0779DC5C0A9DE4 + ;; 8.4.*) gpg_fetch_key AFD8691FDAEDF03BDF6E460563F15A9B715376CA gpg_fetch_key 9D7F99A0CB8F05C8A6958D6256A97AF7600A39A6 From c2cec97c8732a47eaffacc2beceb1fbad09975ee Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Fri, 21 Mar 2025 12:56:05 +0000 Subject: [PATCH 7/7] Update README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a0ce51e..ebbdc2a 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ extension=timecop.so ## SYSTEM REQUIREMENTS - OS: Linux, macOS -- PHP: 5.6.x - 8.3.x +- PHP: 5.6.x - 8.4.x - SAPI: Apache, CLI - Other SAPIs are not tested, but there is no SAPI-dependent code. - non-ZTS(recommended), ZTS