2019-01-28 17:34:31 +08:00
|
|
|
PHP 8.0 UPGRADE NOTES
|
2012-03-06 04:14:04 +08:00
|
|
|
|
|
|
|
1. Backward Incompatible Changes
|
|
|
|
2. New Features
|
2014-05-01 18:27:38 +08:00
|
|
|
3. Changes in SAPI modules
|
|
|
|
4. Deprecated Functionality
|
|
|
|
5. Changed Functions
|
|
|
|
6. New Functions
|
|
|
|
7. New Classes and Interfaces
|
2015-02-10 15:56:18 +08:00
|
|
|
8. Removed Extensions and SAPIs
|
2014-05-01 18:27:38 +08:00
|
|
|
9. Other Changes to Extensions
|
|
|
|
10. New Global Constants
|
|
|
|
11. Changes to INI File Handling
|
2014-08-22 19:35:07 +08:00
|
|
|
12. Windows Support
|
2019-01-28 17:34:31 +08:00
|
|
|
13. Other Changes
|
|
|
|
14. Performance Improvements
|
2010-03-25 00:23:50 +08:00
|
|
|
|
2005-11-23 07:49:13 +08:00
|
|
|
|
2010-03-25 00:23:50 +08:00
|
|
|
========================================
|
2012-03-06 04:14:04 +08:00
|
|
|
1. Backward Incompatible Changes
|
2010-03-25 00:23:50 +08:00
|
|
|
========================================
|
2016-04-25 05:49:52 +08:00
|
|
|
|
2019-01-04 18:55:41 +08:00
|
|
|
- Core:
|
2019-01-29 19:14:54 +08:00
|
|
|
. Methods with the same name as the class are no longer interpreted as
|
|
|
|
constructors. The __construct() method should be used instead.
|
2019-01-29 23:03:24 +08:00
|
|
|
. Removed ability to call non-static methods statically.
|
2019-01-29 17:46:21 +08:00
|
|
|
. Removed (unset) cast.
|
2019-01-28 23:05:02 +08:00
|
|
|
. Removed track_errors ini directive. This means that $php_errormsg is no
|
|
|
|
longer available. The error_get_last() function may be used instead.
|
2019-01-29 20:36:26 +08:00
|
|
|
. Removed the ability to define case-insensitive constants. The third
|
|
|
|
argument to define() may no longer be true.
|
2019-01-31 19:25:51 +08:00
|
|
|
. Access to undefined constants now always results in an Error exception.
|
|
|
|
Previously, unqualified constant accesses resulted in a warning and were
|
|
|
|
interpreted as strings.
|
2019-01-30 20:35:36 +08:00
|
|
|
. Removed ability to specify an autoloader using an __autoload() function.
|
|
|
|
spl_autoload_register() should be used instead.
|
2019-01-30 22:54:35 +08:00
|
|
|
. Removed the $errcontext argument for custom error handlers.
|
2019-01-28 23:05:02 +08:00
|
|
|
. Removed create_function(). Anonymous functions may be used instead.
|
2019-01-29 00:12:32 +08:00
|
|
|
. Removed each(). foreach or ArrayIterator should be used instead.
|
2019-01-29 22:16:51 +08:00
|
|
|
. Removed ability to unbind $this from closures that were created from a
|
|
|
|
method, using Closure::fromCallable() or ReflectionMethod::getClosure().
|
2019-10-28 20:24:07 +08:00
|
|
|
. Also removed ability to unbind $this from proper closures that contain uses
|
|
|
|
of $this.
|
2019-11-04 20:02:28 +08:00
|
|
|
. Removed ability to use array_key_exists() with objects. Use one of isset()
|
|
|
|
or property_exists() instead.
|
2020-01-23 06:24:28 +08:00
|
|
|
. Made the behavior of array_key_exists() regarding the type of the key
|
2020-03-18 21:52:22 +08:00
|
|
|
parameter consistent with isset() and normal array access. All key types now use
|
|
|
|
the usual coercions and array/object keys throw a TypeError.
|
2019-01-29 08:08:10 +08:00
|
|
|
. Any array that has a number n as its first numeric key will use n+1 for
|
|
|
|
its next implicit key. Even if n is negative.
|
|
|
|
RFC: https://wiki.php.net/rfc/negative_array_index
|
2019-08-30 16:31:32 +08:00
|
|
|
. The default error_reporting level is now E_ALL. Previously it excluded
|
|
|
|
E_NOTICE and E_DEPRECATED.
|
2019-09-02 16:13:54 +08:00
|
|
|
. display_startup_errors is now enabled by default.
|
2019-10-15 17:46:48 +08:00
|
|
|
. Using "parent" inside a class that has no parent will now result in a
|
|
|
|
fatal compile-time error.
|
2018-11-27 04:20:03 +08:00
|
|
|
. The @ operator will no longer silence fatal errors (E_ERROR, E_CORE_ERROR,
|
|
|
|
E_COMPILE_ERROR, E_USER_ERROR, E_RECOVERABLE_ERROR, E_PARSE). Error handlers
|
|
|
|
that expect error_reporting to be 0 when @ is used, should be adjusted to
|
|
|
|
use a mask check instead:
|
|
|
|
|
|
|
|
// Replace
|
|
|
|
function my_error_handler($err_no, $err_msg, $filename, $linenum) {
|
2019-02-12 00:10:36 +08:00
|
|
|
if (error_reporting() == 0) {
|
2018-11-27 04:20:03 +08:00
|
|
|
return; // Silenced
|
|
|
|
}
|
|
|
|
// ...
|
|
|
|
}
|
|
|
|
|
|
|
|
// With
|
|
|
|
function my_error_handler($err_no, $err_msg, $filename, $linenum) {
|
2019-03-14 01:30:35 +08:00
|
|
|
if (!(error_reporting() & $err_no)) {
|
2018-11-27 04:20:03 +08:00
|
|
|
return; // Silenced
|
|
|
|
}
|
|
|
|
// ...
|
|
|
|
}
|
|
|
|
|
|
|
|
Additionally, care should be taken that error messages are not displayed in
|
|
|
|
production environments, which can result in information leaks. Please
|
|
|
|
ensure that display_errors=Off is used in conjunction with error logging.
|
2019-03-27 23:58:30 +08:00
|
|
|
. Inheritance errors due to incompatible method signatures (LSP violations)
|
|
|
|
will now always generate a fatal error. Previously a warning was generated
|
|
|
|
in some cases.
|
|
|
|
RFC: https://wiki.php.net/rfc/lsp_errors
|
2019-06-16 04:44:02 +08:00
|
|
|
. The precedence of the concatenation operator has changed relative to
|
2019-05-17 00:37:42 +08:00
|
|
|
bitshifts and addition as well as subtraction.
|
|
|
|
RFC: https://wiki.php.net/rfc/concatenation_precedence
|
2019-09-18 21:43:32 +08:00
|
|
|
. Arguments with a default-value that resolves to null at run-time will no
|
|
|
|
longer implicitly mark the argument type as nullable. Either use an explicit
|
|
|
|
nullable type, or an explicit null default value instead.
|
|
|
|
|
|
|
|
// Replace
|
|
|
|
function test(int $arg = CONST_RESOLVING_TO_NULL) {}
|
|
|
|
// With
|
|
|
|
function test(?int $arg = CONST_RESOLVING_TO_NULL) {}
|
|
|
|
// Or
|
|
|
|
function test(int $arg = null) {}
|
2019-09-27 20:47:23 +08:00
|
|
|
. A number of warnings have been converted into Error exceptions:
|
|
|
|
|
|
|
|
* Attempting to write to a property of a non-object. Previously this
|
|
|
|
implicitly created an stdClass object for null, false and empty strings.
|
|
|
|
* Attempting to append an element to an array for which the PHP_INT_MAX key
|
|
|
|
is already used.
|
|
|
|
* Attempting to use an invalid type (array or object) as an array key or
|
|
|
|
string offset.
|
2019-09-27 20:52:20 +08:00
|
|
|
* Attempting to write to an array index of a scalar value.
|
|
|
|
* Attempting to unpack a non-array/Traversable.
|
2019-09-27 20:47:23 +08:00
|
|
|
|
2019-10-01 19:20:42 +08:00
|
|
|
A number of notices have been converted into warnings:
|
|
|
|
|
|
|
|
* Attempting to read an undefined variable.
|
|
|
|
* Attempting to read an undefined property.
|
|
|
|
* Attempting to read a property of a non-object.
|
|
|
|
* Attempting to access an array index of a non-array.
|
|
|
|
* Attempting to convert an array to string.
|
|
|
|
* Attempting to use a resource as an array key.
|
|
|
|
* Attempting to use null, a boolean or a float as a string offset.
|
|
|
|
* Attempting to read an out-of-bounds string offset.
|
2020-01-09 07:38:47 +08:00
|
|
|
* Attempting to assign an empty string to a string offset.
|
2019-10-01 19:20:42 +08:00
|
|
|
|
|
|
|
RFC: https://wiki.php.net/rfc/engine_warnings
|
2020-01-09 07:38:47 +08:00
|
|
|
. Attempting to assign multiple bytes to a string offset will now emit a warning.
|
2019-10-02 18:24:11 +08:00
|
|
|
. Unexpected characters in source files (such as null bytes outside of
|
|
|
|
strings) will now result in a ParseError exception instead of a compile
|
|
|
|
warning.
|
2019-10-10 20:14:36 +08:00
|
|
|
. Uncaught exceptions now go through "clean shutdown", which means that
|
|
|
|
destructors will be called after an uncaught exception.
|
2020-02-07 18:36:52 +08:00
|
|
|
. Compile time fatal error "Only variables can be passed by reference" has been
|
|
|
|
delayed until run-time and converted to "Cannot pass parameter by reference"
|
|
|
|
exception.
|
|
|
|
. Some "Only variables should be passed by reference" notices have been converted
|
|
|
|
to "Cannot pass parameter by reference" exception.
|
2020-02-06 18:13:13 +08:00
|
|
|
. The generated name for anonymous classes has changed. It will now include
|
|
|
|
the name of the first parent or interface:
|
|
|
|
|
|
|
|
new class extends ParentClass {};
|
|
|
|
// -> ParentClass@anonymous
|
|
|
|
new class implements FirstInterface, SecondInterface {};
|
|
|
|
// -> FirstInterface@anonymous
|
|
|
|
new class {};
|
|
|
|
// -> class@anonymous
|
|
|
|
|
|
|
|
The name shown above is still followed by a null byte and and a unique
|
|
|
|
suffix.
|
2020-01-09 19:21:02 +08:00
|
|
|
. Declaring a required parameter after an optional one is deprecated. As an
|
|
|
|
exception, declaring a parameter of the form "Type $param = null" before
|
|
|
|
a required one continues to be allowed, because this pattern was sometimes
|
|
|
|
used to achieve nullable types in older PHP versions.
|
|
|
|
|
|
|
|
function test($a = [], $b) {} // Deprecated
|
|
|
|
function test(Foo $a = null, $b) {} // Allowed
|
2020-03-03 21:31:09 +08:00
|
|
|
. Non-absolute trait method references in trait alias adaptations are now
|
|
|
|
required to be unambiguous:
|
|
|
|
|
|
|
|
class X {
|
|
|
|
use T1, T2 {
|
|
|
|
func as otherFunc;
|
|
|
|
}
|
|
|
|
function func() {}
|
|
|
|
}
|
|
|
|
|
|
|
|
If both T1::func() and T2::func() exist, this code was previously silently
|
|
|
|
accepted, and func as assumed to refer to T1::func. Now it will generate a
|
|
|
|
fatal error instead, and either T1::func or T2::func needs to be written
|
|
|
|
explicitly.
|
2020-01-09 22:04:33 +08:00
|
|
|
. The signature of abstract methods defined in traits is now checked against
|
|
|
|
the implementing class method:
|
|
|
|
|
|
|
|
trait MyTrait {
|
|
|
|
abstract private function neededByTrait(): string;
|
|
|
|
}
|
|
|
|
|
|
|
|
class MyClass {
|
|
|
|
use MyTrait;
|
|
|
|
|
|
|
|
// Error, because of return type mismatch.
|
|
|
|
private function neededByTrait(): int { return 42; }
|
|
|
|
}
|
|
|
|
|
|
|
|
RFC: https://wiki.php.net/rfc/abstract_trait_method_validation
|
2019-01-23 01:07:46 +08:00
|
|
|
|
2019-02-19 23:53:40 +08:00
|
|
|
- COM:
|
|
|
|
. Removed the ability to import case-insensitive constants from type
|
|
|
|
libraries. The second argument to com_load_typelib() may no longer be false;
|
|
|
|
com.autoregister_casesensitive may no longer be disabled; case-insensitive
|
|
|
|
markers in com.typelib_file are ignored.
|
|
|
|
|
2019-01-30 19:53:08 +08:00
|
|
|
- Date:
|
|
|
|
. mktime() and gmmktime() now require at least one argument. time() can be
|
|
|
|
used to get the current timestamp.
|
|
|
|
|
2019-09-18 05:52:08 +08:00
|
|
|
- dom:
|
|
|
|
. Remove unimplemented classes from ext/dom that had no behavior and contained
|
|
|
|
test data. These classes have also been removed in the latest version of DOM
|
|
|
|
standard:
|
|
|
|
|
|
|
|
* DOMNameList
|
|
|
|
* DomImplementationList
|
|
|
|
* DOMConfiguration
|
|
|
|
* DomError
|
|
|
|
* DomErrorHandler
|
|
|
|
* DOMImplementationSource
|
|
|
|
* DOMLocator
|
|
|
|
* DOMUserDataHandler
|
|
|
|
* DOMTypeInfo
|
|
|
|
|
2019-01-30 19:58:26 +08:00
|
|
|
- Exif:
|
|
|
|
. Removed read_exif_data(). exif_read_data() should be used instead.
|
|
|
|
|
2019-01-29 18:01:03 +08:00
|
|
|
- Filter:
|
|
|
|
. The FILTER_FLAG_SCHEME_REQUIRED and FILTER_FLAG_HOST_REQUIRED flags for the
|
|
|
|
FILTER_VALIDATE_URL filter have been removed. The scheme and host are (and
|
|
|
|
have been) always required.
|
2019-07-08 16:49:34 +08:00
|
|
|
. The INPUT_REQUEST and INPUT_SESSION source for filter_input() etc have been
|
|
|
|
removed. These were never implemented and their use always generated a
|
|
|
|
warning.
|
2019-01-29 18:01:03 +08:00
|
|
|
|
2019-01-28 21:29:06 +08:00
|
|
|
- GD:
|
2019-09-28 01:47:24 +08:00
|
|
|
. The GD extension now uses objects as the underlying data structure for
|
|
|
|
images, rather than resources. These objects are completely opaque, i.e.
|
|
|
|
they don't have any methods.
|
2019-01-28 21:29:06 +08:00
|
|
|
. The deprecated function image2wbmp() has been removed.
|
|
|
|
RFC: https://wiki.php.net/rfc/image2wbmp
|
2019-01-28 21:50:52 +08:00
|
|
|
. The deprecated functions png2wbmp() and jpeg2wbmp() have been removed.
|
|
|
|
RFC: https://wiki.php.net/rfc/deprecate-png-jpeg-2wbmp
|
2019-01-30 23:46:36 +08:00
|
|
|
. The default $mode parameter of imagecropauto() no longer accepts -1.
|
|
|
|
IMG_CROP_DEFAULT should be used instead.
|
2019-01-28 21:29:06 +08:00
|
|
|
|
2019-01-28 23:05:02 +08:00
|
|
|
- GMP:
|
|
|
|
. gmp_random() has been removed. One of gmp_random_range() or
|
|
|
|
gmp_random_bits() should be used instead.
|
|
|
|
|
2020-03-17 20:58:17 +08:00
|
|
|
- Iconv:
|
|
|
|
. iconv() implementations which do not properly set errno in case of errors,
|
|
|
|
are no longer supported.
|
|
|
|
|
2019-01-28 22:18:01 +08:00
|
|
|
- Intl:
|
|
|
|
. The deprecated constant INTL_IDNA_VARIANT_2003 has been removed.
|
|
|
|
RFC: https://wiki.php.net/rfc/deprecate-and-remove-intl_idna_variant_2003
|
2019-01-30 23:33:59 +08:00
|
|
|
. The deprecated Normalizer::NONE constant has been removed.
|
2020-01-23 06:24:28 +08:00
|
|
|
. The IntlDateFormatter::RELATIVE_FULL, IntlDateFormatter::RELATIVE_LONG,
|
|
|
|
IntlDateFormatter::RELATIVE_MEDIUM, and IntlDateFormatter::RELATIVE_SHORT constants
|
|
|
|
have been added.
|
2019-01-28 22:18:01 +08:00
|
|
|
|
2019-02-04 20:04:46 +08:00
|
|
|
- LDAP:
|
|
|
|
. The deprecated function ldap_sort has been removed.
|
|
|
|
|
2019-01-28 23:05:02 +08:00
|
|
|
- Mbstring:
|
|
|
|
. The mbstring.func_overload directive has been removed. The related
|
|
|
|
MB_OVERLOAD_MAIL, MB_OVERLOAD_STRING, and MB_OVERLOAD_REGEX constants have
|
|
|
|
also been removed. Finally, the "func_overload" and "func_overload_list"
|
|
|
|
entries in mb_get_info() have been removed.
|
|
|
|
. mb_parse_str() can no longer be used without specifying a result array.
|
2019-01-29 00:19:05 +08:00
|
|
|
. A number of deprecated mbregex aliases have been removed. See the following
|
|
|
|
list for which functions should be used instead:
|
|
|
|
|
|
|
|
* mbregex_encoding() -> mb_regex_encoding()
|
|
|
|
* mbereg() -> mb_ereg()
|
|
|
|
* mberegi() -> mb_eregi()
|
|
|
|
* mbereg_replace() -> mb_ereg_replace()
|
|
|
|
* mberegi_replace() -> mb_eregi_replace()
|
|
|
|
* mbsplit() -> mb_split()
|
|
|
|
* mbereg_match() -> mb_ereg_match()
|
|
|
|
* mbereg_search() -> mb_ereg_search()
|
|
|
|
* mbereg_search_pos() -> mb_ereg_search_pos()
|
|
|
|
* mbereg_search_regs() -> mb_ereg_search_regs()
|
|
|
|
* mbereg_search_init() -> mb_ereg_search_init()
|
|
|
|
* mbereg_search_getregs() -> mb_ereg_search_getregs()
|
|
|
|
* mbereg_search_getpos() -> mb_ereg_search_getpos()
|
|
|
|
* mbereg_search_setpos() -> mb_ereg_search_setpos()
|
2019-01-28 23:05:02 +08:00
|
|
|
|
2019-01-29 19:40:01 +08:00
|
|
|
. The 'e' modifier for mb_ereg_replace() has been removed.
|
|
|
|
mb_ereg_replace_callback() should be used instead.
|
2019-02-01 22:18:28 +08:00
|
|
|
. A non-string pattern argument to mb_ereg_replace() will now be interpreted
|
|
|
|
as a string instead of an ASCII codepoint. The previous behavior may be
|
|
|
|
restored with an explicit call to chr().
|
2020-01-25 19:32:55 +08:00
|
|
|
. The needle argument for mb_strpos(), mb_strrpos(), mb_stripos(), mb_strripos(),
|
|
|
|
mb_strstr(), mb_stristr(), mb_strrchr() and mb_strrichr() can now be empty.
|
2019-09-21 22:25:17 +08:00
|
|
|
. The $is_hex parameter, which was not used internally, has been removed from
|
|
|
|
mb_decode_numericentity().
|
2019-12-14 03:09:42 +08:00
|
|
|
. The legacy behaviour of passing the encoding as the third argument instead of an offset for the mb_strrpos
|
|
|
|
function has been removed, provide an explicit 0 offset with the encoding as the fourth argument.
|
2019-01-29 19:40:01 +08:00
|
|
|
|
2019-07-17 15:30:22 +08:00
|
|
|
- PCRE:
|
2019-10-27 11:44:36 +08:00
|
|
|
. When passing invalid escape sequences they are no longer interpreted as
|
2019-07-17 15:30:22 +08:00
|
|
|
literals. This behaviour previously required the X modifier - which is
|
|
|
|
now ignored.
|
|
|
|
|
2019-02-14 15:15:27 +08:00
|
|
|
- PDO:
|
|
|
|
. The method PDOStatement::setFetchMode() now accepts the following signature:
|
|
|
|
|
2019-09-18 05:52:08 +08:00
|
|
|
PDOStatement::setFetchMode($mode, $classname, $params)
|
2019-02-14 15:15:27 +08:00
|
|
|
|
2019-03-01 07:41:19 +08:00
|
|
|
- PDO_ODBC:
|
|
|
|
. The php.ini directive pdo_odbc.db2_instance_name has been removed
|
|
|
|
|
2019-02-07 09:31:24 +08:00
|
|
|
- Reflection:
|
2019-02-11 16:54:08 +08:00
|
|
|
. The method signatures
|
2019-02-07 09:31:24 +08:00
|
|
|
|
2019-02-11 16:54:08 +08:00
|
|
|
ReflectionClass::newInstance($args)
|
|
|
|
ReflectionFunction::invoke($args)
|
|
|
|
ReflectionMethod::invoke($object, $args)
|
2019-02-07 09:31:24 +08:00
|
|
|
|
2019-02-11 16:54:08 +08:00
|
|
|
have been changed to:
|
|
|
|
|
|
|
|
ReflectionClass::newInstance(...$args)
|
|
|
|
ReflectionFunction::invoke(...$args)
|
|
|
|
ReflectionMethod::invoke($object, ...$args)
|
|
|
|
|
|
|
|
Code that must be compatible with both PHP 7 and PHP 8 can use the following
|
|
|
|
signatures to be compatible with both versions:
|
|
|
|
|
|
|
|
ReflectionClass::newInstance($arg = null, ...$args)
|
|
|
|
ReflectionFunction::invoke($arg = null, ...$args)
|
|
|
|
ReflectionMethod::invoke($object, $arg = null, ...$args)
|
2019-02-07 09:31:24 +08:00
|
|
|
|
2019-10-21 22:13:09 +08:00
|
|
|
. The ReflectionType::__toString() method will now return a complete debug
|
|
|
|
representation of the type, and is no longer deprecated. In particular the
|
|
|
|
result will include a nullability indicator for nullable types. The format
|
|
|
|
of the return value is not stable and may change between PHP versions.
|
2020-02-20 18:13:20 +08:00
|
|
|
. Reflection export() methods have been removed.
|
2020-04-06 17:02:13 +08:00
|
|
|
. The following methods can now return information about default values of
|
|
|
|
parameters of internal functions:
|
|
|
|
ReflectionParameter::isDefaultValueAvailable()
|
|
|
|
ReflectionParameter::getDefaultValue()
|
|
|
|
ReflectionParameter::isDefaultValueConstant()
|
|
|
|
ReflectionParameter::getDefaultValueConstantName()
|
2019-10-21 22:13:09 +08:00
|
|
|
|
2019-08-03 23:05:56 +08:00
|
|
|
- Socket:
|
|
|
|
. The deprecated AI_IDN_ALLOW_UNASSIGNED and AI_IDN_USE_STD3_ASCII_RULES
|
|
|
|
flags for socket_addrinfo_lookup() have been removed.
|
|
|
|
|
2019-01-29 00:40:39 +08:00
|
|
|
- SPL:
|
|
|
|
. SplFileObject::fgetss() has been removed.
|
2018-11-27 06:45:59 +08:00
|
|
|
. SplHeap::compare($a, $b) now specifies a method signature. Inheriting
|
|
|
|
classes implementing this method will now have to use a compatible
|
|
|
|
method signature.
|
2020-03-25 19:33:38 +08:00
|
|
|
. SplDoublyLinkedList::push() now returns void instead of true
|
|
|
|
. SplDoublyLinkedList::unshift() now returns void instead of true
|
|
|
|
. SplQueue::enqueue() now returns void instead of true
|
2019-01-29 00:40:39 +08:00
|
|
|
|
2019-01-28 23:05:02 +08:00
|
|
|
- Standard:
|
2019-01-28 23:35:04 +08:00
|
|
|
. assert() will no longer evaluate string arguments, instead they will be
|
|
|
|
treated like any other argument. assert($a == $b) should be used instead of
|
|
|
|
assert('$a == $b'). The assert.quiet_eval ini directive and
|
|
|
|
ASSERT_QUIET_EVAL constants have also been removed, as they would no longer
|
|
|
|
have any effect.
|
2019-01-28 23:05:02 +08:00
|
|
|
. parse_str() can no longer be used without specifying a result array.
|
2019-01-29 00:40:39 +08:00
|
|
|
. fgetss() has been removed.
|
|
|
|
. The string.strip_tags filter has been removed.
|
2019-01-29 17:02:03 +08:00
|
|
|
. The needle argument of strpos(), strrpos(), stripos(), strripos(), strstr(),
|
|
|
|
strchr(), strrchr(), and stristr() will now always be interpreted as a
|
|
|
|
string. Previously non-string needles were interpreted as an ASCII code
|
|
|
|
point. An explicit call to chr() can be used to restore the previous
|
|
|
|
behavior.
|
2020-01-25 19:32:55 +08:00
|
|
|
. The needle argument for strpos(), strrpos(), stripos(), strripos(), strstr(),
|
|
|
|
stristr() and strrchr() can now be empty.
|
2019-10-22 18:32:41 +08:00
|
|
|
. The length argument for substr(), substr_count(), substr_compare(), and
|
|
|
|
iconv_substr() can now be null. Null values will behave as if no length
|
|
|
|
argument was provided and will therefore return the remainder of the string
|
|
|
|
instead of an empty string.
|
2019-10-22 05:22:04 +08:00
|
|
|
. The length argument for array_splice() can now be null. Null values will
|
|
|
|
behave identically to omitting the argument, thus removing everything from
|
|
|
|
the 'offset' to the end of the array.
|
2019-01-30 19:20:25 +08:00
|
|
|
. The 'salt' option of password_hash() is no longer supported. If the 'salt'
|
|
|
|
option is used a warning is generated, the provided salt is ignored, and a
|
|
|
|
generated salt is used instead.
|
2019-02-11 16:58:10 +08:00
|
|
|
. The quotemeta() function will now return an empty string if an empty string
|
|
|
|
was passed. Previously false was returned.
|
2019-12-05 20:15:11 +08:00
|
|
|
. hebrevc() has been removed.
|
|
|
|
. convert_cyr_string() has been removed.
|
|
|
|
. money_format() has been removed.
|
|
|
|
. ezmlm_hash() has been removed.
|
2020-02-20 18:13:20 +08:00
|
|
|
. restore_include_path() has been removed.
|
2019-12-05 20:15:11 +08:00
|
|
|
. get_magic_quotes_gpc() and get_magic_quotes_gpc_runtime() has been removed.
|
|
|
|
. FILTER_SANITIZE_MAGIC_QUOTES has been removed.
|
2019-12-20 05:58:26 +08:00
|
|
|
. Calling implode() with parameters in a reverse order ($pieces, $glue) is no
|
|
|
|
longer supported.
|
2020-01-11 18:34:05 +08:00
|
|
|
. parse_url() will now distinguish absent and empty queries and fragments:
|
|
|
|
|
|
|
|
http://example.com/foo => query = null, fragment = null
|
|
|
|
http://example.com/foo? => query = "", fragment = null
|
|
|
|
http://example.com/foo# => query = null, fragment = ""
|
|
|
|
http://example.com/foo?# => query = "", fragment = ""
|
|
|
|
|
|
|
|
Previously all cases resulted in query and fragment being null.
|
2020-02-12 17:27:28 +08:00
|
|
|
. var_dump() and debug_zval_dump() will now print floating-point numbers
|
|
|
|
using serialize_precision rather than precision. In a default configuration,
|
|
|
|
this means that floating-point numbers are now printed with full accuracy
|
|
|
|
by these debugging functions.
|
2019-01-29 00:40:39 +08:00
|
|
|
|
2019-09-22 22:28:42 +08:00
|
|
|
- tidy:
|
|
|
|
. The $use_include_path parameter, which was not used internally, has been
|
|
|
|
removed from tidy_repair_string().
|
|
|
|
|
2018-09-16 16:45:08 +08:00
|
|
|
- XML:
|
|
|
|
. xml_parser_create(_ns) will now return an XmlParser object rather than a
|
|
|
|
resource. Return value checks using is_resource() should be replaced with
|
|
|
|
checks for `false`. The xml_parser_free() function no longer has an effect,
|
|
|
|
instead the XmlParser instance is automatically destroyed if it is no longer
|
|
|
|
referenced.
|
|
|
|
|
2019-09-15 00:31:59 +08:00
|
|
|
- XMLWriter:
|
|
|
|
. The XMLWriter functions now accept and return, respectively, XMLWriter
|
|
|
|
objects instead of resources.
|
|
|
|
|
2016-06-10 16:17:50 +08:00
|
|
|
- Zip:
|
2020-03-05 21:03:20 +08:00
|
|
|
. ZipArchive::OPSYS_Z_CPM have been removed, should use ZipArchive::OPSYS_CPM
|
|
|
|
(this name was a typo).
|
2016-06-10 16:17:50 +08:00
|
|
|
|
2019-01-29 00:40:39 +08:00
|
|
|
- Zlib:
|
|
|
|
. gzgetss() has been removed.
|
2019-01-28 23:05:02 +08:00
|
|
|
|
2012-03-06 04:14:04 +08:00
|
|
|
========================================
|
|
|
|
2. New Features
|
|
|
|
========================================
|
2009-01-29 01:23:28 +08:00
|
|
|
|
2019-09-10 20:18:53 +08:00
|
|
|
- Core:
|
2019-09-25 19:21:13 +08:00
|
|
|
. Added support for union types.
|
|
|
|
RFC: https://wiki.php.net/rfc/union_types_v2
|
2019-10-31 19:13:18 +08:00
|
|
|
. Added WeakMap.
|
|
|
|
RFC: https://wiki.php.net/rfc/weak_maps
|
2019-09-10 20:18:53 +08:00
|
|
|
. Added ValueError class.
|
2020-01-25 19:40:22 +08:00
|
|
|
. Any number of function parameters may now be replaced by a variadic
|
2020-01-06 19:06:51 +08:00
|
|
|
argument, as long as the types are compatible. For example, the following
|
|
|
|
code is now allowed:
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public function method(int $many, string $parameters, $here) {}
|
|
|
|
}
|
|
|
|
class B extends A {
|
|
|
|
public function method(...$everything) {}
|
|
|
|
}
|
2020-01-07 22:06:36 +08:00
|
|
|
. "static" (as in "late static binding") can now be used as a return type:
|
|
|
|
|
|
|
|
class Test {
|
|
|
|
public function create(): static {
|
|
|
|
return new static();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
RFC: https://wiki.php.net/rfc/static_return_type
|
2020-01-08 22:57:13 +08:00
|
|
|
. It is now possible to fetch the class name of an object using
|
|
|
|
`$object::class`. The result is the same as `get_class($object)`.
|
|
|
|
RFC: https://wiki.php.net/rfc/class_name_literal_on_object
|
2020-02-16 06:49:18 +08:00
|
|
|
. New and instanceof can now be used with arbitrary expressions, using
|
2020-02-11 19:44:43 +08:00
|
|
|
`new (expression)(...$args)` and `$obj instanceof (expression)`.
|
|
|
|
RFC: https://wiki.php.net/rfc/variable_syntax_tweaks
|
|
|
|
. Some consistency fixes to variable syntax have been applied, for example
|
|
|
|
writing `Foo::BAR::$baz` is now allowed.
|
|
|
|
RFC: https://wiki.php.net/rfc/variable_syntax_tweaks
|
2020-01-09 22:04:33 +08:00
|
|
|
. Added Stringable interface, which is automatically implemented if a class
|
|
|
|
defines a __toString() method.
|
2020-02-06 17:27:30 +08:00
|
|
|
RFC: https://wiki.php.net/rfc/stringable
|
2020-01-09 22:04:33 +08:00
|
|
|
. Traits can now define abstract private methods.
|
2020-01-06 19:06:51 +08:00
|
|
|
|
2019-12-16 21:31:14 +08:00
|
|
|
- Date:
|
|
|
|
. Added DateTime::createFromInterface() and
|
|
|
|
DateTimeImmutable::createFromInterface().
|
|
|
|
|
2020-02-29 00:35:54 +08:00
|
|
|
- dom:
|
|
|
|
. Introduce DOMParentNode and DOMChildNode with new traversal and manipulation APIs
|
|
|
|
RFC: https://wiki.php.net/rfc/dom_living_standard_api
|
|
|
|
|
2020-03-05 21:03:20 +08:00
|
|
|
- Zip:
|
2020-04-02 20:58:13 +08:00
|
|
|
. Extension updated to version 1.19.0
|
2020-03-05 21:03:20 +08:00
|
|
|
. New ZipArchive::lastId property to get index value of last added entry.
|
|
|
|
. Error can be checked after an archive is closed using ZipArchive::status,
|
|
|
|
ZipArchive::statusSys properties or ZipArchive::getStatusString() method.
|
2020-03-06 17:29:16 +08:00
|
|
|
. The remove_path option of ZipArchive::addGlob() and ::addPattern() is now
|
|
|
|
treated as arbitrary string prefix (for consistency with the add_path
|
|
|
|
option), whereas formerly it was treated as directory name.
|
2020-04-02 20:58:13 +08:00
|
|
|
. Optional compression / encryption features are listed in phpinfo.
|
2020-03-05 21:03:20 +08:00
|
|
|
|
2012-03-06 04:14:04 +08:00
|
|
|
========================================
|
2014-05-01 18:27:38 +08:00
|
|
|
3. Changes in SAPI modules
|
2012-03-06 04:14:04 +08:00
|
|
|
========================================
|
2009-01-29 01:23:28 +08:00
|
|
|
|
2020-01-03 23:29:12 +08:00
|
|
|
- CGI and FPM will now use CONTEXT_DOCUMENT_ROOT to scan for .user.ini files,
|
|
|
|
if it is defined. Otherwise, DOCUMENT_ROOT will be used as before. This
|
|
|
|
improves support for Apache mod_userdir and mod_alias.
|
|
|
|
|
2012-03-06 04:14:04 +08:00
|
|
|
========================================
|
2014-05-01 18:27:38 +08:00
|
|
|
4. Deprecated Functionality
|
2012-03-06 04:14:04 +08:00
|
|
|
========================================
|
2009-01-29 01:23:28 +08:00
|
|
|
|
2020-03-20 18:27:42 +08:00
|
|
|
- Zip:
|
|
|
|
. Using empty file as ZipArchive is deprecated. Libzip 1.6.0
|
|
|
|
do not accept empty files as valid zip archives any longer.
|
|
|
|
Existing workaround will be removed in next version.
|
|
|
|
|
2012-03-06 04:14:04 +08:00
|
|
|
========================================
|
2014-05-01 18:27:38 +08:00
|
|
|
5. Changed Functions
|
2012-03-06 04:14:04 +08:00
|
|
|
========================================
|
2009-06-24 03:40:31 +08:00
|
|
|
|
2020-03-05 21:03:20 +08:00
|
|
|
- Zip
|
2020-03-18 21:09:50 +08:00
|
|
|
. ZipArchive::addGlob and ZipArchive::addPattern methods accept more
|
|
|
|
values in the "options" array argument:
|
|
|
|
. flags
|
|
|
|
. comp_method
|
|
|
|
. comp_flags
|
|
|
|
. env_method
|
|
|
|
. enc_pasword
|
2020-03-05 21:03:20 +08:00
|
|
|
. ZipArchive::addEmptyDir, ZipArchive::addFile and aZipArchive::addFromString
|
|
|
|
methods have a new "flags" argument. This allow to manage name encoding
|
|
|
|
(ZipArchive::FL_ENC_*) and entry replacement (ZipArchive::FL_OVERWRITE)
|
2020-03-09 14:09:50 +08:00
|
|
|
. ZipArchive::extractTo now restore file modification time.
|
2020-03-05 21:03:20 +08:00
|
|
|
|
2012-03-06 04:14:04 +08:00
|
|
|
========================================
|
2014-05-01 18:27:38 +08:00
|
|
|
6. New Functions
|
2012-03-06 04:14:04 +08:00
|
|
|
========================================
|
2015-04-24 23:19:58 +08:00
|
|
|
|
2020-02-17 21:29:12 +08:00
|
|
|
- PCRE:
|
|
|
|
. Added preg_last_error_msg(), which returns a human-readable message for
|
|
|
|
the last PCRE error. It complements preg_last_error(), which returns an
|
|
|
|
integer enum instead.
|
|
|
|
|
2019-12-10 19:16:46 +08:00
|
|
|
- SQLite3:
|
|
|
|
. Add SQLite3::setAuthorizer() and respective class constants to set a
|
|
|
|
userland callback that will be used to authorize or not an action on the
|
|
|
|
database.
|
|
|
|
PR: https://github.com/php/php-src/pull/4797
|
|
|
|
|
2019-10-02 21:06:09 +08:00
|
|
|
- Standard:
|
2020-02-13 23:23:01 +08:00
|
|
|
. Added str_contains($haystack, $needle) function, which checks whether
|
|
|
|
$haystack contains $needle as a sub-string. It is equivalent to writing
|
|
|
|
strpos($haystack, $needle) !== false.
|
|
|
|
. Added fdiv() function, which performs a floating-point division under
|
2019-10-02 21:06:09 +08:00
|
|
|
IEEE 754 semantics. Division by zero is considered well-defined and
|
|
|
|
will return one of Inf, -Inf or NaN.
|
|
|
|
|
2020-03-05 21:03:20 +08:00
|
|
|
- Zip:
|
|
|
|
. ZipArchive::setMtimeName and ZipArchive::setMtimeIndex to set the
|
|
|
|
modification time of an entry.
|
|
|
|
. ZipArchive::setProgressCallback to provide updates during archive close.
|
|
|
|
. ZipArchive::setCancelCallback to allow cancellation during archive close.
|
|
|
|
. ZipArchive::replaceFile to replace an entry content.
|
2020-04-02 20:58:13 +08:00
|
|
|
. ZipArchive::isCompressionMethodSupported to check optional compression
|
|
|
|
features.
|
|
|
|
. ZipArchive::isEncryptionMethodSupported to check optional encryption
|
|
|
|
features.
|
2020-03-05 21:03:20 +08:00
|
|
|
|
2012-03-06 04:14:04 +08:00
|
|
|
========================================
|
2014-05-01 18:27:38 +08:00
|
|
|
7. New Classes and Interfaces
|
2012-03-06 04:14:04 +08:00
|
|
|
========================================
|
2009-01-29 01:23:28 +08:00
|
|
|
|
2017-03-23 23:14:39 +08:00
|
|
|
- Tokenizer:
|
|
|
|
. The new PhpToken class adds an object-based interface to the tokenizer.
|
|
|
|
It provides a more uniform and ergonomic representation, while being more
|
|
|
|
memory efficient and faster.
|
|
|
|
RFC: https://wiki.php.net/rfc/token_as_object
|
|
|
|
|
2012-03-06 04:14:04 +08:00
|
|
|
========================================
|
2015-02-10 15:56:18 +08:00
|
|
|
8. Removed Extensions and SAPIs
|
2012-03-06 04:14:04 +08:00
|
|
|
========================================
|
2009-01-29 01:23:28 +08:00
|
|
|
|
2012-03-06 04:14:04 +08:00
|
|
|
========================================
|
2014-05-01 18:27:38 +08:00
|
|
|
9. Other Changes to Extensions
|
2012-03-06 04:14:04 +08:00
|
|
|
========================================
|
2016-07-03 18:43:30 +08:00
|
|
|
|
2020-01-18 17:05:07 +08:00
|
|
|
- CURL:
|
|
|
|
. The CURL extension now requires at least libcurl 7.29.0.
|
|
|
|
|
2019-11-14 16:46:43 +08:00
|
|
|
- GD:
|
|
|
|
. The $num_points parameter of imagepolygon(), imageopenpolygon() and
|
|
|
|
imagefilledpolygon() is now optional, i.e. these functions may be called
|
|
|
|
with either 3 or 4 arguments. If the arguments is omitted, it is calculated
|
|
|
|
as count($points)/2.
|
2020-01-06 19:49:07 +08:00
|
|
|
. The function imagegetinterpolation() to get the current interpolation method
|
|
|
|
has been added.
|
2019-11-14 16:46:43 +08:00
|
|
|
|
2020-03-12 04:15:28 +08:00
|
|
|
- MBString:
|
|
|
|
. The Unicode data tables have been updated to version 13.0.0.
|
|
|
|
|
2012-03-06 04:14:04 +08:00
|
|
|
========================================
|
2014-05-01 18:27:38 +08:00
|
|
|
10. New Global Constants
|
2012-03-06 04:14:04 +08:00
|
|
|
========================================
|
2010-03-25 00:23:50 +08:00
|
|
|
|
2019-12-17 16:13:41 +08:00
|
|
|
- Filter:
|
|
|
|
. FILTER_VALIDATE_BOOL has been added as an alias for FILTER_VALIDATE_BOOLEAN.
|
|
|
|
The new name is preferred, as it uses the canonical type name.
|
|
|
|
|
2012-03-06 04:14:04 +08:00
|
|
|
========================================
|
2014-05-01 18:27:38 +08:00
|
|
|
11. Changes to INI File Handling
|
2012-03-06 04:14:04 +08:00
|
|
|
========================================
|
2010-08-30 17:38:47 +08:00
|
|
|
|
2014-08-22 19:35:07 +08:00
|
|
|
========================================
|
|
|
|
12. Windows Support
|
|
|
|
========================================
|
|
|
|
|
2020-01-21 17:05:33 +08:00
|
|
|
- Standard:
|
|
|
|
. Program execution functions (proc_open(), exec(), popen() etc.) using the
|
|
|
|
shell now consistently execute `%comspec% /s /c "$commandline"`, which has
|
|
|
|
the same effect as executing `$commandline` (without additional quotes).
|
|
|
|
|
2020-01-06 00:14:17 +08:00
|
|
|
- php-test-pack:
|
|
|
|
. The test runner has been renamed from run-test.php to run-tests.php, to
|
|
|
|
match its name in php-src.
|
|
|
|
|
2019-01-15 17:13:39 +08:00
|
|
|
========================================
|
2019-01-28 17:34:31 +08:00
|
|
|
13. Other Changes
|
2012-03-06 04:14:04 +08:00
|
|
|
========================================
|
2018-12-27 05:26:01 +08:00
|
|
|
|
|
|
|
========================================
|
2019-01-28 17:34:31 +08:00
|
|
|
14. Performance Improvements
|
2018-12-27 05:26:01 +08:00
|
|
|
========================================
|
|
|
|
|
2019-10-30 07:48:28 +08:00
|
|
|
- array_slice() on an array without gaps will no longer scan the whole array to find
|
2019-10-25 21:31:06 +08:00
|
|
|
the start offset. This may significantly reduce the runtime of the function
|
|
|
|
with large offsets and small lengths.
|