A sneak peek at PHP 8.4

MergePHP July 2024

Ian Littman

@ian@phpc.social / @iansltx

https://ian.im/php84amerge

What we'll cover

  • Where to get it now
  • What's new
  • What's deprecated/removed/BC-broken

 

Blue-highlighted items are links if you want more info

 

Info drawn from php.watch + UPGRADING and NEWS files

How do I get it?

 

WARNING: This is an alpha. Don't deploy this to production.

New Features + Improvements

class User implements Named
{
    private bool $isModified = false;
    public function __construct(private string $first, private string $last){}
    public string $fullName {
        // Override the "read" action with arbitrary logic.
        get => $this->first . " " . $this->last;
 
        // Override the "write" action with arbitrary logic.
        set { 
            [$this->first, $this->last] = explode(' ', $value, 2);
            $this->isModified = true;
        }
    }
}
  • array_find - first value in array for which callback returns true
  • array_find_key - first key in array for which callback returns true
  • array_all - whether callback returns true for all items
  • array_any - whether callback returns true for at least one item
  • Polyfill via polyfills/array-find

Date improvements

Security

NumberS!

 

String manipulation

DOM

Other additions

Exceptions/input validation

  • dom
  • Intl
  • mb_*
  • pcntl
  • SimpleXML
  • SplFixedArray out of bounds
  • XMLReader/XMLWriter
  • XSL
  • round() on invalid mode
  • xml_set_*_handler()

Resources -> Types

  • JIT is enabled based on a flag rather than buffer size
  • PHP will now exit if JIT is enabled and fails to init
  • Opcache interned string buffer default is 8x larger

JIT/Opcache

  • Core -> PECL
  • PHP built-in web server recursively falls back to index.php more aggressively
  • PCRE is now updated (changes behavior)
  • SimpleXML now doesn't reset the iterator in a few cases
  • strcspn() now doesn't bug out when it sees a null byte
  • Newer openssl, curl requirements

Other BC Breaks

Deprecations

Thanks! Questions?

A Sneak Peek at PHP 8.4 - MergePHP July 2024

By Ian Littman

A Sneak Peek at PHP 8.4 - MergePHP July 2024

  • 123