New features
New object type
A new type, object, has been introduced that can be used for (contravariant) parameter typing and (covariant) return typing of any objects.
<?php
function test(object $obj) : object
{
return new SplQueue();
}
test(new StdClass());
Extension loading by name
Shared extensions no longer require their file extension (.so for Unix or .dll for Windows) to be specified. This is enabled in the php.ini file, as well as in the dl() function.
Abstract method overriding
Abstract methods can now be overridden when an abstract class extends another abstract class.
<?php
abstract class A
{
abstract function test(string $s);
}
abstract class B extends A
{
// overridden - still maintaining contravariance for parameters and covariance for return
abstract function test($s) : int;
}
Sodium is now a core extension
The modern Sodium cryptography library has now become a core extension in PHP.
For a complete function reference, see the Sodium chapter.
Password hashing with Argon2
Argon2 has been added to the password hashing API, where the following constants have been exposed:
-
PASSWORD_ARGON2I
-
PASSWORD_ARGON2_DEFAULT_MEMORY_COST
-
PASSWORD_ARGON2_DEFAULT_TIME_COST
-
PASSWORD_ARGON2_DEFAULT_THREADS
Extended string types for PDO
PDO's string type has been extended to support the national character type when emulating prepares. This has been done with the following constants:
-
PDO::PARAM_STR_NATL
-
PDO::PARAM_STR_CHAR
-
PDO::ATTR_DEFAULT_STR_PARAM
These constants are utilised by bitwise OR'ing them with
PDO::PARAM_STR
:
<?php
$db->quote('über', PDO::PARAM_STR | PDO::PARAM_STR_NATL);
Additional emulated prepares debugging information for PDO
The PDOStatement::debugDumpParams() method has been updated to include the SQL being sent to the DB, where the full, raw query (including the replaced placeholders with their bounded values) will be shown. This has been added to aid with debugging emulated prepares (and so it will only be available when emulated prepares are turned on).
Support for extended operations in LDAP
Support for EXOP has been added to the LDAP extension. This has been done by exposing the following functions and constants:
- ldap_parse_exop()
- ldap_exop()
- ldap_exop_passwd()
- ldap_exop_whoami()
-
LDAP_EXOP_START_TLS
-
LDAP_EXOP_MODIFY_PASSWD
-
LDAP_EXOP_REFRESH
-
LDAP_EXOP_WHO_AM_I
-
LDAP_EXOP_TURN
Address Information additions to the Sockets extension
The sockets extension now has the ability to lookup address information, as well as connect to it, bind to it, and explain it. The following four functions have been added for this:
Parameter type widening
Parameter types from overridden methods and from interface implementations may now be omitted. This is still in compliance with LSP, since parameters types are contravariant.
<?php
interface A
{
public function Test(array $input);
}
class B implements A
{
public function Test($input){} // type omitted for $input
}
Allow a trailing comma for grouped namespaces
A trailing comma can now be added to the group-use syntax introduced in PHP 7.0.
<?php
use Foo\Bar\{
Foo,
Bar,
Baz,
};
proc_nice() support on Windows
The proc_nice() function is now supported on Windows.
pack() and unpack() endian support
The pack() and unpack() functions now support float and double in both little and big endian.
Enhancements to the EXIF extension
The EXIF extension has been updated to support a much larger range of formats. This means that their format specific tags are now properly translated when parsing images with the exif_read_data() function. The following new formats are now supported:
- Samsung
- DJI
- Panasonic
- Sony
- Pentax
- Minolta
- Sigma/Foveon
- AGFA
- Kyocera
- Ricoh
- Epson
The EXIF functions exif_read_data() and exif_thumbnail() now support passing streams as their first argument.
New features in PCRE
- The J modifier for setting PCRE_DUPNAMES has been added.
SQLite3 allows writing BLOBs
SQLite3::openBlob() now allows to open BLOB fields in write mode; formerly only read mode was supported.
Oracle OCI8 Transparent Application Failover Callbacks
Support for Oracle Database Transparent Application Failover (TAF) callbacks has been added. TAF allows PHP OCI8 applications to automatically reconnect to a preconfigured database when a connection is broken. The new TAF callback support allows PHP applications to monitor and control reconnection during failover.
Enhancements to the ZIP extension
Read and write support for encrypted archives has been added (requires libzip 1.2.0).
The ZipArchive class now implements the Countable interface.
The zip:// stream now accepts a 'password' context option.
English translation
You have asked to visit this site in English. For now, only the interface is translated, but not all the content yet.If you want to help me in translations, your contribution is welcome. All you need to do is register on the site, and send me a message asking me to add you to the group of translators, which will give you the opportunity to translate the pages you want. A link at the bottom of each translated page indicates that you are the translator, and has a link to your profile.
Thank you in advance.
Document created the 30/01/2003, last modified the 26/10/2018
Source of the printed document:https://www.gaudry.be/en/php-rf-migration72.new-features.html
The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.
References
These references and links indicate documents consulted during the writing of this page, or which may provide additional information, but the authors of these sources can not be held responsible for the content of this page.
The author This site is solely responsible for the way in which the various concepts, and the freedoms that are taken with the reference works, are presented here. Remember that you must cross multiple source information to reduce the risk of errors.