Skip to content

Support PHP 8.4 #33

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Mar 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ jobs:
- '8.1'
- '8.2'
- '8.3'
- '8.4'
php-zts:
- nts
- ts
Expand All @@ -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
Expand Down
12 changes: 12 additions & 0 deletions .github/workflows/valgrind.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ jobs:
- '7.4.19'
- '8.1.25'
- '8.2.12'
- '8.3.19'
- '8.4.5'
os:
- 'ubuntu-22.04'
steps:
Expand Down Expand Up @@ -62,6 +64,16 @@ 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
gpg_fetch_key 0616E93D95AF471243E26761770426E17EBBB3DD
;;
*)
echo "::warning::No keys imported!"
;;
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()`
Expand Down
2 changes: 2 additions & 0 deletions php_timecop.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions tests/func_override_010.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Function overrideing test for strftime
--SKIPIF--
<?php
$required_version_less_than = '8.4.0';
$required_func = array("timecop_strtotime", "timecop_freeze");
include(__DIR__."/tests-skipcheck.inc.php");
--INI--
Expand Down
1 change: 1 addition & 0 deletions tests/func_override_011.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Function overrideing test for gmstrftime
--SKIPIF--
<?php
$required_version_less_than = '8.4.0';
$required_func = array("timecop_strtotime", "timecop_freeze");
include(__DIR__."/tests-skipcheck.inc.php");
--INI--
Expand Down
1 change: 1 addition & 0 deletions tests/issue_009.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Check for issue #9 (Issue with using timecop constructor)
--SKIPIF--
<?php
$required_version = "5.3";
$required_version_less_than = '7.1';
$required_func = array("timecop_freeze");
$required_class = array("TimecopDateTime");
include(__DIR__."/tests-skipcheck.inc.php");
Expand Down
36 changes: 36 additions & 0 deletions tests/issue_009_php71.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
--TEST--
Check for issue #9 (Issue with using timecop constructor)
--SKIPIF--
<?php
$required_version = "7.1";
$required_func = array("timecop_freeze");
$required_class = array("TimecopDateTime");
include(__DIR__."/tests-skipcheck.inc.php");
--INI--
date.timezone=GMT
timecop.func_override=1
--FILE--
<?php
class Date extends \DateTime
{
public function __construct($time='now', ?\DateTimeZone $timezone=null)
{
parent::__construct($time, $timezone);
$this->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
1 change: 1 addition & 0 deletions tests/refl_002.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Check reflection data for overridden functions
--SKIPIF--
<?php
$required_version_less_than = '8.4.0';
$required_func = array();
$required_class = array();
$required_method = array();
Expand Down
43 changes: 43 additions & 0 deletions tests/refl_002_php84.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
--TEST--
Check reflection data for overridden functions
--SKIPIF--
<?php
$required_version = '8.4.0';
$required_func = array();
$required_class = array();
$required_method = array();
include(__DIR__."/tests-skipcheck.inc.php");
--INI--
date.timezone=America/Los_Angeles
timecop.func_override=0
--FILE--
<?php

$functions = [
'time' => '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
9 changes: 8 additions & 1 deletion timecop_php7.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down Expand Up @@ -112,7 +114,8 @@ 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
#elif PHP_VERSION_ID >= 80100
PHP_DEP_FE(timecop_strftime, arginfo_timecop_strftime)
PHP_DEP_FE(timecop_gmstrftime, arginfo_timecop_gmstrftime)
#else
Expand Down Expand Up @@ -1142,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)
Expand Down Expand Up @@ -1174,6 +1179,8 @@ PHP_FUNCTION(timecop_gmstrftime)
}
/* }}} */

#endif

/*
* get_mock_timeval(fixed, now)
*
Expand Down