SlideShare uma empresa Scribd logo
1 de 38
Baixar para ler offline
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

Mais procurados

Desenvolvimento web: PHP orientado a objetos
Desenvolvimento web: PHP orientado a objetosDesenvolvimento web: PHP orientado a objetos
Desenvolvimento web: PHP orientado a objetos
Lucas Vegi
 
Introdução ao Python & Web Services
Introdução ao Python & Web ServicesIntrodução ao Python & Web Services
Introdução ao Python & Web Services
Dorneles Treméa
 

Mais procurados (20)

PHP na Tela Escura: Aplicações Poderosas em Linha de Comando
PHP na Tela Escura: Aplicações Poderosas em Linha de ComandoPHP na Tela Escura: Aplicações Poderosas em Linha de Comando
PHP na Tela Escura: Aplicações Poderosas em Linha de Comando
 
Desenvolvendo mvp com python
Desenvolvendo mvp com pythonDesenvolvendo mvp com python
Desenvolvendo mvp com python
 
15 coisas sobre php para saber antes de morrer
15 coisas sobre php para saber antes de morrer15 coisas sobre php para saber antes de morrer
15 coisas sobre php para saber antes de morrer
 
Unbreakeable php
Unbreakeable phpUnbreakeable php
Unbreakeable php
 
Otimizando a execução de código-fonte PHP
Otimizando a execução de código-fonte PHPOtimizando a execução de código-fonte PHP
Otimizando a execução de código-fonte PHP
 
Zend Framework 3 - porque só o que existe pode ser aprimorado
Zend Framework 3 - porque só o que existe pode ser aprimoradoZend Framework 3 - porque só o que existe pode ser aprimorado
Zend Framework 3 - porque só o que existe pode ser aprimorado
 
O futuro do elephante: as promessas do php para 2019
O futuro do elephante: as promessas do php para 2019O futuro do elephante: as promessas do php para 2019
O futuro do elephante: as promessas do php para 2019
 
Zend framework 3 Hangout 2016
Zend framework 3 Hangout 2016Zend framework 3 Hangout 2016
Zend framework 3 Hangout 2016
 
Rumo à Certificação PHP
Rumo à Certificação PHPRumo à Certificação PHP
Rumo à Certificação PHP
 
Desenvolvimento web: PHP orientado a objetos
Desenvolvimento web: PHP orientado a objetosDesenvolvimento web: PHP orientado a objetos
Desenvolvimento web: PHP orientado a objetos
 
Frameworks PHP
Frameworks PHPFrameworks PHP
Frameworks PHP
 
[FISL 16] PHP no Campo de Batalha: Segurança Avançada e Programação Defensiva...
[FISL 16] PHP no Campo de Batalha: Segurança Avançada e Programação Defensiva...[FISL 16] PHP no Campo de Batalha: Segurança Avançada e Programação Defensiva...
[FISL 16] PHP no Campo de Batalha: Segurança Avançada e Programação Defensiva...
 
Como fazer boas libs
Como fazer boas libs Como fazer boas libs
Como fazer boas libs
 
O que esperar do Zend Framework 3
O que esperar do Zend Framework 3O que esperar do Zend Framework 3
O que esperar do Zend Framework 3
 
Pog Nunca Mais - Técnicas e Macetes para o Desenvolvimento em PHP
Pog Nunca Mais - Técnicas e Macetes para o Desenvolvimento em PHPPog Nunca Mais - Técnicas e Macetes para o Desenvolvimento em PHP
Pog Nunca Mais - Técnicas e Macetes para o Desenvolvimento em PHP
 
Introdução ao Python & Web Services
Introdução ao Python & Web ServicesIntrodução ao Python & Web Services
Introdução ao Python & Web Services
 
Conceitos básicos PHP
Conceitos básicos PHPConceitos básicos PHP
Conceitos básicos PHP
 
PHP Jedi - Boas Práticas e Alta Performance
PHP Jedi - Boas Práticas e Alta PerformancePHP Jedi - Boas Práticas e Alta Performance
PHP Jedi - Boas Práticas e Alta Performance
 
Objects calisthenics - Os 10 mandamentos do rei do código
Objects calisthenics - Os 10 mandamentos do rei do códigoObjects calisthenics - Os 10 mandamentos do rei do código
Objects calisthenics - Os 10 mandamentos do rei do código
 
Introdução PHP + Kohana 3
Introdução PHP + Kohana 3Introdução PHP + Kohana 3
Introdução PHP + Kohana 3
 

Destaque (7)

Visibilidade e Diagrama de Classe de Projeto na UML
Visibilidade e Diagrama de Classe de Projeto na UMLVisibilidade e Diagrama de Classe de Projeto na UML
Visibilidade e Diagrama de Classe de Projeto na UML
 
Fundamentos de algoritmos e programação - Fortran
Fundamentos de algoritmos e programação - FortranFundamentos de algoritmos e programação - Fortran
Fundamentos de algoritmos e programação - Fortran
 
