SlideShare uma empresa Scribd logo
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
Presidente da ABRAPHP – Associação Brasileira de Profissionais PHP
Diretor da PHP Conference Brasil
Contribui 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 internacionais
Instrutor de cursos presenciais e a distância
Fundador e líder do GU PHPBR
Fundador* e membro do GU PHPRS
Site: http://www.galvao.eti.br/
http://people.php.net/galvao
Twitter: @galvao
Slides e Documentos: http://slideshare.net/ergalvao
https://speakerdeck.com/galvao
Github: http://github.com/galvao
Posts: 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
Sumário
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 Operator
NULL Coalesce Operator
Group Use Declarations
Scalar Type Hints
Return Type Declarations
Exceptions in the engine
CSPRNG
Arrays Constantes
R.I.P.
mysql
Tags
Construtor 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
- Método ninja para encontrar benchmarks de PHP7
F.A.Q.
CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 10/9/15 - 5 / 38
www.galvao.eti.brTudo o que você precisa saber sobre PHP7
PHP6?
F.A.Q.
CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 10/9/15 - 6 / 38
www.galvao.eti.brTudo o que você precisa saber sobre PHP7
ISSO NON
EXZISTE!
PHP6?
F.A.Q.
CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 10/9/15 - 7 / 38
www.galvao.eti.br
https://github.com/rlerdorf/php7dev
Quero agora!
Tudo o que você precisa saber sobre PHP7
F.A.Q.
CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 10/9/15 - 8 / 38
www.galvao.eti.brTudo o que você precisa saber sobre PHP7
F.A.Q.
CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 10/9/15 - 9 / 38
www.galvao.eti.brTudo o que você precisa saber sobre PHP7
X
F.A.Q.
CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 10/9/15 - 10 / 38
www.galvao.eti.brTudo o que você precisa saber sobre PHP7
https://wiki.php.net/rfc
Karma
RFC Debate
Mudanças
Votação
Aprovação
Rejeição
*
Spaceship Operator
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
P
ew
!
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 → 1
1 <=> 1 → 0
P
ew
!
P
ew
!
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 → 1
1 <=> 1 → 0
0 <=> 1 → -1 P
ew
!
P
ew
!
P
ew
!
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 FooBar;
use FooBaz;
use FooQuux;
use Foo{Bar, Baz, Quux};
use Foo{
BarThud,
BazGruntBletch,
QuuxFum
};
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
<?php
function 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
<?php
declare(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
<?php
function foo($x,$y):int
{
return (string)($x + $y);
}
echo foo(1, 2);
Resultado: 3
Coercive
Return Type Declarations
CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 10/9/15 - 22 / 38
www.galvao.eti.brTudo o que você precisa saber sobre PHP7
<?php
declare(strict_types=1);
function foo($x,$y):int
{
return (string)($x + $y);
}
echo foo(1, 2);
Strict
Return Type Declarations
CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 10/9/15 - 23 / 38
www.galvao.eti.brTudo o que você precisa saber sobre PHP7
Resultado:
Fatal error: Uncaught TypeError: Return value of foo()
must be of the type integer, string returned in
/home/vagrant/php7tests/t2.php:6
Stack trace:
#0 /home/vagrant/php7tests/t2.php(9): foo(1, 2)
#1 {main}
thrown in /home/vagrant/php7tests/t2.php on line 6
Return Type Declarations
CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 10/9/15 - 24 / 38
www.galvao.eti.brTudo o que você precisa saber sobre PHP7
Resultado:
Fatal error: Uncaught TypeError: Return value of foo()
must be of the type integer, string returned in
/home/vagrant/php7tests/t2.php:6
Stack trace:
#0 /home/vagrant/php7tests/t2.php(9): foo(1, 2)
#1 {main}
thrown in /home/vagrant/php7tests/t2.php on line 6
Exceptions in the Engine
CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 10/9/15 - 25 / 38
www.galvao.eti.brTudo o que você precisa saber sobre PHP7
<?php
$foo = 0;
try {
$foo->bar();
} catch (Throwable $e) {
die($e->getMessage());
}
Exceptions in the Engine
CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 10/9/15 - 26 / 38
www.galvao.eti.brTudo o que você precisa saber sobre PHP7
<?php
declare(strict_types=1);
function foo($x,$y):int
{
return (string)($x + $y);
}
try {
echo foo(1, 2);
} catch (TypeError $e) {
die($e->getMessage());
}
CSPRNG
CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 10/9/15 - 27 / 38
www.galvao.eti.brTudo o que você precisa saber sobre PHP7
string random_bytes(int $length)
int random_int(int $min, int $max)
Facilitar o acesso a Criptografia!
Lançam uma Error Exception se a aleatoriedade
for insuficiente
Arrays Constantes
CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 10/9/15 - 28 / 38
www.galvao.eti.brTudo o que você precisa saber sobre PHP7
<?php
define('DB_USER', 'foo');
define('DB_PASS', 'bar');
define('DB_HOST', 'localhost');
define('DB_NAME', 'baz');
define('DB_PORT', 3306);
PHP5
Arrays Constantes
CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 10/9/15 - 29 / 38
www.galvao.eti.brTudo o que você precisa saber sobre PHP7
<?php
define('DB', ['USER' => 'foo',
'PASS' => 'bar',
'HOST' => 'localhost',
'NAME' => 'baz',
'PORT' => 3306]
);
PHP7
R.I.P
CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 10/9/15 - 30 / 38
www.galvao.eti.br
<% %>
<script language=”php”>
public function nome_da_classe()
mysql_
Tudo o que você precisa saber sobre PHP7
R.I.P
CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 10/9/15 - 31 / 38
www.galvao.eti.brTudo o que você precisa saber sobre PHP7
<% %>
<script language=”php”>
public function nome_da_classe()
mysql_
R.I.P
CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 10/9/15 - 32 / 38
www.galvao.eti.brTudo o que você precisa saber sobre PHP7
DEFINITELY!
<% %>
<script language=”php”>
public function nome_da_classe()
mysql_
R.I.P
CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 10/9/15 - 33 / 38
www.galvao.eti.brTudo o que você precisa saber sobre PHP7
Oh God, YES!
<% %>
<script language=”php”>
public function nome_da_classe()
mysql_
R.I.P
CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 10/9/15 - 34 / 38
www.galvao.eti.br
<% %>
<script language=”php”>
public function nome_da_classe()
mysql_
Tudo o que você precisa saber sobre PHP7
Ahn… well… kinda, yeah!
R.I.P
CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 10/9/15 - 35 / 38
www.galvao.eti.br
<% %>
<script language=”php”>
public function nome_da_classe()
mysql_
Tudo o que você precisa saber sobre PHP7
Not really, but he HAS TO GO!
Já vão TARDE
CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 10/9/15 - 36 / 38
www.galvao.eti.brTudo o que você precisa saber sobre PHP7
INFORME-SE!
CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 10/9/15 - 37 / 38
www.galvao.eti.br
PHP7: More strict! (but only if you want it to be), by myself!
http://bit.ly/php7-more-strict
Referência, by Thomas Punt
https://github.com/tpunt/PHP7-Reference
PHP7 feature freeze, by Phil Sturgeon
https://philsturgeon.uk/php/2015/03/15/php-7-feature-freeze/
An Exceptional Change in PHP 7.0, by Davey Shafik
https://daveyshafik.com/archives/69237-an-exceptional-change-in-php-7-0.html
Tudo o que você precisa saber sobre PHP7
Muito obrigado!
CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 10/9/15 - 38 / 38
www.galvao.eti.br
? Dúvidas?
↓ Críticas?
↑ Elogios?!
Tudo o que você precisa saber sobre PHP7

Mais conteúdo relacionado

PDF
Segurança PHP em 2016
Er Galvão Abbott
 
ODP
Php7 esta chgando! O que você precisa saber
Er Galvão Abbott
 
PDF
DRYing the Skeleton: Reducing code repetition in ZF2
Er Galvão Abbott
 
PPTX
PHP 7 - A Maioridade do PHP
Daniel Archer Marques Cramer
 
PDF
PHP para aplicações Web de grande porte
Felipe Ribeiro
 
PDF
Muito prazer, eu sou PHP
Luís Cobucci
 
PPTX
PHP Além da universidade
Daniel Archer Marques Cramer
 
PDF
Segurança em Aplicações Web com PHP
Gedvan Dias
 
Segurança PHP em 2016
Er Galvão Abbott
 
Php7 esta chgando! O que você precisa saber
Er Galvão Abbott
 
DRYing the Skeleton: Reducing code repetition in ZF2
Er Galvão Abbott
 
PHP 7 - A Maioridade do PHP
Daniel Archer Marques Cramer
 
PHP para aplicações Web de grande porte
Felipe Ribeiro
 
Muito prazer, eu sou PHP
Luís Cobucci
 
PHP Além da universidade
Daniel Archer Marques Cramer
 
Segurança em Aplicações Web com PHP
Gedvan Dias
 

Mais procurados (20)

PDF
PHP na Tela Escura: Aplicações Poderosas em Linha de Comando
Rafael Jaques
 
PDF
Desenvolvendo mvp com python
Bruno Rocha
 
PDF
15 coisas sobre php para saber antes de morrer
Michele Silva
 
PDF
Unbreakeable php
Er Galvão Abbott
 
ODP
Otimizando a execução de código-fonte PHP
Er Galvão Abbott
 
PDF
Zend Framework 3 - porque só o que existe pode ser aprimorado
Flávio Lisboa
 
PDF
O futuro do elephante: as promessas do php para 2019
Cassio Santos
 
PDF
Zend framework 3 Hangout 2016
Flávio Lisboa
 
PPTX
Rumo à Certificação PHP
Ari Stopassola Junior
 
PPT
Desenvolvimento web: PHP orientado a objetos
Lucas Vegi
 
PDF
Frameworks PHP
Augusto Pascutti
 
PDF
[FISL 16] PHP no Campo de Batalha: Segurança Avançada e Programação Defensiva...
Rafael Jaques
 
PDF
Como fazer boas libs
Vinta Software
 
PDF
O que esperar do Zend Framework 3
Flávio Lisboa
 
ZIP
Pog Nunca Mais - Técnicas e Macetes para o Desenvolvimento em PHP
Paulino Michelazzo
 
KEY
Introdução ao Python & Web Services
Dorneles Treméa
 
PDF
Conceitos básicos PHP
Helton Ritter
 
PDF
PHP Jedi - Boas Práticas e Alta Performance
Felipe Ribeiro
 
PDF
Objects calisthenics - Os 10 mandamentos do rei do código
BonoBee
 
PDF
Introdução PHP + Kohana 3
Adir Kuhn
 
PHP na Tela Escura: Aplicações Poderosas em Linha de Comando
Rafael Jaques
 
Desenvolvendo mvp com python
Bruno Rocha
 
15 coisas sobre php para saber antes de morrer
Michele Silva
 
Unbreakeable php
Er Galvão Abbott
 
Otimizando a execução de código-fonte PHP
Er Galvão Abbott
 
Zend Framework 3 - porque só o que existe pode ser aprimorado
Flávio Lisboa
 
O futuro do elephante: as promessas do php para 2019
Cassio Santos
 
Zend framework 3 Hangout 2016
Flávio Lisboa
 
Rumo à Certificação PHP
Ari Stopassola Junior
 
Desenvolvimento web: PHP orientado a objetos
Lucas Vegi
 
Frameworks PHP
Augusto Pascutti
 
[FISL 16] PHP no Campo de Batalha: Segurança Avançada e Programação Defensiva...
Rafael Jaques
 
Como fazer boas libs
Vinta Software
 
O que esperar do Zend Framework 3
Flávio Lisboa
 
Pog Nunca Mais - Técnicas e Macetes para o Desenvolvimento em PHP
Paulino Michelazzo
 
Introdução ao Python & Web Services
Dorneles Treméa
 
Conceitos básicos PHP
Helton Ritter
 
PHP Jedi - Boas Práticas e Alta Performance
Felipe Ribeiro
 
Objects calisthenics - Os 10 mandamentos do rei do código
BonoBee
 
Introdução PHP + Kohana 3
Adir Kuhn
 
Anúncio

Destaque (7)

PPT
Visibilidade e Diagrama de Classe de Projeto na UML
ufpb
 
PPTX
Fundamentos de algoritmos e programação - Fortran
Kennedy Morais Fernandes
 
PPT
Diagrama de classe
Suissa
 
PPTX
Desenvolvendo sistemas seguros com PHP
Flavio Souza
 
PPT
Memorias de um sargento
VitorCazelatto
 
PPT
1 Aula De Dreamweaver
Profe Luiz
 
PDF
Diagrama de Classe: Relacionamento de Composição
marcusNOGUEIRA
 
Visibilidade e Diagrama de Classe de Projeto na UML
ufpb
 
Fundamentos de algoritmos e programação - Fortran
Kennedy Morais Fernandes
 
Diagrama de classe
Suissa
 
Desenvolvendo sistemas seguros com PHP
Flavio Souza
 
Memorias de um sargento
VitorCazelatto
 
1 Aula De Dreamweaver
Profe Luiz
 
Diagrama de Classe: Relacionamento de Composição
marcusNOGUEIRA
 
Anúncio

Semelhante a Tudo o que você precisa saber sobre o php7 (20)

PDF
PHP: Evolução
Er Galvão Abbott
 
PDF
Aprender PHP e mySQL (UFCD0155)
Afonso Gomes
 
PDF
Mapeamento Objeto Relacional com PHP - PHP Conference Brasil 2010
Flávio Lisboa
 
ODP
Php Test Fest PHPMS, Maio 2008
zehzinho
 
PDF
Palestra Zend Framework PHPSC Conf 2010
Flávio Lisboa
 
PDF
phpDSFLKJLFKJSDFJLSFLSFDJLKSFLKSJFSFDJLKJ.pdf
riodurval
 
ODP
Desenvolvendo aplicações web com python e web2py
Gilson Filho
 
PDF
Linguagem PHP
Bruno Cunha
 
PDF
Desenvolvendo aplicações com ZF2
Er Galvão Abbott
 
PDF
Muito prazer, eu sou PHP
Johnathan Cardoso
 
PDF
Apresentacao frameworks
Er Galvão Abbott
 
ODP
Web: funcionamento, evolução e mercado
Er Galvão Abbott
 
PDF
M5-Desenvolvimento-Paginas-Web
diogoa21
 
PDF
Código legado - PHP Conference Brasil - 2014
Michael Castillo Granados
 
PDF
Dicas para aumentar a performance de um software PHP
Almir Neto
 
PDF
php1_LLKSDHFLSHDFLSFLJSFLSJFLSJFLSJFLSJF.pdf
riodurval
 
PDF
Rest fuuuu front-end
Igor Santos
 
PDF
PHPBR TestFest
Er Galvão Abbott
 
PPTX
PHPSP TestFest 2010
Rafael Dohms
 
PHP: Evolução
Er Galvão Abbott
 
Aprender PHP e mySQL (UFCD0155)
Afonso Gomes
 
Mapeamento Objeto Relacional com PHP - PHP Conference Brasil 2010
Flávio Lisboa
 
Php Test Fest PHPMS, Maio 2008
zehzinho
 
Palestra Zend Framework PHPSC Conf 2010
Flávio Lisboa
 
phpDSFLKJLFKJSDFJLSFLSFDJLKSFLKSJFSFDJLKJ.pdf
riodurval
 
Desenvolvendo aplicações web com python e web2py
Gilson Filho
 
Linguagem PHP
Bruno Cunha
 
Desenvolvendo aplicações com ZF2
Er Galvão Abbott
 
Muito prazer, eu sou PHP
Johnathan Cardoso
 
Apresentacao frameworks
Er Galvão Abbott
 
Web: funcionamento, evolução e mercado
Er Galvão Abbott
 
M5-Desenvolvimento-Paginas-Web
diogoa21
 
Código legado - PHP Conference Brasil - 2014
Michael Castillo Granados
 
Dicas para aumentar a performance de um software PHP
Almir Neto
 
php1_LLKSDHFLSHDFLSFLJSFLSJFLSJFLSJFLSJF.pdf
riodurval
 
Rest fuuuu front-end
Igor Santos
 
PHPBR TestFest
Er Galvão Abbott
 
PHPSP TestFest 2010
Rafael Dohms
 

Mais de Er Galvão Abbott (15)

ODP
PHP e Open Source
Er Galvão Abbott
 
PDF
ABRAPHP: Conquistas e Realizações - 2012-2014
Er Galvão Abbott
 
ODP
Implementing security routines with zf2
Er Galvão Abbott
 
PDF
ZF2 Menor, melhor e mais poderoso
Er Galvão Abbott
 
ODP
Implementando rotinas de geolocalização
Er Galvão Abbott
 
ODP
OSS, Comunidade, Eventos e como sua empresa ganha com isso
Er Galvão Abbott
 
ODP
OWASP: O que, Por que e Como
Er Galvão Abbott
 
PDF
Além da autenticação: Permissões de acesso com Zend Framework
Er Galvão Abbott
 
PDF
Proposta de Boas Práticas e Padrões de Desenvolvimento Web
Er Galvão Abbott
 
PDF
Preto, Branco e as Sombras de Cinza
Er Galvão Abbott
 
PDF
Top 10 OWASP com PHP
Er Galvão Abbott
 
PDF
Aplicacoes Web Com AJAX
Er Galvão Abbott
 
PDF
Implementando Segurança Em Sua Aplicação PHP
Er Galvão Abbott
 
PDF
Prevenindo XSS: Execute apenas o SEU código
Er Galvão Abbott
 
PDF
PHP e Segurança - Uma união possível
Er Galvão Abbott
 
PHP e Open Source
Er Galvão Abbott
 
ABRAPHP: Conquistas e Realizações - 2012-2014
Er Galvão Abbott
 
Implementing security routines with zf2
Er Galvão Abbott
 
ZF2 Menor, melhor e mais poderoso
Er Galvão Abbott
 
Implementando rotinas de geolocalização
Er Galvão Abbott
 
OSS, Comunidade, Eventos e como sua empresa ganha com isso
Er Galvão Abbott
 
OWASP: O que, Por que e Como
Er Galvão Abbott
 
Além da autenticação: Permissões de acesso com Zend Framework
Er Galvão Abbott
 
Proposta de Boas Práticas e Padrões de Desenvolvimento Web
Er Galvão Abbott
 
Preto, Branco e as Sombras de Cinza
Er Galvão Abbott
 
Top 10 OWASP com PHP
Er Galvão Abbott
 
Aplicacoes Web Com AJAX
Er Galvão Abbott
 
Implementando Segurança Em Sua Aplicação PHP
Er Galvão Abbott
 
Prevenindo XSS: Execute apenas o SEU código
Er Galvão Abbott
 
PHP e Segurança - Uma união possível
Er Galvão Abbott
 

Tudo o que você precisa saber sobre o php7

  • 1. 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
  • 2. Presidente da ABRAPHP – Associação Brasileira de Profissionais PHP Diretor da PHP Conference Brasil Contribui 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 internacionais Instrutor de cursos presenciais e a distância Fundador e líder do GU PHPBR Fundador* e membro do GU PHPRS Site: http://www.galvao.eti.br/ http://people.php.net/galvao Twitter: @galvao Slides e Documentos: http://slideshare.net/ergalvao https://speakerdeck.com/galvao Github: http://github.com/galvao Posts: 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
  • 3. Sumário 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 Operator NULL Coalesce Operator Group Use Declarations Scalar Type Hints Return Type Declarations Exceptions in the engine CSPRNG Arrays Constantes R.I.P. mysql Tags Construtor estilo PHP4 Features
  • 4. 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 - Método ninja para encontrar benchmarks de PHP7
  • 5. F.A.Q. CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 10/9/15 - 5 / 38 www.galvao.eti.brTudo o que você precisa saber sobre PHP7 PHP6?
  • 6. F.A.Q. CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 10/9/15 - 6 / 38 www.galvao.eti.brTudo o que você precisa saber sobre PHP7 ISSO NON EXZISTE! PHP6?
  • 7. F.A.Q. CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 10/9/15 - 7 / 38 www.galvao.eti.br https://github.com/rlerdorf/php7dev Quero agora! Tudo o que você precisa saber sobre PHP7
  • 8. F.A.Q. CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 10/9/15 - 8 / 38 www.galvao.eti.brTudo o que você precisa saber sobre PHP7
  • 9. F.A.Q. CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 10/9/15 - 9 / 38 www.galvao.eti.brTudo o que você precisa saber sobre PHP7 X
  • 10. F.A.Q. CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 10/9/15 - 10 / 38 www.galvao.eti.brTudo o que você precisa saber sobre PHP7 https://wiki.php.net/rfc Karma RFC Debate Mudanças Votação Aprovação Rejeição *
  • 11. Spaceship Operator 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
  • 12. CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 10/9/15 - 12 / 38 www.galvao.eti.br 1 <=> 0 → 1 P ew ! Tudo o que você precisa saber sobre PHP7 Spaceship Operator
  • 13. CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 10/9/15 - 13 / 38 www.galvao.eti.br 1 <=> 0 → 1 1 <=> 1 → 0 P ew ! P ew ! Tudo o que você precisa saber sobre PHP7 Spaceship Operator
  • 14. CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 10/9/15 - 14 / 38 www.galvao.eti.br 1 <=> 0 → 1 1 <=> 1 → 0 0 <=> 1 → -1 P ew ! P ew ! P ew ! Tudo o que você precisa saber sobre PHP7 Spaceship Operator
  • 15. 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
  • 16. 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 FooBar; use FooBaz; use FooQuux; use Foo{Bar, Baz, Quux}; use Foo{ BarThud, BazGruntBletch, QuuxFum };
  • 17. 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 <?php function foo(int $x, int $y) { return $x + $y; } echo foo('1', 2); Coercive Resultado: 3
  • 18. 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 <?php declare(strict_types=1); function foo(int $x, int $y) { return $x + $y; } echo foo('1', 2); Strict
  • 19. 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
  • 20. 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
  • 21. 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 <?php function foo($x,$y):int { return (string)($x + $y); } echo foo(1, 2); Resultado: 3 Coercive
  • 22. Return Type Declarations CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 10/9/15 - 22 / 38 www.galvao.eti.brTudo o que você precisa saber sobre PHP7 <?php declare(strict_types=1); function foo($x,$y):int { return (string)($x + $y); } echo foo(1, 2); Strict
  • 23. Return Type Declarations CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 10/9/15 - 23 / 38 www.galvao.eti.brTudo o que você precisa saber sobre PHP7 Resultado: Fatal error: Uncaught TypeError: Return value of foo() must be of the type integer, string returned in /home/vagrant/php7tests/t2.php:6 Stack trace: #0 /home/vagrant/php7tests/t2.php(9): foo(1, 2) #1 {main} thrown in /home/vagrant/php7tests/t2.php on line 6
  • 24. Return Type Declarations CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 10/9/15 - 24 / 38 www.galvao.eti.brTudo o que você precisa saber sobre PHP7 Resultado: Fatal error: Uncaught TypeError: Return value of foo() must be of the type integer, string returned in /home/vagrant/php7tests/t2.php:6 Stack trace: #0 /home/vagrant/php7tests/t2.php(9): foo(1, 2) #1 {main} thrown in /home/vagrant/php7tests/t2.php on line 6
  • 25. Exceptions in the Engine CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 10/9/15 - 25 / 38 www.galvao.eti.brTudo o que você precisa saber sobre PHP7 <?php $foo = 0; try { $foo->bar(); } catch (Throwable $e) { die($e->getMessage()); }
  • 26. Exceptions in the Engine CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 10/9/15 - 26 / 38 www.galvao.eti.brTudo o que você precisa saber sobre PHP7 <?php declare(strict_types=1); function foo($x,$y):int { return (string)($x + $y); } try { echo foo(1, 2); } catch (TypeError $e) { die($e->getMessage()); }
  • 27. CSPRNG CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 10/9/15 - 27 / 38 www.galvao.eti.brTudo o que você precisa saber sobre PHP7 string random_bytes(int $length) int random_int(int $min, int $max) Facilitar o acesso a Criptografia! Lançam uma Error Exception se a aleatoriedade for insuficiente
  • 28. Arrays Constantes CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 10/9/15 - 28 / 38 www.galvao.eti.brTudo o que você precisa saber sobre PHP7 <?php define('DB_USER', 'foo'); define('DB_PASS', 'bar'); define('DB_HOST', 'localhost'); define('DB_NAME', 'baz'); define('DB_PORT', 3306); PHP5
  • 29. Arrays Constantes CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 10/9/15 - 29 / 38 www.galvao.eti.brTudo o que você precisa saber sobre PHP7 <?php define('DB', ['USER' => 'foo', 'PASS' => 'bar', 'HOST' => 'localhost', 'NAME' => 'baz', 'PORT' => 3306] ); PHP7
  • 30. R.I.P CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 10/9/15 - 30 / 38 www.galvao.eti.br <% %> <script language=”php”> public function nome_da_classe() mysql_ Tudo o que você precisa saber sobre PHP7
  • 31. R.I.P CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 10/9/15 - 31 / 38 www.galvao.eti.brTudo o que você precisa saber sobre PHP7 <% %> <script language=”php”> public function nome_da_classe() mysql_
  • 32. R.I.P CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 10/9/15 - 32 / 38 www.galvao.eti.brTudo o que você precisa saber sobre PHP7 DEFINITELY! <% %> <script language=”php”> public function nome_da_classe() mysql_
  • 33. R.I.P CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 10/9/15 - 33 / 38 www.galvao.eti.brTudo o que você precisa saber sobre PHP7 Oh God, YES! <% %> <script language=”php”> public function nome_da_classe() mysql_
  • 34. R.I.P CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 10/9/15 - 34 / 38 www.galvao.eti.br <% %> <script language=”php”> public function nome_da_classe() mysql_ Tudo o que você precisa saber sobre PHP7 Ahn… well… kinda, yeah!
  • 35. R.I.P CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 10/9/15 - 35 / 38 www.galvao.eti.br <% %> <script language=”php”> public function nome_da_classe() mysql_ Tudo o que você precisa saber sobre PHP7 Not really, but he HAS TO GO!
  • 36. Já vão TARDE CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 10/9/15 - 36 / 38 www.galvao.eti.brTudo o que você precisa saber sobre PHP7
  • 37. INFORME-SE! CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 10/9/15 - 37 / 38 www.galvao.eti.br PHP7: More strict! (but only if you want it to be), by myself! http://bit.ly/php7-more-strict Referência, by Thomas Punt https://github.com/tpunt/PHP7-Reference PHP7 feature freeze, by Phil Sturgeon https://philsturgeon.uk/php/2015/03/15/php-7-feature-freeze/ An Exceptional Change in PHP 7.0, by Davey Shafik https://daveyshafik.com/archives/69237-an-exceptional-change-in-php-7-0.html Tudo o que você precisa saber sobre PHP7
  • 38. Muito obrigado! CC Attribution-ShareAlike 3.0 Unported License by Er Galvão Abbott - 10/9/15 - 38 / 38 www.galvao.eti.br ? Dúvidas? ↓ Críticas? ↑ Elogios?! Tudo o que você precisa saber sobre PHP7