We can't find the internet
Attempting to reconnect
Something went wrong!
Hang in there while we get back on track
DPC2020: What's new in PHP 7.4, and coming up in PHP 8 - Derick Rethans
Discover the latest features in PHP 7.4 and PHP 8, including typed properties, attributes, and the JIT compiler, and learn how they can improve performance, flexibility, and debugging capabilities.
-
PHP 7.4 added typed properties, which can now be more effectively leveraged using the
mixed
type, allowing for more flexibility and serendipity. - PHP 8 introduces attributes, a new type of metadata that can be used to add custom behavior to classes and methods, similar to annotations in other languages.
- The JIT compiler in PHP 8 is able to optimize code to run natively on the CPU, potentially leading to significant performance improvements.
-
The
mixed
type allows for type promotion, where a narrower type can be upcast to a broader type. - Union types allow for the combination of multiple types in a single variable, and can be used to represent more nuanced types.
- Attributes use cases include providing metadata for debugging, logging, and caching.
- PHP 8’s attributes system is designed to be extensible and flexible, allowing for custom attribute types and behavior.
-
The
mixed
type is not exactly the same as Java’sObject
type, but is more general-purpose. -
The
mixed
type can be used to represent any value, including null and undefined types. - The JIT compiler is not perfect and may not always be able to optimize code, but it is designed to be more efficient than the traditional PHP interpreter.
- PHP 8’s attributes system is likely to be more widely adopted and used than PHP 7’s typed properties.
-
The
mixed
type is not a replacement for theobject
type, but rather a supplement to it. - PHP 8’s attributes system is designed to be more flexible and powerful than PHP 7’s typed properties.
-
The
mixed
type can be used to represent more complex types, such as arrays and objects. - PHP 8’s attributes system is designed to be more extensible and customizable than PHP 7’s typed properties.
- The JIT compiler is not limited to just compiling PHP code, it can also be used to compile other languages such as C.