Home>Article> PHP 7.4 expected to be released in December 2019

PHP 7.4 expected to be released in December 2019

藏色散人
藏色散人 Original
2019-03-27 11:33:30 6400browse

PHP 7.4 may be released in December 2019. This page will be updated regularly.

PreloadingPreloadingrfc

Preloading(preloading) is an amazing addition to PHP core that can bring some major performance improvements.

In short: If you are using a framework today, its files must be loaded and recompiled on every request. Preloading allows the server to load PHP files in memory on startup and make them permanently available to all subsequent requests.

The increased performance comes at a cost, of course: if the source of the preloaded files changes, the server must be restarted.

Typed propertiesrfc

Class variables can be type hints:

class A { public string $name; public Foo $foo; }

Update:To So far, Typed properties have been merged, confirming them for PHP 7.4.

Improved type variance(Improved type variance)rfc

I have written before Article about the PHP type system, so it's nice to see some improvements coming to the PHP core.

Type differences are a topic worthy of its own blog post;

In short: you will be able to usecovariantreturn types

class ParentType {} class ChildType extends ParentType {} class A { public function covariantReturnTypes(): ParentType { /* … */ } } class B extends A { public function covariantReturnTypes(): ChildType { /* … */ } }

andcontravariantParameters.

class A { public function contraVariantArguments(ChildType $type) { /* … */ } } class B extends A { public function contraVariantArguments(ParentType $type) { /* … */ } }

Update: The RFC is currently in the voting stage, but it looks like it will pass without any issues.

Foreign Function Interface(External Function Interface)rfc

Foreign Function Interface, referred to as FFI, allows calling C code from userland. This means that PHP extensions can be written in pure PHP.

It’s worth noting that this is a complex topic. You still need C knowledge to use this feature correctly.

NullMerge assignment operatorrfc

Not this way:

$data['date'] = $data['date'] ?? new DateTime();

You can do this:

$data['date'] ??= new DateTime();

Update: This feature is now merged into PHP 7.4.

Custom object serializationrfc

This RFC adds two new magic methods:__serializeand__unserialize. The differences between these methods and the__sleepand__wakeupmethods are discussed in the RFC.

Update: RFC passed. This feature will be added in PHP 7.4.

No more narrow marginsrfc

Technically, this is not an update related to PHP 7.4 , but it's certainly worth mentioning. The voting rules for RFCs have changed: they always require a 2/3 majority to pass.

Reflection for referencesrfc

Libraries like Symfony’s var dumper heavily rely on Reflection API to dump variables reliably. Previously, there was no proper reflection support for references, causing these libraries to rely on hacks to detect references.

PHP 7.4 added theReflectionReferenceclass to solve this problem.

Update: RFC passed, changes confirmed for PHP 7.4.

Addmb_str_splitrfc

This function provides the same functionality as str_split, but on multi-byte characters On skewers.

Always enabledext-hashrfc

As the title says, this extension is now included in all PHP installations is permanently available.

Not enabled by defaultPEAR

Since PEAR is no longer actively maintained, the core team decided to remove its default installation with PHP 7.4.

Password Hashing(Hashing) Registryrfc

Internal Change Hash Library way to make it easier for users to use them.

DEPRECATEDext/wwdxrfc

This data exchange format has never been standardized However, its extension is now deprecated.

Upgrading Backward-Incompatible Changes

When upgrading a PHP version, you should always review theFull Upgrade Documentation.

Here are some of the backwards-incompatible changes highlighted:

parent::Referencing in a class without a parent will generate a compile-time error instead Runtime error.

• Calling var_dump on aDateTimeordatetimevariableinstance will no longer leave accessible properties on the object.

openssl_random_pseudo_bytesWill throw an exception in error conditions.

• Attempts to serialize aPDOorPDOStatementinstance will generate an exception instead of aPDOException.

• Callingget_object_vars()on anArrayObjectinstance will return the properties of theArrayObjectitself, not the values of the wrapped array or object . Note that (array) casts are not affected.

Translated from: https://stitcher.io/blog/new-in-php-74#reflection-for-references-rfc

Related recommendations:

The difference in security between PHP7 and PHP5 (example)

Changes brought about by the Abstract Syntax Tree (AST) of PHP7

The execution principle of PHP7 language (PHP7 source code analysis)

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn