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:306504browse

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

<strong>Preloading</strong><strong>Preloading</strong> rfc

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.

<strong>Typed properties</strong> rfc

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.

<strong>Improved type variance</strong>(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 use covariant return types

class ParentType {}
class ChildType extends ParentType {}

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

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

and contravariantParameters.

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.

<strong>Foreign Function Interface</strong>(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.

<strong>Null</strong>Merge assignment operator rfc

Not this way:

$data[&#39;date&#39;] = $data[&#39;date&#39;] ?? new DateTime();

You can do this:

$data[&#39;date&#39;] ??= new DateTime();

Update: This feature is now merged into PHP 7.4.

Custom object serialization rfc

This RFC adds two new magic methods: __serialize and __unserialize. The differences between these methods and the __sleep and __wakeup methods are discussed in the RFC.

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

<strong>No more narrow margins</strong> rfc

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.

<strong>Reflection for references</strong> rfc

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 the ReflectionReference class to solve this problem.

Update: RFC passed, changes confirmed for PHP 7.4.

Addmb_str_split rfc

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

Always enabledext-hash rfc

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) Registry rfc

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

DEPRECATED<strong>ext/wwdx</strong> rfc

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 the Full 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 a DateTime or datetimevariable instance will no longer leave accessible properties on the object.

openssl_random_pseudo_bytes Will throw an exception in error conditions.

• Attempts to serialize a PDO or PDOStatement instance will generate an exception instead of a PDOException.

• Calling get_object_vars() on an ArrayObject instance will return the properties of the ArrayObject itself, 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