CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 10/9/15 - 1 / 38 Tudo o que você precisa saber sobre PHP7 www.galvao.eti.br Tudo o que você precisa saber sobre PHP7 Logo by Vincent Pontier, Freddie and other silly things by The Internet
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 10/9/15 - 1 / 38
Tudo o que você precisa saber sobre PHP7 www.galvao.eti.br
Tudo o que você precisasaber sobre
PHP7 Logo by Vincent Pontier, Freddie and other silly things by The Internet
Presidente da ABRAPHP – Associação Brasileira de Profissionais PHPDiretor da PHP Conference BrasilContribui para a tradução da documentação oficial Atua como Zend Framework Evangelist para o ZTeam, da Zend.
20+ anos desenvolvendo sistemas e aplicações com interface web 15+ destes com PHP 7+ com Zend Framework
Palestrante em eventos nacionais e internacionaisInstrutor de cursos presenciais e a distânciaFundador e líder do GU PHPBRFundador* e membro do GU PHPRS
Site: http://www.galvao.eti.br/ http://people.php.net/galvaoTwitter: @galvaoSlides e Documentos: http://slideshare.net/ergalvao https://speakerdeck.com/galvaoGithub: http://github.com/galvaoPosts: https://medium.com/@galvao
Quem?!
CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 10/9/15 - 2 / 38
www.galvao.eti.brTudo o que você precisa saber sobre PHP7
CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 10/9/15 - 3 / 38
www.galvao.eti.br
F.A.Q.
Tudo o que você precisa saber sobre PHP7
Spaceship OperatorNULL Coalesce OperatorGroup Use DeclarationsScalar Type Hints Return Type DeclarationsExceptions in the engineCSPRNGArrays Constantes
R.I.P.mysqlTagsConstrutor estilo PHP4
Features
Velozes & Curiosos
CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 10/9/15 - 4 / 38
www.galvao.eti.brTudo o que você precisa saber sobre PHP7
≃3x mais rápido (no mínimo)
Escolha seu benchmark favorito:
- Google Spreadsheet, by Dmitry Stogov (Zend)- Artigo, by Lorna Jane- Infográficos, by Zend
CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 10/9/15 - 11 / 38
www.galvao.eti.brTudo o que você precisa saber sobre PHP7
CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 10/9/15 - 12 / 38
www.galvao.eti.br
1 <=> 0 → 1
Pew!
Tudo o que você precisa saber sobre PHP7
Spaceship Operator
CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 10/9/15 - 13 / 38
www.galvao.eti.br
1 <=> 0 → 11 <=> 1 → 0
Pew!
Pew!
Tudo o que você precisa saber sobre PHP7
Spaceship Operator
CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 10/9/15 - 14 / 38
www.galvao.eti.br
1 <=> 0 → 11 <=> 1 → 00 <=> 1 → -1
Pew!
Pew!
Pew!
Tudo o que você precisa saber sobre PHP7
Spaceship Operator
NULL Coalesce Operator
CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 10/9/15 - 15 / 38
www.galvao.eti.brTudo o que você precisa saber sobre PHP7
$foo = isset($_GET['bar']) ? $_GET['bar'] : true;
$foo = $_GET['bar'] ?? true;
PHP5
PHP7
Group Use Declarations
CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 10/9/15 - 16 / 38
www.galvao.eti.brTudo o que você precisa saber sobre PHP7
PHP5
PHP7
use Foo\Bar;use Foo\Baz;use Foo\Quux;
use Foo\{Bar, Baz, Quux};
use Foo\{ Bar\Thud, Baz\Grunt\Bletch, Quux\Fum};
STH
CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 10/9/15 - 17 / 38
www.galvao.eti.brTudo o que você precisa saber sobre PHP7
<?phpfunction foo(int $x, int $y){ return $x + $y;}
echo foo('1', 2);
Coercive
Resultado: 3
STH
CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 10/9/15 - 18 / 38
www.galvao.eti.brTudo o que você precisa saber sobre PHP7
<?phpdeclare(strict_types=1);
function foo(int $x, int $y){ return $x + $y;}
echo foo('1', 2);
Strict
STH
CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 10/9/15 - 19 / 38
www.galvao.eti.brTudo o que você precisa saber sobre PHP7
Resultado:
Fatal error: Uncaught TypeError: Argument 1 passed to foo() must be of the type integer, string given, called in /home/vagrant/php7tests/t1.php on line 9 and defined in /home/vagrant/php7tests/t1.php:4
Stack trace:#0 /home/vagrant/php7tests/t1.php(9): foo('1', 2)#1 {main} thrown in /home/vagrant/php7tests/t1.php on line 4
STH
CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 10/9/15 - 20 / 38
www.galvao.eti.brTudo o que você precisa saber sobre PHP7
Resultado:
Fatal error: Uncaught TypeError: Argument 1 passed to foo() must be of the type integer, string given, called in /home/vagrant/php7tests/t1.php on line 9 and defined in /home/vagrant/php7tests/t1.php:4
Stack trace:#0 /home/vagrant/php7tests/t1.php(9): foo('1', 2)#1 {main} thrown in /home/vagrant/php7tests/t1.php on line 4
Return Type Declarations
CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 10/9/15 - 21 / 38
www.galvao.eti.brTudo o que você precisa saber sobre PHP7