PHP 7.3 release is approaching - Questers

PHP 7.3 release is approaching

PHP is one of the most popular server-side programming languages largely used for web development (by websites such as Facebook, Wikipedia, WordPress, etc.) but also as a general-purpose programming language. And although it had fallen behind a couple of years ago, with the latest updates it is getting back on track and currently has a lot to offer in terms of speed, ease of use and stability.

Now a new release is approaching and after the announcement of the RC 6 on November 22, we know almost exactly what to expect from it. However, we are still very excited to see the final result. The new updates are aiming at significantly improving the performance of PHP 7.3 in comparison to the previous versions and we would like to share some thoughts on them here.

  • Flexible Heredoc and Nowdoc Syntaxes

Heredoc and Nowdoc syntaxes enable users to use multi-line long strings but currently they have very rigid requirements. Therefore, this update is aiming to implement two main changes: enabling the closing marker to be indented and removing the requirement for а new line after the closing marker.

  • Allow a trailing comma in function calls

PHP 7.3 is coming with allowed trailing commas in function calls. As introduced in PHP RFC, it “will make it more convenient to append arguments in many contexts where it is common to call a function with lots of arguments (especially variadic functions)”. This change is quite reasonable as values get appended pretty often.

  • JSON_THROW_ON_ERROR

PHP 7.3 would offer a better error handling for the functions json_encode() and json_decode() which currently don’t have a proper error throwing representation. The new option flag JASON_THROW_ON_ERROR would throw a JsonException if there is an issue parsing the provided data. This would also eliminate the need of manual request of the error message.

  • PCRE2 Migration

PHP uses PCRE (Perl Compatible Regular Expressions) as a library for regular expressions but it is based on 8.x series which is a legacy library. The up-to-date version is PCRE2 and is actively supported. The main goal of this change is to migrate PHP core to use PCRE2 and make it stable while focusing on maximum backward compatibility. What should be taken into account here is that the PCRE2 library is more aggressive in pattern validation and may result in not compiling your current patterns.

  • list() Reference Assignment

Although PHP has list() assignment and reference assignment functions it was not possible to use reference assignment in list() until now. With the updated syntax PHP 7.3 would now allow you to do that and you would be able to edit a single variable instead of finding the index within the array.

  • is_countable function

One of the new features coming to PHP 7.3 is the is_countable function. In PHP 7.2 you could count arrays and objects via count() function and if the object was not countable you would get a warning. Now with the new version, you could use the is_countable function that will return “true” if the given variable is an array or a countable variable and “false” if otherwise.

  • array_key_first() and array_key_last()

Adding these two new functions to PHP would allow you to retrieve the first and the last key of an array without using reset(), end() and key() functions that require changing the internal state of the array. These two functions would make the code less complex and, in some cases, avoid errors.

  • Argon2 Password Hash Enhancements

Achieving a better level of protection is always a good thing. The enhancement of the Argon2 hashing algorithm is aiming to implement the Argon2id with the password_* functions. The advantage of Argon2id is that it combines the approach of Argon2i for the first pass over memory (using data-independent memory access) with Argon2d approach for subsequent passes (using data-depending memory access).

  • Deprecate and Remove image2wbmp()

The image2wbmp() function is used to output or save a WBMP (bitmap) version of a picture. After PHP 5.0.0 its threshold parameter is treated as foreground colour and it basically duplicates the imagewbmp(). Since there is no need of two identical functions the new version of PHP would deprecate the mage2wbmp() and later on completely remove it.

  • Deprecate and Remove Case-Insensitive Constants

In the previous versions, PHP has supported both case-sensitive and case-insensitive constants. But case-insensitive constants are used very rarely in practice and cause various inconsistencies and unnecessary implementational complexity. PHP 7.3 would deprecate these constants and implement the following changes:
-    Deprecate calling define() with third parameter true;
-    Deprecate accessing case-insensitive constants with a casing different from the declaration, except true, false and null constants.

  • Other Deprecations

There are a few more features that are being targeted for deprecation in PHP 7.3 and later on in PHP 8 to be removed. Here is a short list of them:
-    Undocumented mbstring function aliases
-    String search functions with integer needle
-    fgetss() function and string.strip_tags filter
-    Defining a free-standing assert() function
-    FILTER_FLAG_SCHEME_REQUIRED and FILTER_FLAG_HOST_REQUIRED flags
-    pdo_odbc.db2_instance_name php.ini directive

In conclusion PHP 7.3 is coming with a number of exciting updates, various deprecations and new features. They will be available very soon and hopefully will make PHP even better, faster and more stable programming language.

field_tagged: