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

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

Chris Gmyr

June 20, 2019
Tweet

More Decks by Chris Gmyr

Other Decks in Programming

Transcript

  1. 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
  2. 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
  3. 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
  4. 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
  5. 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
  6. PHP RFC: Alternative "use" syntax for Closures // before... $closure

    = function ( ArgumentType $argument1, ArgumentType $argument2, ArgumentType $argument3, ArgumentType $argument4 ) use ( $importVariable1, &$importVariable2, $importVariable3, &$importVariable4 ): ReturnType { // ... };
  7. 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; // ... };
  8. 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
  9. // 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...
  10. 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; } }
  11. 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?
  12. 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
  13. 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
  14. 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/
  15. 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
  16. 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
  17. Next Month @ TrianglePHP TDB Presented By YOU?!?! Thursday, July

    18, 6pm @ Atlantic BT Need an Idea? 4 Testing 4 Security 4 Performance 4 Git
  18. Tonight @ TrianglePHP Simple DevOps with Laravel's Forge & Envoyer

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