What's new in PHP 7.2

Ian Littman / @iansltx

AustinPHP June 2017

http://ian.im/72aus0617

PHP 7.2alpha1 is out!

Cleanup (technically BC breaks) - CASTS

Numeric array indexes now convert to string property names when an array is cast as an object.

 

The reverse direction is similar; numeric string property names now map back to integer array keys.

 

Previously, these transformations would give you inaccessible indexes or properties.

Cleanup (technically BC breaks) - BAREWORDS

References to undefined constants (i.e. strings without quotes around them) now generate warnings instead of notices, though they still work for now.

 

This will turn into an Error eventually (<= PHP 8.0).

Cleanup (technically BC breaks)

  • Session status now behaves more correctly, but will now error out if you provide invalid session status codes
  • hash_hmac(), hash_hmac_file(), hash_pbkdf2() don't support non-cryptographic hashes anymore
  • bcmod() in BCMath no longer truncates fractions
  • The json_decode() option JSON_OBJECT_AS_ARRAY is used if the second parameter (assoc) is null. Previously JSON_OBJECT_AS_ARRAY was always ignored.
  • Trait property initial value compatibility check no longer casts

Windows <7||2008R2 Dropped

...and Netware

New Features - Available now

  • Now allowed in overridden methods
    • Removing a parameter typehint
    • Overriding an abstract method with another one
  • Trailing commas in group use declarations
  • Argon2i is now the default password_hash() algo
  • Zip can now read/write encrypted archives

New Features - AVailable Now

  • mail()/mb_send_mail() accepts an $extra_header array
  • count() now warns on non-countable objects (anything other than arrays and Countable implementors)
  • number_format() now never returns negative zero
  • utf8_encode(), utf8_decode() are now in the standard extension (rather than in the xml extension)
  • socket_getaddrinfo()
  • Debuggable PDO prepared statement emulation

Libsodium is now in core!

New Features! (available soon)

mcrypt is now in PECL!

Deprecations (gone in PHP 8.0)

  • __autoload
  • $php_errormsg
  • create_function()
  • mbstring.func_overload
  • (unset) cast
  • parse_str() without second argument
  • gmp_random()
  • each() - it's really slow and problematic
  • assert() with string argument (aka eval-check-true)
  • $errcontext argument of error handler

thanks!

What's New in PHP 7.2 - AustinPHP Lightning Talk

By Ian Littman

What's New in PHP 7.2 - AustinPHP Lightning Talk

PHP 7.2a1 is out! Let's talk through some of the things that'll be added, changed, or removed in the upcoming 7.2 release!

  • 6,946