what's new in PHP 8.4

Austin Drupal Meetup April 2025

Ian Littman

@ian@phpc.social / @ian.im / @iansltx

https://ian.im/php84adm

Released November 21, 2024

  • Thanks to release managers Eric Mann, Calvin Buckley, and Saki Takamachi
  • Current version: 8.4.6 (as of April 10)
  • Bugfixes until Dec 31, 2026
  • Security fixes until Dec 31, 2028
  • Security fixes after that if provided by your distro (or Zend)

What we'll cover

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

 

Blue-highlighted items are links if you want more info (ian.im/php84adm)

 

Info drawn from the release page + php.watch + UPGRADING and NEWS files

How do I get it?

New Features + Improvements

class User
{
    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 (string $value) { 
            [$this->first, $this->last] = explode(' ', $value, 2);
            $this->isModified = true;
        }
    }
}
class User
{
    public private(set) string $firstName;
    public private(set) string $lastName;

    public function setName(string $first, string $last)
    {
        $this->firstName = $first;
        $this->lastName = $last;
    }
}

$u = new User();
$u->setName('John', 'Smith');
echo $u->firstName . ' ' . $u->lastName . "\n"; // succeeds
$u->firstName = 'Jane'; // fails

Ghosts 👻💤 'n' proxies 'n' stuff

  • 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

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

  • BCMath numbers (mentioned earlier)
  • ODBC connections and results
  • SoapClient Url, Sdl (and typemap is now an array)
  • StreamBucket
  • More typed constants
    • Date
    • Intl
    • PDO
    • Spl
    • Sqlite
    • XMLReader
    • PHP_DEBUG, PHP_ZTS (now bools)

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
  • GMP class is now final
  • A bunch of MYSQLI_* constants have been removed
  • exit() and die() behave more like functions now

Other BC Breaks

Deprecations

Thanks! Questions?