PHP 8.2 logo with "Subtle New Features" subheading.

PHP 8.2’s Subtle New Features

PHP version 8.2 was released on December 8, 2022 and I’m sure you’ve already heard about the great new features. The Randomizer & random generator engines classes, DNF types; constants within traits; the sensitive parameter trait; static return types for dates; the n regular expression modifier; false, true, and null types; the readonly class modifier, a handful of deprecations, and a small performance bump.

These features are great. They add some new things to play with, fix a few issues, and provide the usual speed boost. What about the more subtle features that aren’t reported on. They need some love too.

phpinfo()‘s Visual Upgrade

The first thing I will go over is a feature that doesn’t appear to be reported on anywhere. Not even in the changelog. Why?

The phpinfo() function got a facelift. It now supports dark mode using the OS and browser’s CSS prefers-color-scheme media query. There is also now sticky headers for tables. The headers will stay at the top of the screen while you continue scrolling.

Some other new features that go unnoticed…

  • Opimized code path for newly created files using the file:// stream wrapper.
  • Lower memory usage for strings created by various different functions.
  • Added support for curl’s CURLOPT_XFERINFOFUNCTION progress callback option. This replaces the deprecated CURLOPT_PROGRESSFUNCTION option.
  • Added support for curl’s CURLOPT_MAXFILESIZE_LARGE option which sould be used instead of CURLOPT_MAXFILESIZE in cases where the file is greater than 2 gigabytes.
  • Added curl_upkeep(callable) function that accepts a callable (function/method) and is used when HTTP2 keep-alive/ping requests are sent.
  • The idate(format, timestamp) function now supports the “N” and “o” specifiers to get the ISO day of week and ISO year respectively.
  • Added the FILTER_FLAG_GLOBAL_RANGE option when validating with the FILTER_VALIDATE_IP flag in the filter functions. The filter will fail when non-global IPV4/IPV6 IP ranges are used in accordance with RFC 6890 where the Global attribute is false.
  • A number of Apple Mac-specific memory and JIT compiler-related improvements.
  • Added JIT indirect call reduction.
  • Added the openssl_cipher_key_length(algorithm) function.
  • Added the ReflectionFunction::isAnonymous() method which returns true if the function is anonymous (e.g. a closure).
  • Added the ReflectionMethod::hasPrototype() method which returns true if the method has an inherited parent method (prototype).
  • Added a number of new Socket options.
  • Added ini_parse_quantity(string_value) function to convert parsed shorthand ini values that may include a number of supported units to integer value.
  • Added memory_reset_peak_usage() function to allow checking for excess memory usage multiple times throughout a script.

Upgrade Soon!

PHP 8.2 has many features that will make development and testing with PHP easier. It’s easy to overlook the more suble and less-reported-on features, but they are often some of the more useful or awaited changes. It’s highly reccomended that you upgrade to version 8.2 soon and always keep your software versions up-to-date to get the latest features and security fixes.


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *