The Latest in PHP: June 2019 Edition

The Latest in PHP: June 2019 Edition

Markdown file can be found here https://github.com/trianglephp/latest-in-php

6834447bdbca70cd2390adc690c3b4f1?s=128

Chris Gmyr

June 20, 2019
Tweet

Transcript

  1. The Latest in PHP June 2019 Edition

  2. Presented by Chris Gmyr @cmgmyr

  3. PHP Supported Versions 4 7.1 Security Only until Dec 1,

    2019 4 7.2 & 7.3 Active Development 4 7.4 is underway (~Nov 2019, last 7 branch) 4 8.0 in 2020 More Info: 4 http://php.net/supported-versions.php
  4. PHP Releases 4 7.1.[29-30] 4 7.2.[18-19] 4 7.3.[5-6] 4 7.4.0

    Alpha 1! 7.1.* - 7.3.* have Security and Bug fixes More Info: 4 http://php.net/ChangeLog-7.php
  5. PHP RFC: Arrow Functions 2.0 (Implemented in 7.4) // before

    function array_values_from_keys($arr, $keys) { return array_map(function ($x) use ($arr) { return $arr[$x]; }, $keys); } // after function array_values_from_keys($arr, $keys) { return array_map(fn($x) => $arr[$x], $keys); } https://wiki.php.net/rfc/arrow_functions_v2
  6. PHP RFC: Spread Operator in Array Expression (Implemented in 7.4)

    PHP has already supported argument unpacking (AKA spread operator) since 5.6. This RFC proposes to bring this feature to array expression. $parts = ['apple', 'pear']; $fruits = ['banana', 'orange', ...$parts, 'watermelon']; // ['banana', 'orange', 'apple', 'pear', 'watermelon']; https://wiki.php.net/rfc/spread_operator_for_array
  7. PHP RFC: Nullsafe Calls (Draft) A new operator would be

    added to the language: ?->. Calling $obj?->foo(..) behaves identically to $obj->foo(..) if $obj is not null. If $obj is null, then it returns null. function f($o) { return $o?->mayFail1()?->mayFail2()?->mayFail3()?->mayFail4(); } https://wiki.php.net/rfc/nullsafe_calls
  8. PHP RFC: Alternative "use" syntax for Closures (Under Discussion) https://wiki.php.net/rfc/alternative-closure-use-

    syntax
  9. PHP RFC: Alternative "use" syntax for Closures // before... $closure

    = function ( ArgumentType $argument1, ArgumentType $argument2, ArgumentType $argument3, ArgumentType $argument4 ) use ( $importVariable1, &$importVariable2, $importVariable3, &$importVariable4 ): ReturnType { // ... };
  10. PHP RFC: Alternative "use" syntax for Closures // after... $closure

    = function ( ArgumentType $argument1, ArgumentType $argument2, ArgumentType $argument3, ArgumentType $argument4 ): ReturnType { use $importVariable1, &$importVariable2; use $importVariable3, &$importVariable4; // ... };
  11. PHP Quick Tip

  12. levenshtein() Calculate Levenshtein distance between two strings $str1 = "apple";

    $str2 = "appplee"; echo levenshtein($str1, $str2); // 2 https://www.php.net/manual/en/ function.levenshtein.php
  13. // input misspelled word $input = 'carrrot'; // array of

    words to check against $words = array('apple','pineapple','banana','orange', 'radish','carrot','pea','bean','potato'); // no shortest distance found, yet $shortest = -1; // loop through words to find the closest...
  14. foreach ($words as $word) { // calculate the distance between

    the input word, and the current word $lev = levenshtein($input, $word); // check for an exact match if ($lev == 0) { $closest = $word; $shortest = 0; break; } // if this distance is less than the next found shortest // distance, OR if a next shortest word has not yet been found if ($lev <= $shortest || $shortest < 0) { // set the closest match, and shortest distance $closest = $word; $shortest = $lev; } }
  15. echo "Input word: $input\n"; if ($shortest == 0) { echo

    "Exact match found: $closest\n"; } else { echo "Did you mean: $closest?\n"; } --- Input word: carrrot Did you mean: carrot?
  16. Latest Versions 4 Laravel: 5.8.24 4 Symfony: 4.3.1 4 Drupal:

    8.6.17 4 PHPStorm: 2019.1.3 4 VSCode: 1.35
  17. PHP Conferences - July Laracon VII July 24–25, New York,

    New York https://laracon.us
  18. PHP Conferences - September SymfonyLive Berlin 2019 September 24–27, Berlin,

    Germany http://berlin2019.live.symfony.com Cascadia PHP September 19–21, Portland, OR https://cascadiaphp.com
  19. Nomad PHP US: Double Loop: TDD & BDD Done Right

    presented by Jessica Mauerhan June 20, 2019 at 06:00pm PDT UK: The Dark Corners of the SPL presented by Omni Adams June 20, 2019 at 11:00am PDT https://nomadphp.com/
  20. Open Call for Papers PHPCon Poland 2019 CfP Deadline: July

    10, 2019 November 15–17, Szczyrk, Poland https://2019.phpcon.pl PHP.Barcelona Conferenence 2019 CfP Deadline: September 30th, 2019 November 12–13, Barcelona, Spain https://php.barcelona
  21. Upcoming regional events All Things Open Oct 13-15, 2019 http://allthingsopen.org

    Early bird going on now for $99!
  22. Notable News & Articles 4 PHP Versions Stats - 2019.1

    Edition 4 Package: composer-git-hooks 4 Package: prestissimo (composer plugin) 4 Taylor Otwell: Laravel Live QA 4 GitHub Actions for PHP Developers 4 A Look At PHP’s isset() 4 Structuring the Docker setup for PHP Projects
  23. Next Month @ TrianglePHP TDB Presented By YOU?!?! Thursday, July

    18, 6pm @ Atlantic BT Need an Idea? 4 Testing 4 Security 4 Performance 4 Git
  24. Have a Job/Need a Job Who's hiring? Who's looking? What

    are you looking for?
  25. Tonight @ TrianglePHP Simple DevOps with Laravel's Forge & Envoyer

    Presented By - Chris Gmyr Thank you to Atlantic BT for hosting and refreshments!