SlideShare a Scribd company logo
1 of 30
Download to read offline
SVILUPPAREINPHP7:
LENOVITÀDELPHP7.1E7.2
di
Senior Software Engineer
, una società Rogue Wave (USA)
, Milano, 10 Novembre
Enrico Zimuel
Zend Technologies
Codemotion 2017
MIPRESENTO
Sviluppatore web dal 1996
Senior Software Engineer presso ,
una società
Coautore di , e
Speaker e relatore internazionale
Research Programmer presso
Co-fondatore del
www.zimuel.it
Zend
Rogue Wave
Apigility Expressive Zend
Framework
TEDx
Università di Amsterdam
PUG Torino
www.sviluppareinphp7.it
PHP7.1
7.1.0 (1 Dic 2016)
Ultima release 7.1.11 (26 Ott 2017)
Versione Rilascio Supporto
attivo
Security
x
5.5 EOL EOL EOL
5.6 28 Ago
2014
19 Gen 2017 31 Dic
2018
7.0 3 Dic
2015
3 Dic 2017 3 Dic
2018
7.1 1 Dic
2016
1 Dic 2018 1 Dic
2019
NOVITÀ7.1
TIPINULLABLE
Per parametri e valori di ritorno di funzioni
Sintassi: aggiunta del ? prima del tipo
null può essere passato come argomento,
o restituito come valore
EXAMPLE
function hi(?string $name): ?string
{
return $name ? 'Hello ' . $name : null;
}
echo hi(null); // returns null
echo hi('Enrico'); // returns 'Hello Enrico'
echo hi(); // Fatal error
RITORNODITIPOVOID
function swap(&$left, &$right): void
{
if ($left === $right) {
return;
}
$tmp = $left;
$left = $right;
$right = $tmp;
}
$a = 1;
$b = 2;
var_dump(swap($a, $b), $a, $b);
ARRAYDESTRUTTURATI
$data = [['foo', 'bar', 'baz']];
[$a, $b] = $data[0];
var_dump($a, $b); // string(3) "foo", string(3) "bar"
[$a, , $c] = $data[0];
var_dump($a, $c); // string(3) "foo", string(3) "baz"
foreach ($data as [$a, $b, $c]) {
var_dump($a, $b, $c);
// string(3) "foo"
// string(3) "bar"
// string(3) "baz"
}
CONARRAYASSOCIATIVI
Chiavi speci cate in list(), o con la sintassi []
$data = ['a' => 'foo', 'b' => 'bar', 'c' => 'baz'];
list('a' => $a, 'b' => $b, 'c' => $c) = $data;
var_dump($a, $b, $c); // foo, bar, baz
['a' => $a, 'b' => $b, 'c' => $c] = $data;
var_dump($a, $b, $c); // foo, bar, baz
ITERABLE
Aggiunto lo pseudo-tipo iterable
Accetta array o Traversable
Utilizzato in parametri e ritorno di funzioni
ESEMPIO
function foo(iterable $iterable): void
{
foreach ($iterable as $value) {
var_dump($value);
}
}
foo([1,2,3]);
foo(new ArrayIterator([1,2,3]));
VISIBILITÀDICONST
class ConstDemo
{
const CONST_A = 1; // public
public const CONST_B = 2;
protected const CONST_C = 3;
private const CONST_D = 4;
}
CATCHMULTIPLI
try {
// Some code...
} catch (ExceptionA | ExceptionB $e) {
// Handle exceptions A or B
} catch (Exception $e) {
// ...
}
INDICINEGATIVI
var_dump("abcdef"[-2]); // string(1) "e"
var_dump("abcdef"[-7]); // string(0) "", PHP Notice
// strpos
var_dump(strpos("aabbcc", "b", -3)); // int(3)
// get the last character of a string
$last = substr($foo, -1); // before PHP 7.1
$last = $foo[-1];
OPENSSLAEAD
Cifratura e autenticazione (Authenticated
Encryption)
Supporto modalità GCM e CCM
GCM è 3 volte più veloce di CCM.
Più informazioni su
Dettagli
benchmark
Authenticated Encryption in PHP 7.1
OPENSSL_ENCRYPT()
$tag contiene l'hash di autenticazione
string openssl_encrypt(
string $data,
string $method,
string $password,
[ int $options = 0 ],
[ string $iv = "" ],
[ string &$tag = NULL ],
[ string $aad = "" ],
[ int $tag_length = 16 ]
)
OPENSSL_DECRYPT()
string openssl_decrypt(
string $data,
string $method,
string $password,
[ int $options = 0 ],
[ string $iv = "" ],
[ string $tag = "" ],
[ string $aad = "" ]
)
ENCRYPTEXAMPLE
Il risultato è $ciphertext . $tag
$algo = 'aes-256-gcm';
$iv = random_bytes(openssl_cipher_iv_length($algo));
$key = random_bytes(32); // 256 bit
$data = random_bytes(1024); // 1 Kb of random data
$ciphertext = openssl_encrypt(
$data,
$algo,
$key,
OPENSSL_RAW_DATA,
$iv,
$tag
);
DECRYPTEXAMPLE
$decrypt = openssl_decrypt(
$ciphertext,
$algo,
$key,
OPENSSL_RAW_DATA,
$iv,
$tag
);
if (false === $decrypt) {
throw new Exception(openssl_error_string());
}
echo $data === $decrypt ? 'Ok' : 'Failure';
FUNZIONALITÀDEPRECATE
MCRYPT
Utilizzare OpenSSL al suo posto
PHP7.2
7.2.0 (Prevista per 30 Nov 2017)
ALCUNENOVITÀ
TIPOOBJECT
Utilizzabile come parametro e ritorno di tipo
function foo(object $obj): string {
return $obj->var;
}
function bar(MyClass $arg): object {
return $arg;
}
OMISSIONEDELTIPO
E' possibile omettere il tipo di un parametro per
interfacce o classi ereditate
class Foo {
public function myFunction(array $myarray)
{ /* ... */ }
}
class Bar extends Foo {
public function myFunction($myarray)
{ /* ... */ }
}
ULTIMAVIRGOLA
Lasciare la virgola nell'ultimo elemento di un lista
// Arrays (already possible)
$array = [1, 2, 3,];
use FooBar{ Foo, Bar, Baz, };
fooCall($arg1, $arg2, $arg3,);
protected
$a = 'foo',
$b = 'bar',
;
SICUREZZA
Supporto per memorizzazione sicura
password
, supporto crittogra a moderna
Argon2
Sodium
GRAZIE!
Contatti: enrico [at] zimuel.it
Web:
Twitter:
Questa presentazione è rilasciata con licenza
.
Presentazione realizzata con
www.zimuel.it
@ezimuel
Creative Commons Attribution-ShareAlike 3.0 Unported License
reveal.js

