FOREIGN FUNCTION INTERFACE
•Enables the execution of C code directly from PHP
•Provides a FFI class to manage the bridge between C and PHP
•A C function can be executed as a PHP method of FFI class
Weak References allow the programmer to retain a reference to an object which does not prevent the
object from being destroyed; They are useful for implementing cache like structures.
Covariant Returns and Contravariant
COVARIANT RETURNS AND CONTRAVARIANT PARAMETERS
Variance is a property of class hierarchies describing how the types of a type constructor
•Invariant: if the type of the super-type constrain the type of the subtype.
•Covariant: if the ordering of types is preserved (types are ordered from
more specific to more generic).
•Contravariant: if it reverses the order (types are ordered from more
generic to more specific).
Currently, PHP has mostly invariant parameter and return types, with few exceptions. This
RFC proposes to allow covariance and contravariance on parameter types and return types.
In general, a type constructor can be:
"On server startup – before any application code is run – we may load a
certain set of PHP files into memory – and make their contents
“permanently available” to all subsequent requests that will be served by
that server. All the functions and classes defined in these files will be
available to requests out of the box, exactly like internal entities."
• Preloading is controlled by a specific php.ini directive: opcache.preload
• This directive specifies a PHP script to be compiled and executed at server start-up
• Each file to cache, should be added in this script using opcache_compile_file()
OPCache Preloading in Symfony
• Preloading disabled
• Naive preloading - all Laravel and application code
I found this benchmark by stitcher.io on Laravel project
• Preloading Optimised - dumped all classes used by `get_declared_classes()`
Requests per second Time per request
That's around a 25% performance gain compared to not using
preloading, and an 8% gain compared to using the naive approach.
• Restart the web server to update opcache.preload
• Not compatible with host running multiple applications, or multiple
versions of applications
Deprecate left-associative ternary operator
DEPRECATE LEFT-ASSOCIATIVE TERNARY OPERATOR
Unlike most other languages, the ternary operator in PHP is left-associative rather than right-associative.
Not only being uncommon, it is also confusing for programmers who switch between different languages.
PHP 7.4 proposes to remove the left-associativity and requires the use of parentheses instead.
• Starting from PHP 7.4, nested ternaries without explicit use of parentheses will throw a deprecation warning.
• Starting from PHP 8.0, there will be a compile runtime error.
PERFORMANCE OF PHP 7.4
• He compared the execution time of PHP7.4RC1 with PHP 7.1, 7.2 and 7.3
• He used Zendbench.php script as benchmark
I found this benchmark on PHP 7.X by Enrico Zimuel
• He took the total execution time
• Full experiment report here
PERFORMANCE OF PHP 7.4: RESULTS
PHP ver. Exec. time (in sec)
PERFORMANCE OF PHP 7.4: RESULTS
PHP 7.4 IS THE FASTEST!
• 7.4RC1 is 26% faster than 7.1.32
• 7.4RC1 is 22% faster than 7.2.22
• 7.4RC1 is 10% faster than 7.3.9