Diagrama de classe
Diagrama de classeDiagrama de classe
Diagrama de classe
 
Desenvolvendo sistemas seguros com PHP
Desenvolvendo sistemas seguros com PHPDesenvolvendo sistemas seguros com PHP
Desenvolvendo sistemas seguros com PHP
 
Memorias de um sargento
Memorias de um sargentoMemorias de um sargento
Memorias de um sargento
 
1 Aula De Dreamweaver
1 Aula De Dreamweaver1 Aula De Dreamweaver
1 Aula De Dreamweaver
 
Diagrama de Classe: Relacionamento de Composição
Diagrama de Classe: Relacionamento de ComposiçãoDiagrama de Classe: Relacionamento de Composição
Diagrama de Classe: Relacionamento de Composição
 

Semelhante a Tudo o que você precisa saber sobre o php7

Aprender PHP e mySQL (UFCD0155)
Aprender PHP e mySQL (UFCD0155)Aprender PHP e mySQL (UFCD0155)
Aprender PHP e mySQL (UFCD0155)
Afonso Gomes
 
Php Test Fest PHPMS, Maio 2008
Php Test Fest PHPMS, Maio 2008Php Test Fest PHPMS, Maio 2008
Php Test Fest PHPMS, Maio 2008
zehzinho
 

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

PHP: Evolução
PHP: EvoluçãoPHP: Evolução
PHP: Evolução
 
Aprender PHP e mySQL (UFCD0155)
Aprender PHP e mySQL (UFCD0155)Aprender PHP e mySQL (UFCD0155)
Aprender PHP e mySQL (UFCD0155)
 
Mapeamento Objeto Relacional com PHP - PHP Conference Brasil 2010
Mapeamento Objeto Relacional com PHP - PHP Conference Brasil 2010Mapeamento Objeto Relacional com PHP - PHP Conference Brasil 2010
Mapeamento Objeto Relacional com PHP - PHP Conference Brasil 2010
 
Php Test Fest PHPMS, Maio 2008
Php Test Fest PHPMS, Maio 2008Php Test Fest PHPMS, Maio 2008
Php Test Fest PHPMS, Maio 2008
 
Palestra Zend Framework PHPSC Conf 2010
Palestra Zend Framework PHPSC Conf 2010Palestra Zend Framework PHPSC Conf 2010
Palestra Zend Framework PHPSC Conf 2010
 
Desenvolvendo aplicações web com python e web2py
Desenvolvendo aplicações web com python e web2pyDesenvolvendo aplicações web com python e web2py
Desenvolvendo aplicações web com python e web2py
 
Linguagem PHP
Linguagem PHPLinguagem PHP
Linguagem PHP
 
Desenvolvendo aplicações com ZF2
Desenvolvendo aplicações com ZF2Desenvolvendo aplicações com ZF2
Desenvolvendo aplicações com ZF2
 
Muito prazer, eu sou PHP
Muito prazer, eu sou PHPMuito prazer, eu sou PHP
Muito prazer, eu sou PHP
 
Apresentacao frameworks
Apresentacao frameworksApresentacao frameworks
Apresentacao frameworks
 
Mini Curso de PHP
Mini Curso de PHPMini Curso de PHP
Mini Curso de PHP
 
Web: funcionamento, evolução e mercado
Web: funcionamento, evolução e mercadoWeb: funcionamento, evolução e mercado
Web: funcionamento, evolução e mercado
 
M5-Desenvolvimento-Paginas-Web
M5-Desenvolvimento-Paginas-WebM5-Desenvolvimento-Paginas-Web
M5-Desenvolvimento-Paginas-Web
 
Código legado - PHP Conference Brasil - 2014
Código legado - PHP Conference Brasil - 2014Código legado - PHP Conference Brasil - 2014
Código legado - PHP Conference Brasil - 2014
 
Dicas para aumentar a performance de um software PHP
Dicas para aumentar a performance de um software PHPDicas para aumentar a performance de um software PHP
Dicas para aumentar a performance de um software PHP
 
Rest fuuuu front-end
Rest fuuuu front-endRest fuuuu front-end
Rest fuuuu front-end
 
PHPBR TestFest
PHPBR TestFestPHPBR TestFest
PHPBR TestFest
 
PHPSP TestFest 2010
PHPSP TestFest 2010PHPSP TestFest 2010
PHPSP TestFest 2010
 
Aula 01 - Curso PHP e MySQL
Aula 01 - Curso PHP e MySQLAula 01 - Curso PHP e MySQL
Aula 01 - Curso PHP e MySQL
 
ReSTFul Api's com FRAPI
ReSTFul Api's com FRAPIReSTFul Api's com FRAPI
ReSTFul Api's com FRAPI
 

Mais de Er Galvão Abbott

Mais de Er Galvão Abbott (15)

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

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