More Related Content

What's hot

06 1 array_stringhe_typedef
06 1 array_stringhe_typedef06 1 array_stringhe_typedef
06 1 array_stringhe_typedef
Piero Fraternali
 
Lezione 16 (2 aprile 2012)
Lezione 16 (2 aprile 2012)Lezione 16 (2 aprile 2012)
Lezione 16 (2 aprile 2012)
STELITANO
 
05 3 istruzioni-selezione-iterazione-condizioni
05 3 istruzioni-selezione-iterazione-condizioni05 3 istruzioni-selezione-iterazione-condizioni
05 3 istruzioni-selezione-iterazione-condizioni
Piero Fraternali
 
13 Puntatori E Memoria Dinamica
13   Puntatori E Memoria Dinamica13   Puntatori E Memoria Dinamica
13 Puntatori E Memoria Dinamica
guest60e9511
 
Complessità e ordinamento di Ezio Sperduto
Complessità e ordinamento di Ezio SperdutoComplessità e ordinamento di Ezio Sperduto
Complessità e ordinamento di Ezio Sperduto
Vitalij Zadneprovskij
 

What's hot (20)

07 1 funzioni
07 1 funzioni07 1 funzioni
07 1 funzioni
 
06 1 array_stringhe_typedef
06 1 array_stringhe_typedef06 1 array_stringhe_typedef
06 1 array_stringhe_typedef
 
EcmaScript 6 & 7
EcmaScript 6 & 7EcmaScript 6 & 7
EcmaScript 6 & 7
 
Cattive abitudini e-lineeguida
Cattive abitudini e-lineeguidaCattive abitudini e-lineeguida
Cattive abitudini e-lineeguida
 
