php-src/UPGRADING

326 lines
12 KiB
Plaintext
Raw Normal View History

PHP 8.0 UPGRADE NOTES
1. Backward Incompatible Changes
2. New Features
2014-05-01 10:27:38 +00:00
3. Changes in SAPI modules
4. Deprecated Functionality
5. Changed Functions
6. New Functions
7. New Classes and Interfaces
2015-02-10 07:56:18 +00:00
8. Removed Extensions and SAPIs
2014-05-01 10:27:38 +00:00
9. Other Changes to Extensions
10. New Global Constants
11. Changes to INI File Handling
2014-08-22 11:35:07 +00:00
12. Windows Support
13. Other Changes
14. Performance Improvements
2010-03-24 16:23:50 +00:00
2010-03-24 16:23:50 +00:00
========================================
1. Backward Incompatible Changes
2010-03-24 16:23:50 +00:00
========================================
- Core:
. Methods with the same name as the class are no longer interpreted as
constructors. The __construct() method should be used instead.
. Removed ability to call non-static methods statically.
. Removed (unset) cast.
. Removed track_errors ini directive. This means that $php_errormsg is no
longer available. The error_get_last() function may be used instead.
. Removed the ability to define case-insensitive constants. The third
argument to define() may no longer be true.
. Access to undefined constants now always results in an Error exception.
Previously, unqualified constant accesses resulted in a warning and were
interpreted as strings.
. Removed ability to specify an autoloader using an __autoload() function.
spl_autoload_register() should be used instead.
. Removed the $errcontext argument for custom error handlers.
. Removed create_function(). Anonymous functions may be used instead.
. Removed each(). foreach or ArrayIterator should be used instead.
2019-01-29 14:16:51 +00:00
. Removed ability to unbind $this from closures that were created from a
method, using Closure::fromCallable() or ReflectionMethod::getClosure().
2019-01-29 00:08:10 +00: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 08:31:32 +00:00
. The default error_reporting level is now E_ALL. Previously it excluded
E_NOTICE and E_DEPRECATED.
. display_startup_errors is now enabled by default.
2018-11-26 20:20:03 +00: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) {
if (error_reporting() == 0) {
2018-11-26 20:20:03 +00:00
return; // Silenced
}
// ...
}
// With
function my_error_handler($err_no, $err_msg, $filename, $linenum) {
2019-03-13 17:30:35 +00:00
if (!(error_reporting() & $err_no)) {
2018-11-26 20:20:03 +00: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.
. 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-15 20:44:02 +00:00
. The precedence of the concatenation operator has changed relative to
bitshifts and addition as well as subtraction.
RFC: https://wiki.php.net/rfc/concatenation_precedence
. 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) {}
. 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.
* Attempting to write to an index of a scalar value.
RFC: Part of https://wiki.php.net/rfc/engine_warnings
- 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.
- Date:
. mktime() and gmmktime() now require at least one argument. time() can be
used to get the current timestamp.
- 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 11:58:26 +00:00
- Exif:
. Removed read_exif_data(). exif_read_data() should be used instead.
- 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.
. 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.
- GD:
. The deprecated function image2wbmp() has been removed.
RFC: https://wiki.php.net/rfc/image2wbmp
. The deprecated functions png2wbmp() and jpeg2wbmp() have been removed.
RFC: https://wiki.php.net/rfc/deprecate-png-jpeg-2wbmp
2019-01-30 15:46:36 +00:00
. The default $mode parameter of imagecropauto() no longer accepts -1.
IMG_CROP_DEFAULT should be used instead.
- GMP:
. gmp_random() has been removed. One of gmp_random_range() or
gmp_random_bits() should be used instead.
- 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 15:33:59 +00:00
. The deprecated Normalizer::NONE constant has been removed.
- LDAP:
. The deprecated function ldap_sort has been removed.
- 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.
. 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()
. The 'e' modifier for mb_ereg_replace() has been removed.
mb_ereg_replace_callback() should be used instead.
. 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().
. The $is_hex parameter, which was not used internally, has been removed from
mb_decode_numericentity().
- PCRE:
. When passing invalid escape sequences they are no longer intepreted as
literals. This behaviour previously required the X modifier - which is
now ignored.
2019-02-14 07:15:27 +00:00
- PDO:
. The method PDOStatement::setFetchMode() now accepts the following signature:
PDOStatement::setFetchMode($mode, $classname, $params)
2019-02-14 07:15:27 +00:00
2019-02-28 23:41:19 +00:00
- PDO_ODBC:
. The php.ini directive pdo_odbc.db2_instance_name has been removed
- Reflection:
2019-02-11 08:54:08 +00:00
. The method signatures
2019-02-11 08:54:08 +00:00
ReflectionClass::newInstance($args)
ReflectionFunction::invoke($args)
ReflectionMethod::invoke($object, $args)
2019-02-11 08:54:08 +00: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)
- Socket:
. The deprecated AI_IDN_ALLOW_UNASSIGNED and AI_IDN_USE_STD3_ASCII_RULES
flags for socket_addrinfo_lookup() have been removed.
- SPL:
. SplFileObject::fgetss() has been removed.
2018-11-26 22:45:59 +00:00
. SplHeap::compare($a, $b) now specifies a method signature. Inheriting
classes implementing this method will now have to use a compatible
method signature.
- Standard:
. 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.
. parse_str() can no longer be used without specifying a result array.
. fgetss() has been removed.
. The string.strip_tags filter has been removed.
. 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.
. The needle argument for strpos(), strrpos(), stripos(), strripos(), strstr() and stristr() can now be empty.
. 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.
. The quotemeta() function will now return an empty string if an empty string
was passed. Previously false was returned.
- tidy:
. The $use_include_path parameter, which was not used internally, has been
removed from tidy_repair_string().
- 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.
- XMLWriter:
. The XMLWriter functions now accept and return, respectively, XMLWriter
objects instead of resources.
- Zlib:
. gzgetss() has been removed.
========================================
2. New Features
========================================
- Core:
. Added ValueError class.
========================================
2014-05-01 10:27:38 +00:00
3. Changes in SAPI modules
========================================
========================================
2014-05-01 10:27:38 +00:00
4. Deprecated Functionality
========================================
========================================
2014-05-01 10:27:38 +00:00
5. Changed Functions
========================================
2009-06-23 19:40:31 +00:00
========================================
2014-05-01 10:27:38 +00:00
6. New Functions
========================================
2015-04-24 15:19:58 +00:00
========================================
2014-05-01 10:27:38 +00:00
7. New Classes and Interfaces
========================================
========================================
2015-02-10 07:56:18 +00:00
8. Removed Extensions and SAPIs
========================================
========================================
2014-05-01 10:27:38 +00:00
9. Other Changes to Extensions
========================================
2016-07-03 10:43:30 +00:00
========================================
2014-05-01 10:27:38 +00:00
10. New Global Constants
========================================
2010-03-24 16:23:50 +00:00
========================================
2014-05-01 10:27:38 +00:00
11. Changes to INI File Handling
========================================
2014-08-22 11:35:07 +00:00
========================================
12. Windows Support
========================================
========================================
13. Other Changes
========================================
========================================
14. Performance Improvements
========================================