Upgrade to Pro — share decks privately, control downloads, hide ads and more …

PHP 7.2 Update Notes

PHP 7.2 Update Notes

Gave as a rough talk at Dallas PHP Dec'17 when the screens didn't even work so people couldn't even see it lol.

Bob Majdak Jr

December 12, 2017
Tweet

More Decks by Bob Majdak Jr

Other Decks in Programming

Transcript

  1. Parameter Types can be "widened" class Whatever public function DoSomething(Bool

    $Choice): String class SomethingElse extends Whatever public function DoSomething($Choice): String "contravariance"
  2. PDO PDO will handle National Character Set (NCHAR) prepare emulations

    better now. PDOStatement::debugDumpParams will now include the full compiled SQL query for you with actual data generated after the prepare. EXIF ZIP Read and Write encrypted archives now. EXIF extension updated to be able to read metadata from more camera vendors. HASH API uses Objects rather than Resources now - update any is_resource checks to is_object. SQLITE 3 Open blob fields in write mode.
  3. UTF8_ENCODE / UTF8_DECODE These functions no longer depend on the

    XML extension and have been moved to the standard library. NUMBER_FORMAT(Number[, Precision]) GET_CLASS(VOID) The get_class() function no longer accepts NULL as an argument. To get the name of the containing class leave the argument list empty. Number format will always return positive 0 now in cases where it was possible to return negative zero. (ex. number_format(-0.25)) COUNT() Counting things that are not Countable (like a string) will result in warnings being thrown. JSON_OBJECT_AS_ARRAY Works now. Used to be ignored due to the 2nd argument of json_decode. Now if 2nd arg is null, the flag will be respected.
  4. // the php bug of the millennium. $JSON = json_encode([

    'User' => 'Bob', 'Data' => [ 1=>'One', 10=>'Ten'] ]); var_dump($JSON); $User = json_decode($JSON); $User->Data = (Array)$User->Data; var_dump($User->Data); var_dump($User->Data['1'],$User->Data[10]);
  5. string(44) "{"User":"Bob","Data":{"1":"One","10":"Ten"}}" array(2) { '1' => string(3) "One" '10' =>

    string(3) "Ten" } Notice: Undefined offset: 1 in /opt/dmanetwork/test.php on line 9 Notice: Undefined offset: 10 in /opt/dmanetwork/test.php on line 9
  6. PHP_FLOAT_MIN, _MAX, _DIG, _EPSILON New constants that exist for knowing

    about floating points. New Generic Type: "Object" Sodium crypto library in core, Argon2 hashing. Full access to the sodium library within PHP, and the hashing API can now deal with Argon2. You can now specify that something may accept or return any type of object using the generic typecast. Due to this, "Object" is no longer allowed to be used in class names. PROC_NICE() works on Windows Return a string like "Windows" "BSD" "Linux" "Solaris" or "Unknown" Used to change the priority of a running process. PHP_OS_FAMILY
  7. Unquoted Strings / Undefined Constants These will throw stronger E_WARNING

    now, and in the next version likely to throw a full on Error exception. create_function deprecated parse_str without a second argument deprecated They are phasing out things which create magic variables for you. Use the anonymous/lambda function system instead. EACH() deprecated Use sql_autoload_register instead. Apparently not only did this exist, but a billion times slower than foreach() for some reason. __autoload deprecated
  8. Interesting but Undocumented To Date spl_object_id() mb_chr() mb_ord() mb_scrub() socket_addrinfo_lookup()

    socket_addrinfo_connect() socket_addrinfo_bind() socket_addrinfo_explain()