Puntatori e Riferimenti
Puntatori e RiferimentiPuntatori e Riferimenti
Puntatori e Riferimenti
 
PHP
PHPPHP
PHP
 
Funzioni anonime in PHP 5.3
Funzioni anonime in PHP 5.3Funzioni anonime in PHP 5.3
Funzioni anonime in PHP 5.3
 
Groovy e Domain Specific Languages
Groovy e Domain Specific LanguagesGroovy e Domain Specific Languages
Groovy e Domain Specific Languages
 
Array in C++
Array in C++Array in C++
Array in C++
 
2008 python
2008 python2008 python
2008 python
 
2006 Py02 base
2006 Py02 base2006 Py02 base
2006 Py02 base
 
Lezione 16 (2 aprile 2012)
Lezione 16 (2 aprile 2012)Lezione 16 (2 aprile 2012)
Lezione 16 (2 aprile 2012)
 
05 3 istruzioni-selezione-iterazione-condizioni
05 3 istruzioni-selezione-iterazione-condizioni05 3 istruzioni-selezione-iterazione-condizioni
05 3 istruzioni-selezione-iterazione-condizioni
 
Bash intro
Bash introBash intro
Bash intro
 
07 2 ricorsione
07 2 ricorsione07 2 ricorsione
07 2 ricorsione
 
Sviluppo web dall'antichità all'avanguardia e ritorno
Sviluppo web  dall'antichità all'avanguardia e ritornoSviluppo web  dall'antichità all'avanguardia e ritorno
Sviluppo web dall'antichità all'avanguardia e ritorno
 
Php mysql3
Php mysql3Php mysql3
Php mysql3
 
13 Puntatori E Memoria Dinamica
13   Puntatori E Memoria Dinamica13   Puntatori E Memoria Dinamica
13 Puntatori E Memoria Dinamica
 
Ruby in 25 minuti
Ruby in 25 minutiRuby in 25 minuti
Ruby in 25 minuti
 
Complessità e ordinamento di Ezio Sperduto
Complessità e ordinamento di Ezio SperdutoComplessità e ordinamento di Ezio Sperduto
Complessità e ordinamento di Ezio Sperduto
 

Similar to Enrico Zimuel - PUG Milano meetup - Codemotion Milan 2017

Php mysql e cms
Php mysql e cmsPhp mysql e cms
Php mysql e cms
orestJump
 
Gianfrasoft Corso Di Php Parte 2
Gianfrasoft   Corso Di Php   Parte 2Gianfrasoft   Corso Di Php   Parte 2
Gianfrasoft Corso Di Php Parte 2
Gianfranco Fedele
 
Consigli per iniziare tdd
Consigli per iniziare tddConsigli per iniziare tdd
Consigli per iniziare tdd
Tassoman ☺
 

Similar to Enrico Zimuel - PUG Milano meetup - Codemotion Milan 2017 (20)

Php mysql e cms
Php mysql e cmsPhp mysql e cms
Php mysql e cms
 
Amazon S3 in Perl
Amazon S3 in PerlAmazon S3 in Perl
Amazon S3 in Perl
 
PHP Template Engine (introduzione)
PHP Template Engine (introduzione)PHP Template Engine (introduzione)
PHP Template Engine (introduzione)
 
What's new in C# 7
What's new in C# 7What's new in C# 7
What's new in C# 7
 
Scala Programming Linux Day 2009
Scala Programming Linux Day 2009Scala Programming Linux Day 2009
Scala Programming Linux Day 2009
 
Perl Template Toolkit
Perl Template ToolkitPerl Template Toolkit
Perl Template Toolkit
 
Mantenere una distribuzione Drupal attraverso test coverage: Paddle case study
Mantenere una distribuzione Drupal attraverso test coverage: Paddle case studyMantenere una distribuzione Drupal attraverso test coverage: Paddle case study
Mantenere una distribuzione Drupal attraverso test coverage: Paddle case study
 
Acadevmy - TypeScript Overview
Acadevmy - TypeScript OverviewAcadevmy - TypeScript Overview
Acadevmy - TypeScript Overview
 
08 mapreduce
08   mapreduce08   mapreduce
08 mapreduce
 
Array
ArrayArray
Array
 
Fare con Zend Framework 2 ciò che facevo con ZF1
Fare con Zend Framework 2 ciò che facevo con ZF1Fare con Zend Framework 2 ciò che facevo con ZF1
Fare con Zend Framework 2 ciò che facevo con ZF1
 
What is new in C# 2018
What is new in C# 2018What is new in C# 2018
What is new in C# 2018
 
Javascript
JavascriptJavascript
Javascript
 
Introduzione ad ECMAScript 6 (ES6) e TypeScript
Introduzione ad ECMAScript 6 (ES6) e TypeScriptIntroduzione ad ECMAScript 6 (ES6) e TypeScript
Introduzione ad ECMAScript 6 (ES6) e TypeScript
 
PHP7 e Rich Domain Model
PHP7 e Rich Domain ModelPHP7 e Rich Domain Model
PHP7 e Rich Domain Model
 
Gianfrasoft Corso Di Php Parte 2
Gianfrasoft   Corso Di Php   Parte 2Gianfrasoft   Corso Di Php   Parte 2
Gianfrasoft Corso Di Php Parte 2
 
Corso di php01
Corso di php01Corso di php01
Corso di php01
 
Consigli per iniziare tdd
Consigli per iniziare tddConsigli per iniziare tdd
Consigli per iniziare tdd
 
SaaS con Symfony2
SaaS con Symfony2SaaS con Symfony2
SaaS con Symfony2
 
Creare un proprio linguaggio di programmazione per il web e applicazioni desk...
Creare un proprio linguaggio di programmazione per il web e applicazioni desk...Creare un proprio linguaggio di programmazione per il web e applicazioni desk...
Creare un proprio linguaggio di programmazione per il web e applicazioni desk...
 

More from Codemotion

More from Codemotion (20)

Fuzz-testing: A hacker's approach to making your code more secure | Pascal Ze...
Fuzz-testing: A hacker's approach to making your code more secure | Pascal Ze...Fuzz-testing: A hacker's approach to making your code more secure | Pascal Ze...
Fuzz-testing: A hacker's approach to making your code more secure | Pascal Ze...
 
Pompili - From hero to_zero: The FatalNoise neverending story
Pompili - From hero to_zero: The FatalNoise neverending storyPompili - From hero to_zero: The FatalNoise neverending story
Pompili - From hero to_zero: The FatalNoise neverending story
 
Pastore - Commodore 65 - La storia
Pastore - Commodore 65 - La storiaPastore - Commodore 65 - La storia
Pastore - Commodore 65 - La storia
 
Pennisi - Essere Richard Altwasser
Pennisi - Essere Richard AltwasserPennisi - Essere Richard Altwasser
Pennisi - Essere Richard Altwasser
 
Michel Schudel - Let's build a blockchain... in 40 minutes! - Codemotion Amst...
Michel Schudel - Let's build a blockchain... in 40 minutes! - Codemotion Amst...Michel Schudel - Let's build a blockchain... in 40 minutes! - Codemotion Amst...
Michel Schudel - Let's build a blockchain... in 40 minutes! - Codemotion Amst...
 
Richard Süselbeck - Building your own ride share app - Codemotion Amsterdam 2019
Richard Süselbeck - Building your own ride share app - Codemotion Amsterdam 2019Richard Süselbeck - Building your own ride share app - Codemotion Amsterdam 2019
Richard Süselbeck - Building your own ride share app - Codemotion Amsterdam 2019
 
Eward Driehuis - What we learned from 20.000 attacks - Codemotion Amsterdam 2019
Eward Driehuis - What we learned from 20.000 attacks - Codemotion Amsterdam 2019Eward Driehuis - What we learned from 20.000 attacks - Codemotion Amsterdam 2019
Eward Driehuis - What we learned from 20.000 attacks - Codemotion Amsterdam 2019
 
Francesco Baldassarri - Deliver Data at Scale - Codemotion Amsterdam 2019 -
Francesco Baldassarri  - Deliver Data at Scale - Codemotion Amsterdam 2019 - Francesco Baldassarri  - Deliver Data at Scale - Codemotion Amsterdam 2019 -
Francesco Baldassarri - Deliver Data at Scale - Codemotion Amsterdam 2019 -
 
Martin Förtsch, Thomas Endres - Stereoscopic Style Transfer AI - Codemotion A...
Martin Förtsch, Thomas Endres - Stereoscopic Style Transfer AI - Codemotion A...Martin Förtsch, Thomas Endres - Stereoscopic Style Transfer AI - Codemotion A...
Martin Förtsch, Thomas Endres - Stereoscopic Style Transfer AI - Codemotion A...
 
Melanie Rieback, Klaus Kursawe - Blockchain Security: Melting the "Silver Bul...
Melanie Rieback, Klaus Kursawe - Blockchain Security: Melting the "Silver Bul...Melanie Rieback, Klaus Kursawe - Blockchain Security: Melting the "Silver Bul...
Melanie Rieback, Klaus Kursawe - Blockchain Security: Melting the "Silver Bul...
 
Angelo van der Sijpt - How well do you know your network stack? - Codemotion ...
Angelo van der Sijpt - How well do you know your network stack? - Codemotion ...Angelo van der Sijpt - How well do you know your network stack? - Codemotion ...
Angelo van der Sijpt - How well do you know your network stack? - Codemotion ...
 
Lars Wolff - Performance Testing for DevOps in the Cloud - Codemotion Amsterd...
Lars Wolff - Performance Testing for DevOps in the Cloud - Codemotion Amsterd...Lars Wolff - Performance Testing for DevOps in the Cloud - Codemotion Amsterd...
Lars Wolff - Performance Testing for DevOps in the Cloud - Codemotion Amsterd...
 
Sascha Wolter - Conversational AI Demystified - Codemotion Amsterdam 2019
Sascha Wolter - Conversational AI Demystified - Codemotion Amsterdam 2019Sascha Wolter - Conversational AI Demystified - Codemotion Amsterdam 2019
Sascha Wolter - Conversational AI Demystified - Codemotion Amsterdam 2019
 
Michele Tonutti - Scaling is caring - Codemotion Amsterdam 2019
Michele Tonutti - Scaling is caring - Codemotion Amsterdam 2019Michele Tonutti - Scaling is caring - Codemotion Amsterdam 2019
Michele Tonutti - Scaling is caring - Codemotion Amsterdam 2019
 
Pat Hermens - From 100 to 1,000+ deployments a day - Codemotion Amsterdam 2019
Pat Hermens - From 100 to 1,000+ deployments a day - Codemotion Amsterdam 2019Pat Hermens - From 100 to 1,000+ deployments a day - Codemotion Amsterdam 2019
Pat Hermens - From 100 to 1,000+ deployments a day - Codemotion Amsterdam 2019
 
James Birnie - Using Many Worlds of Compute Power with Quantum - Codemotion A...
James Birnie - Using Many Worlds of Compute Power with Quantum - Codemotion A...James Birnie - Using Many Worlds of Compute Power with Quantum - Codemotion A...
James Birnie - Using Many Worlds of Compute Power with Quantum - Codemotion A...
 
Don Goodman-Wilson - Chinese food, motor scooters, and open source developmen...
Don Goodman-Wilson - Chinese food, motor scooters, and open source developmen...Don Goodman-Wilson - Chinese food, motor scooters, and open source developmen...
Don Goodman-Wilson - Chinese food, motor scooters, and open source developmen...
 
Pieter Omvlee - The story behind Sketch - Codemotion Amsterdam 2019
Pieter Omvlee - The story behind Sketch - Codemotion Amsterdam 2019Pieter Omvlee - The story behind Sketch - Codemotion Amsterdam 2019
Pieter Omvlee - The story behind Sketch - Codemotion Amsterdam 2019
 
Dave Farley - Taking Back “Software Engineering” - Codemotion Amsterdam 2019
Dave Farley - Taking Back “Software Engineering” - Codemotion Amsterdam 2019Dave Farley - Taking Back “Software Engineering” - Codemotion Amsterdam 2019
Dave Farley - Taking Back “Software Engineering” - Codemotion Amsterdam 2019
 
Joshua Hoffman - Should the CTO be Coding? - Codemotion Amsterdam 2019
Joshua Hoffman - Should the CTO be Coding? - Codemotion Amsterdam 2019Joshua Hoffman - Should the CTO be Coding? - Codemotion Amsterdam 2019
Joshua Hoffman - Should the CTO be Coding? - Codemotion Amsterdam 2019
 

Enrico Zimuel - PUG Milano meetup - Codemotion Milan 2017