5. Performances
● Machine used: 8x Intel(R) Xeon(R) CPU @ 2.20GHz (Powered by Google Cloud Platform
and running in an isolated container)
● OS: Ubuntu 16.04.3 LTS
● Docker Stack: Debian 8, Nginx 1.13.8, MariaDB 10.1.31
● PHP Engines: 5.6, 7.0, 7.1, 7.2
● HHVM: 3.24.2
● OPCache: For WordPress, Joomla, and Drupal, we used the official Docker image. For the
rest we used the same image setup with the OPcache enabled using the following
recommended php.ini settings.
20. New Features - PHP 7.0.X -
Scalar type declarations:
PHP 5.X PHP 7.0.X
21. New Features - PHP 7.0.X -
Scalar type declarations:
Type
Declaration
int float string bool object
int yes yes* yes^ yes no
float yes yes yes^ yes no
string yes^ yes yes yes yes~
bool yes yes yes yes no
* Only non-NaN floats between PHP_INT_MIN and PHP_INT_MAX accepted.
^ If it’s a numeric string
~ Only if object has a toString() method
22. New Features - PHP 7.0.X -
Scalar type declarations:
● By default, PHP will coerce values of the wrong type into the expected scalar type if possible. For
example, a function that is given an integer for a parameter that expects a string will get a variable of
type string.
Config strict types:
23. New Features - PHP 7.0.X -
Scalar type declarations:
Example with strict mode:
24. New Features - PHP 7.0.X -
Return type declarations:
● PHP 7 adds support for return type declarations. Similarly to argument type declarations, return type
declarations specify the type of the value that will be returned from a function. The same types are
available for return type declarations as are available for argument type declarations.
25. New Features - PHP 7.0.X -
Null coalescing operator:
● The null coalescing operator (??) has been added as syntactic sugar for the common case of needing to
use a ternary in conjunction with isset(). It returns its first operand if it exists and is not NULL; otherwise it
returns its second operand.
26. New Features - PHP 7.0.X -
Spaceship operator:
● The spaceship operator is used for comparing two expressions. It returns -1, 0 or 1 when $a is
respectively less than, equal to, or greater than $b. Comparisons are performed according to PHP's
usual type comparison rules.
27. New Features - PHP 7.0.X -
Constant arrays using define():
● Array constants can now be defined with define(). In PHP 5.6, they could only be defined with const.
28. New Features - PHP 7.0.X -
Anonymous classes:
● Support for anonymous classes has been
added via new class. These can be used in
place of full class definitions for throwaway
objects:
29. New Features - PHP 7.0.X -
Closure::call():
● Closure::call() is a more performant, shorthand way of temporarily binding an object scope to a closure
and invoking it.
30. New Features - PHP 7.0.X -
Filtered unserialize():
● This feature seeks to provide better security when unserializing objects on untrusted data. It prevents
possible code injections by enabling the developer to whitelist classes that can be unserialized.
31. New Features - PHP 7.0.X -
Group use declarations:
● Classes, functions and constants being imported from the same namespace can now be grouped
together in a single use statement.
32. New Features - PHP 7.0.X -
Other Features:
● Generator Return Expressions
● Integer division with intdiv()
● preg_replace_callback_array()
● IntlChar
● Unicode codepoint escape syntax
34. Deprecated - PHP 7.0.X -
PHP 4 style constructors:
● PHP 4 style constructors (methods that have the same name as the class they are defined in) are
deprecated, and will be removed in the future. PHP 7 will emit E_DEPRECATED if a PHP4 constructor
is the only constructor defined within a class. Classes that implement a __construct() method are
unaffected.
35. Deprecated - PHP 7.0.X -
Static calls to non-static methods:
● Static calls to methods that are not declared static are deprecated, and may be removed in the future.
36. Deprecated - PHP 7.0.X -
password_hash() salt option:
● The salt option for the password_hash() function has been deprecated to prevent developers from
generating their own (usually insecure) salts. The function itself generates a cryptographically secure
salt when no salt is provided by the developer - therefore custom salt generation should not be needed.
37. Deprecated - PHP 7.0.X -
Other Deprecated:
● capture_session_meta SSL context option.
● ldap_soft() function in library LDAP.
40. New Features - PHP 7.1.X
Nullable types:
● Type declarations for parameters and return values can now be marked as nullable by prefixing the
type name with a question mark. This signifies that as well as the specified type, NULL can be passed
as an argument, or returned as a value, respectively.
41. New Features - PHP 7.1.X -
Void functions:
● Type declarations for parameters and return values can now be marked as nullable by prefixing the
type name with a question mark. This signifies that as well as the specified type, NULL can be passed
as an argument, or returned as a value, respectively.
42. New Features - PHP 7.1.X -
Class constant visibility:
● Support for specifying the visibility of class constants has been added.
43. New Features - PHP 7.1.X -
Multi catch exception handling:
● Multiple exceptions per catch block may now be specified using the pipe character (|). This is useful for
when different exceptions from different class hierarchies are handled the same.
44. New Features - PHP 7.1.X -
Support for keys in list():
● You can now specify keys in list(), or its new shorthand [] syntax. This enables destructuring of arrays
with non-integer or non-sequential keys.
45. New Features - PHP 7.1.X -
Support for negative string offsets:
● Support for negative string offsets has been added to the string manipulation functions accepting
offsets, as well as to string indexing with [] or {}. In such cases, a negative offset is interpreted as being
an offset from the end of the string.
46. Deprecated - PHP 7.1.X -
Other Deprecated:
● iterable pseudo-type.
● Support for AEAD in ext/openssl.
● Convert callables to Closures with Closure::fromCallable()
51. New Features - PHP 7.2.X -
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.
52. New Features - PHP 7.2.X -
Abstract method overriding:
● Abstract methods can now be overridden when an abstract class extends another abstract class.
53. New Features - PHP 7.2.X -
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.
54. New Features - PHP 7.2.X -
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
55. New Features - PHP 7.2.X -
Other New Features:
● SQLite3 allows writing BLOBs.
● Oracle OCI8 Transparent Application Failover Callbacks.
● Enhancements to the ZIP extension.
● proc_nice() support on Windows.
57. Deprecates - PHP 7.2.X -
__autoload() method:
● The __autoload() method has been deprecated because it is inferior to spl_autoload_register() (due to it
not being able to chain autoloaders), and there is no interoperability between the two autoloading
styles.
58. Deprecates - PHP 7.2.X -
● create_function().
● parse_str() without a second argument.
● gmp_random() function.
● each() function.
● assert() with a string argument.
● ...
59. Deprecates - PHP 7.2.X -
__autoload() method:
● The __autoload() method has been deprecated because it is inferior to spl_autoload_register() (due to it
not being able to chain autoloaders), and there is no interoperability between the two autoloading
styles.