development

PHP 8.1 with a lot of new features released. PHP Foundation asks for volunteers to document them.

josh-muller-qiPTr8GmhM0-unsplash

Today a new release of PHP became publicly available. The new minor version, 8.1, contains a lot of new features. Below we provide a short description of the most notable changes.

  • Built-in support for enumerations (enums for short). A long-awaited change that will let make the code more readable, avoid unexpected application states, and make coding and code support simpler.
  • Fibers - a new mechanism to manage parallelism on the low level. The feature allows the implementation of lightweight and controlled concurrency. It is unlikely that every developer will use it, but they will be helpful in such frameworks as ReactPHP, thus improving many projects that rely on them.
  • Inheritance cache - the new feature that allows caching the links between classes. It should noticeably increase performance.
  • Enabled string keys for array unpacking. The ability to unpack arrays was brought in PHP 7.4, but earlier, only numeric keys were allowed. The new update adds the ability to use strings as keys.
  • Read-only properties. The class declared read-only can be initialized only once. Further changes to the property are not allowed.
  • First-class Callable syntax. Now it is easier to create a callable using the same syntax as calling a function or method.
  • Intersection types - a new feature that allows declaring a type for a parameter or property. It also allows enforcing the values for all declared class or interface types, unlike Union types, which allow any declared types.
  • New type - never. This new return type will never return a value but instead throws an exception or terminates the program with an exit or die call.
  • New function - array_is_list. The function is designed to return true if the given array is a semantic list of values, with all keys being integers starting from zero with no gaps in between. However, it also returns true on empty arrays.
  • Final flag on class constants. From now on, the class constants marked with this flag can’t be overridden during inheritance.
  • New functions - fsync and fdatasync. They work similar to fflush (which flushes potentially buffered data to the underlying operating system), but they also request the OS to flush the write buffers to the storage media. The difference between them is that fdatasync synchronizes data without meta-data, and fsync synchronizes the data, including meta-data.
  • Explicit Octal numeral notation. Earlier, the Octal numerals could be prefixed only with zero and the uppercase letter O. From now on, the Octal numerals also can be prefixed with zero and lowercase letter o, thus making them easier to read.

So as you can see, the update brought many significant changes. They are described in detail in the changelog. However, a few hours ago, the official PHP Twitter account announced that they seek volunteers to help documenting all the new features.

Reading next

blogging-guide-K5DY18hy5JQ-unsplash
j-kelly-brito-PeUJyoylfe4-unsplash

Interested in a specific business & technology topic and looking for an article in our blog but haven't found one yet?

If you haven't come across an article that matches your query, feel free to suggest the topic to us, and we'll consider featuring it in our blog. Share your suggestion in the form below, and we'll be sure to review your request.

Talk with us

If you have any questions or problems in your business that can be solved with technical solutions, just let us know. We'll do everything we can to help you.