Skip to content
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
19 changes: 19 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,28 @@ PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? ????, PHP 8.5.0beta1

- Core:
. Non-canonical cast names (boolean), (integer), (double), and (binary) have
been deprecated. (Girgias)

- FileInfo
. The finfo_close() function has been deprecated. (timwolla)

- MySQLi:
. The mysqli_execute() alias function has been deprecated. (timwolla)

- PDO:
. The "uri:" DSN scheme has been deprecated due to security concerns with
DSNs coming from remote URIs. (timwolla)

- Reflection:
. Fixed bug GH-17927 (Reflection: have some indication of property hooks in
`_property_string()`). (DanielEScherzer)
. The setAccessible() methods of various Reflection objects have been
deprecated, as those no longer have an effect. (timwolla)

- Standard:
. The socket_set_timeout() alias function has been deprecated. (timwolla)

31 Jul 2025, PHP 8.5.0alpha4

Expand Down
29 changes: 29 additions & 0 deletions UPGRADING
Original file line number Diff line number Diff line change
Expand Up @@ -316,12 +316,41 @@ PHP 8.5 UPGRADE NOTES
one will still be used. If a user output handler returns a non-string and
produces output, the warning about producing an output is emitted first.
RFC: https://wiki.php.net/rfc/deprecations_php_8_4
. Non-canonical cast names (boolean), (integer), (double), and (binary) have
been deprecated, use (bool), (int), (float), and (string) respectively.
RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_non-standard_cast_names

- FileInfo:
. The finfo_close() function has been deprecated.
As finfo objects are freed automatically.
RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_finfo_close

- Hash:
. The MHASH_* constants have been deprecated. These have been overlooked
when the mhash*() function family has been deprecated per
https://wiki.php.net/rfc/deprecations_php_8_1#mhash_function_family

- MySQLi:
. The mysqli_execute() alias function has been deprecated.
Use mysqli_stmt_execute() instead.
RFC: https://wiki.php.net/rfc/deprecations_php_8_5#formally_deprecate_mysqli_execute

- PDO:
. The "uri:" DSN scheme has been deprecated due to security concerns with
DSNs coming from remote URIs.
RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_pdo_s_urischeme


- Reflection:
. The setAccessible() methods of various Reflection objects have been
deprecated, as those no longer have an effect.
RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_reflectionsetaccessible

- Standard:
. The socket_set_timeout() alias function has been deprecated.
Use stream_set_timeout() instead.
RFC: https://wiki.php.net/rfc/deprecations_php_8_5#formally_deprecate_socket_set_timeout

========================================
5. Changed Functions
========================================
Expand Down
4 changes: 2 additions & 2 deletions Zend/tests/type_casts/cast_to_double.phpt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--TEST--
casting different variables to double
casting different variables to float
--INI--
precision=14
--FILE--
Expand Down Expand Up @@ -32,7 +32,7 @@ $vars = array(
);

foreach ($vars as $var) {
$tmp = (double)$var;
$tmp = (float)$var;
var_dump($tmp);
}

Expand Down
11 changes: 11 additions & 0 deletions Zend/tests/type_casts/non_canonical_binary_cast.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--TEST--
Non canonical (binary) cast
--FILE--
<?php

var_dump((binary) 42);

?>
--EXPECTF--
Deprecated: Non-canonical cast (binary) is deprecated, use the (string) cast instead in %s on line %d
int(42)
11 changes: 11 additions & 0 deletions Zend/tests/type_casts/non_canonical_boolean_cast.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--TEST--
Non canonical (boolean) cast
--FILE--
<?php

var_dump((boolean) 42);

?>
--EXPECTF--
Deprecated: Non-canonical cast (boolean) is deprecated, use the (bool) cast instead in %s on line %d
int(42)
11 changes: 11 additions & 0 deletions Zend/tests/type_casts/non_canonical_double_cast.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--TEST--
Non canonical (double) cast
--FILE--
<?php

var_dump((double) 42);

?>
--EXPECTF--
Deprecated: Non-canonical cast (double) is deprecated, use the (float) cast instead in %s on line %d
int(42)
11 changes: 11 additions & 0 deletions Zend/tests/type_casts/non_canonical_integer_cast.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--TEST--
Non canonical (integer) cast
--FILE--
<?php

var_dump((integer) "42");

?>
--EXPECTF--
Deprecated: Non-canonical cast (integer) is deprecated, use the (int) cast instead in %s on line %d
int(42)
2 changes: 1 addition & 1 deletion Zend/zend_ast.c
Original file line number Diff line number Diff line change
Expand Up @@ -2310,7 +2310,7 @@ static ZEND_COLD void zend_ast_export_ex(smart_str *str, zend_ast *ast, int prio
case IS_NULL: PREFIX_OP("(unset)", 240, 241);
case _IS_BOOL: PREFIX_OP("(bool)", 240, 241);
case IS_LONG: PREFIX_OP("(int)", 240, 241);
case IS_DOUBLE: PREFIX_OP("(double)", 240, 241);
case IS_DOUBLE: PREFIX_OP("(float)", 240, 241);
case IS_STRING: PREFIX_OP("(string)", 240, 241);
case IS_ARRAY: PREFIX_OP("(array)", 240, 241);
case IS_OBJECT: PREFIX_OP("(object)", 240, 241);
Expand Down
2 changes: 1 addition & 1 deletion Zend/zend_language_parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ static YYSIZE_T zend_yytnamerr(char*, const char*);
%token T_INC "'++'"
%token T_DEC "'--'"
%token T_INT_CAST "'(int)'"
%token T_DOUBLE_CAST "'(double)'"
%token T_DOUBLE_CAST "'(float)'"
%token T_STRING_CAST "'(string)'"
%token T_ARRAY_CAST "'(array)'"
%token T_OBJECT_CAST "'(object)'"
Expand Down
36 changes: 32 additions & 4 deletions Zend/zend_language_scanner.l
Original file line number Diff line number Diff line change
Expand Up @@ -1629,14 +1629,28 @@ OPTIONAL_WHITESPACE_OR_COMMENTS ({WHITESPACE}|{MULTI_LINE_COMMENT}|{SINGLE_LINE_
RETURN_TOKEN_WITH_IDENT(T_VAR);
}

<ST_IN_SCRIPTING>"("{TABS_AND_SPACES}("int"|"integer"){TABS_AND_SPACES}")" {
<ST_IN_SCRIPTING>"("{TABS_AND_SPACES}("int"){TABS_AND_SPACES}")" {
RETURN_TOKEN(T_INT_CAST);
}

<ST_IN_SCRIPTING>"("{TABS_AND_SPACES}("double"|"float"){TABS_AND_SPACES}")" {
<ST_IN_SCRIPTING>"("{TABS_AND_SPACES}("integer"){TABS_AND_SPACES}")" {
if (PARSER_MODE()) {
zend_error(E_DEPRECATED, "Non-canonical cast (integer) is deprecated, use the (int) cast instead");
}
RETURN_TOKEN(T_INT_CAST);
}

<ST_IN_SCRIPTING>"("{TABS_AND_SPACES}("float"){TABS_AND_SPACES}")" {
RETURN_TOKEN(T_DOUBLE_CAST);
}

<ST_IN_SCRIPTING>"("{TABS_AND_SPACES}("double"){TABS_AND_SPACES}")" {
if (PARSER_MODE()) {
zend_error(E_DEPRECATED, "Non-canonical cast (double) is deprecated, use the (float) cast instead");
}
RETURN_TOKEN(T_INT_CAST);
}

<ST_IN_SCRIPTING>"("{TABS_AND_SPACES}"real"{TABS_AND_SPACES}")" {
if (PARSER_MODE()) {
zend_throw_exception(zend_ce_parse_error, "The (real) cast has been removed, use (float) instead", 0);
Expand All @@ -1645,10 +1659,17 @@ OPTIONAL_WHITESPACE_OR_COMMENTS ({WHITESPACE}|{MULTI_LINE_COMMENT}|{SINGLE_LINE_
RETURN_TOKEN(T_DOUBLE_CAST);
}

<ST_IN_SCRIPTING>"("{TABS_AND_SPACES}("string"|"binary"){TABS_AND_SPACES}")" {
<ST_IN_SCRIPTING>"("{TABS_AND_SPACES}("string"){TABS_AND_SPACES}")" {
RETURN_TOKEN(T_STRING_CAST);
}

<ST_IN_SCRIPTING>"("{TABS_AND_SPACES}("binary"){TABS_AND_SPACES}")" {
if (PARSER_MODE()) {
zend_error(E_DEPRECATED, "Non-canonical cast (binary) is deprecated, use the (string) cast instead");
}
RETURN_TOKEN(T_INT_CAST);
}

<ST_IN_SCRIPTING>"("{TABS_AND_SPACES}"array"{TABS_AND_SPACES}")" {
RETURN_TOKEN(T_ARRAY_CAST);
}
Expand All @@ -1657,10 +1678,17 @@ OPTIONAL_WHITESPACE_OR_COMMENTS ({WHITESPACE}|{MULTI_LINE_COMMENT}|{SINGLE_LINE_
RETURN_TOKEN(T_OBJECT_CAST);
}

<ST_IN_SCRIPTING>"("{TABS_AND_SPACES}("bool"|"boolean"){TABS_AND_SPACES}")" {
<ST_IN_SCRIPTING>"("{TABS_AND_SPACES}("bool"){TABS_AND_SPACES}")" {
RETURN_TOKEN(T_BOOL_CAST);
}

<ST_IN_SCRIPTING>"("{TABS_AND_SPACES}("boolean"){TABS_AND_SPACES}")" {
if (PARSER_MODE()) {
zend_error(E_DEPRECATED, "Non-canonical cast (boolean) is deprecated, use the (bool) cast instead");
}
RETURN_TOKEN(T_INT_CAST);
}

<ST_IN_SCRIPTING>"("{TABS_AND_SPACES}("unset"){TABS_AND_SPACES}")" {
RETURN_TOKEN(T_UNSET_CAST);
}
Expand Down
20 changes: 8 additions & 12 deletions ext/date/php_date.c
Original file line number Diff line number Diff line change
Expand Up @@ -3970,40 +3970,36 @@ PHP_FUNCTION(date_diff)

static bool timezone_initialize(php_timezone_obj *tzobj, const zend_string *tz_zstr, char **warning_message) /* {{{ */
{
timelib_time *dummy_t = ecalloc(1, sizeof(timelib_time));
timelib_time dummy_t = {0};
int dst, not_found;
const char *tz = ZSTR_VAL(tz_zstr);

ZEND_ASSERT(!zend_str_has_nul_byte(tz_zstr) && "timezone should have been checked to not have null bytes");

dummy_t->z = timelib_parse_zone(&tz, &dst, dummy_t, &not_found, DATE_TIMEZONEDB, php_date_parse_tzfile_wrapper);
if ((dummy_t->z >= (100 * 60 * 60)) || (dummy_t->z <= (-100 * 60 * 60))) {
dummy_t.z = timelib_parse_zone(&tz, &dst, &dummy_t, &not_found, DATE_TIMEZONEDB, php_date_parse_tzfile_wrapper);
if ((dummy_t.z >= (100 * 60 * 60)) || (dummy_t.z <= (-100 * 60 * 60))) {
if (warning_message) {
spprintf(warning_message, 0, "Timezone offset is out of range (%s)", ZSTR_VAL(tz_zstr));
}
timelib_free(dummy_t->tz_abbr);
efree(dummy_t);
timelib_free(dummy_t.tz_abbr);
return false;
}
dummy_t->dst = dst;
dummy_t.dst = dst;
if (!not_found && (*tz != '\0')) {
if (warning_message) {
spprintf(warning_message, 0, "Unknown or bad timezone (%s)", ZSTR_VAL(tz_zstr));
}
timelib_free(dummy_t->tz_abbr);
efree(dummy_t);
timelib_free(dummy_t.tz_abbr);
return false;
}
if (not_found) {
if (warning_message) {
spprintf(warning_message, 0, "Unknown or bad timezone (%s)", ZSTR_VAL(tz_zstr));
}
efree(dummy_t);
return false;
} else {
set_timezone_from_timelib_time(tzobj, dummy_t);
timelib_free(dummy_t->tz_abbr);
efree(dummy_t);
set_timezone_from_timelib_time(tzobj, &dummy_t);
timelib_free(dummy_t.tz_abbr);
return true;
}
} /* }}} */
Expand Down
3 changes: 2 additions & 1 deletion ext/fileinfo/fileinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@
#include "php_ini.h"
#include "ext/standard/info.h"
#include "ext/standard/file.h" /* needed for context stuff */
#include "Zend/zend_attributes.h"
#include "Zend/zend_exceptions.h"
#include "php_fileinfo.h"
#include "fileinfo_arginfo.h"
#include "fopen_wrappers.h" /* needed for is_url */
#include "Zend/zend_exceptions.h"

static zend_object_handlers finfo_object_handlers;
zend_class_entry *finfo_class_entry;
Expand Down
1 change: 1 addition & 0 deletions ext/fileinfo/fileinfo.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ public function set_flags(int $flags): true {}
/** @refcount 1 */
function finfo_open(int $flags = FILEINFO_NONE, ?string $magic_database = null): finfo|false {}

#[\Deprecated(since: '8.5', message: 'as finfo objects are freed automatically')]
function finfo_close(finfo $finfo): true {}

function finfo_set_flags(finfo $finfo, int $flags): true {}
Expand Down
12 changes: 10 additions & 2 deletions ext/fileinfo/fileinfo_arginfo.h

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

2 changes: 2 additions & 0 deletions ext/fileinfo/tests/finfo_close_basic.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ unset( $finfo );
*** Testing finfo_close() : basic functionality ***
object(finfo)#%d (0) {
}

Deprecated: Function finfo_close() is deprecated since 8.5, as finfo objects are freed automatically in %s on line %d
bool(true)
object(finfo)#%d (%d) {
}
4 changes: 3 additions & 1 deletion ext/fileinfo/tests/finfo_close_error.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ try {
}

?>
--EXPECT--
--EXPECTF--
*** Testing finfo_close() : error conditions ***

-- Testing finfo_close() function with wrong resource type --

Deprecated: Function finfo_close() is deprecated since 8.5, as finfo objects are freed automatically in %s on line %d
finfo_close(): Argument #1 ($finfo) must be of type finfo, resource given
7 changes: 2 additions & 5 deletions ext/intl/calendar/calendar.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,10 @@ class IntlCalendar
private function __construct() {}

/**
* @param IntlTimeZone|DateTimeZone|string|null $timezone
* @tentative-return-type
* @alias intlcal_create_instance
*/
public static function createInstance($timezone = null, ?string $locale = null): ?IntlCalendar {}
public static function createInstance(IntlTimeZone|DateTimeZone|string|null $timezone = null, ?string $locale = null): ?IntlCalendar {}

/**
* @tentative-return-type
Expand Down Expand Up @@ -355,11 +354,9 @@ public function setSkippedWallTimeOption(int $option): true {}
public function setTime(float $timestamp): bool {}

/**
* @param IntlTimeZone|DateTimeZone|string|null $timezone
* @tentative-return-type
* @alias intlcal_set_time_zone
*/
public function setTimeZone($timezone): bool {}
public function setTimeZone(IntlTimeZone|DateTimeZone|string|null $timezone): bool {}

/**
* @tentative-return-type
Expand Down
Loading