Recently, the PHP development team voted on a new deprecation for PHP 7.4, which should be released at the end of November. Now the first beta version has been released with fixed functionality. The current version not only provides newly selected Deprecations, but also provides some BugFix.
The PHP development team has released the first beta version of PHP 7.4. This determines functionality. PHP 7.4beta1 brings some BugFix in addition to new Deprecations. We are working on changes for the new version.
PHP 7.4beta1 has new deprecations
Previously, PHP allowed square brackets and curly braces to be used interchangeably to access array elements and string offsets. Example from PHP's internal PHP RFC to illustrate:
$array = [1, 2]; echo $array[1]; // prints 2 echo $array{1}; // also prints 2 $string = "foo"; echo $string[0]; // prints "f" echo $string{0}; // also prints "f"
This part is causing confusion and problems. For example, curly braces cannot be used to write elements to an array:
$array[] = 3; echo $array[2]; // prints 3 $array{} = 3; // Parse error: syntax error, unexpected '}'
Nor can you create an array using curly brace syntax:
$array = [1, 2]; // works $array = {1, 2}; // Parse error: syntax error, unexpected '{'
It turns out that it is difficult to use for list mapping:
[$one, $two] = $array; // works {$one, $two} = $array; // Parse error: syntax error, unexpected ','
As a result, the curly brace syntax is now marked as deprecated and therefore not recommended when using array or string offsets from the released beta.
PHP 7.4beta 1 brings further deprecations voted on by the PHP development team last week. 14 of the methods listed there were deprecated in PHP 7.4:
真正的类型 魔术引用遗产 array_key_exists()包含对象 FILTER_SANITIZE_MAGIC_QUOTES过滤器 反射export()方法 mb_strrpos(),编码为第三个参数 implode()参数顺序组合 从非静态闭包中取消绑定$ this hebrevc()函数 convert_cyr_string()函数 money_format()函数 ezmlm_hash()函数 restore_include_path()函数 allow_url_include ini指令
In PHP 7.4beta1, all mentioned methods were no longer recommended and were finally removed in version 8.0.
BugFix in PHP 7.4beta1
In addition to the deprecations mentioned above, the beta version has also prepared some bug fixes. According to the release notes, there is a Segmation Fault in the built-in web server. This problem should be solved with this beta.
Another problem arises when PHP is executed via CGI. PHP is looking for a shebang (#!). If there is a hash in the first line, PHP does not check if the following is an exclamation point, so it is a combination of the hash and the exclamation point (#!). According to the bug report, PHP skipped the corresponding lines and ignored the PHP code.
Test script: --------------- #<!--?php echo "Hello World\n"; ?--> Second line. Expected result: ---------------- X-Powered-By: PHP/5.3.3-7+squeeze3 Content-type: text/html #Hello World Second line. Actual result: -------------- X-Powered-By: PHP/5.3.3-7+squeeze3 Content-type: text/html Second line.
Additionally, there is a bug where PHP eats the first byte of the program if it comes from a process substitution (Bug #78066). The first beta version fixes this bug. For more information about the current version, see the release notes.
Beta1 will be followed by beta2
PHP 7.4 is scheduled to be released on November 28th. After the first beta release, PHP 7.4beta2 will be released on August 8, 2019. The schedule for PHP 7.4 can be found in the PHP wiki.
This article is translated from: https://entwickler.de/online/php/php-7-4beta1-deprecations-579902190.html