Php7 e além

44
PHP7 e além Maturidade, Comunidade e Visibilidade Anderson Casimiro @duodraco

Transcript of Php7 e além

Page 1: Php7 e além

PHP7 e alémMaturidade, Comunidade e Visibilidade

Anderson Casimiro@duodraco

Page 2: Php7 e além

Agenda

História

Chegamos ao Se7e…

Principais funcionalidades

Ecossistema

O que vem por aí?

Page 3: Php7 e além
Page 4: Php7 e além

1995 ~ 2004

PHP, FI, 3, 4

Bad Times...

Page 5: Php7 e além

5 2004

Page 6: Php7 e além

5

OOP Melhorada

Standard PHP Library

PDO, DateTime …

Namespaces

Anonymous Functions

Traits

Generators (yield)

Yearly Releases

Performance

Page 7: Php7 e além

Chegamos ao Se7e...

HipHop

Especificação do PHP

HHVM

Hack

php-src/tree/phpng

Page 8: Php7 e além

e o PHP 6?

Page 9: Php7 e além

O que é o ?

Page 10: Php7 e além

Performance

Page 11: Php7 e além

source: http://www.zend.com/en/resources/php7_infographic

Page 12: Php7 e além

source: http://www.zend.com/en/resources/php7_infographic

Page 13: Php7 e além

source: http://www.zend.com/en/resources/php7_infographic

Page 14: Php7 e além

Mudanças na Sintaxe

Page 15: Php7 e além

Null coalescing

Spaceship

Group use

Unicode escaping

/* PHP5 */$route = $_SERVER['request_uri'] ?:'/index';

/* não está bom… vamos tentar de novo */$route = isset($_SERVER['request_uri'])? $_SERVER['request_uri'] : '/index';

/* PHP7 */$route = $_SERVER['request_uri'] ?? '/index';

Page 16: Php7 e além

Null coalescing

Spaceship

Group use

Unicode escaping

echo 1 <=> 1; // 0echo 2 <=> 1; // 1echo 1 <=> 2; // -1

echo 'scala' <=> 'php'; // -1echo 'php' <=> 'javascript'; // 1echo 'A' <=> 'A'; // 0

$today = new DateTime;$someDay = new DateTime('1981-06-15');echo $today <=> $someDay; // 1

//Alguém aqui lembrou da função usort()?

Page 17: Php7 e além

Null coalescing

Spaceship

Group use

Unicode escaping

use \PHPSP\Talks\Evino\People\{

Attendee,

Speaker,

Staff as PeopleToThankFor

};

Page 18: Php7 e além

Null coalescing

Spaceship

Group use

Unicode escaping

html_entity_decode('&#x10084', 0, 'UTF-8');

mb_convert_encoding('&#x10084', 'UTF-8', 'HTML-ENTITIES');

json_decode('"\\u2764"');

"\u{2764}"

Page 19: Php7 e além

Error Handling

Page 20: Php7 e além

<<interface>>Throwable

Error Exception

AssertionError

TypeErrorRuntimeException

ErrorException

ArtithmeticError

DivisionByZeroError

ParseError

Page 21: Php7 e além

try{ $object = new Test();} catch(\Exception $e){ // Exception logic} catch(\Error $err) { // Error logic} catch(\Throwable $t) { // Error or Exception logic}

Page 22: Php7 e além

Anonymous Classes

Page 23: Php7 e além

interface Logger { public function log(string $msg);}

class Application { private $logger; public function setLogger(Logger $logger) { $this->logger = $logger; }}

$app = new Application;$app->setLogger(new class implements Logger { public function log(string $msg) { echo $msg; }});

Page 24: Php7 e além

Scalar Type Hinting + Return Type Declaration

Page 25: Php7 e além

function buildUser(string $name, int ?$age): User { $user = new User(); $user->setName($name); $user->setAge($age ?? 18); return $user; }

declare(strict_types = 1);

Page 26: Php7 e além

$zoeira = “”;

$apelido = function () use (&$zoeira): void{ $zoeirasDisponiveis = [

'Baladinha top','PHP é fraco, não é tipado','PHP moleque, pé no chão'

];$qual = rand(0, 3);

$zoeira = $zoeirasDisponiveis[$qual];}

echo $zoeira();

Page 27: Php7 e além

Iterable

Page 28: Php7 e além

function plotarResultado(Iterable $colecao = []){ foreach($colecao as $item){ echo (string) $item; }}

$array = [/* ... */];

$statement = $pdo->execute();

plotarResultado($array);

plotarResultado($statement);

Page 29: Php7 e além

Mais sobre o 7

Page 30: Php7 e além

Árvore Abstrata de Sintaxe (AST)

Suporte completo a 64 bits

Gerenciamento de memória

Thread safety sem perdas

Estruturas internas de dados otimizadas

Page 31: Php7 e além

Closure::call()

unserialize() filtrado

IntlChar

Expectations

Delegação de Generators + expressions de retorno

CSPRNG

intdiv()

Session options

Page 32: Php7 e além

Especificar chaves na função list()

Modificadores de visibilidade de constantes de Classe

Catch para multiplos Throwables

Melhorias no Curl (HTTP/2 Server Push)

Criar Closure de um Callable

Melhorias no PCNTL

Page 33: Php7 e além

Alternative tags

Old style constructors

Uniform variable syntaxOperators + indirect access

Server APIs (SAPI)

Extensionsereg, mssql, mysql, sybase_ct

Quebras de compatibilidade 5 -> 7

bit.ly/php5to7

Page 34: Php7 e além

What’s Next...

Page 35: Php7 e além

Descontinuações a partir do 7.2

bit.ly/depr-php-7-2

__autoload

$php_errormsg

create_function()

mbstring.func_overload

(unset) $var

parse_str($arg1)

gmp_random()

each()

assert(“arg”)

set_error_handler(..., $errcontext)

Page 36: Php7 e além

Criptografia Moderna (libSodium)

Page 37: Php7 e além

Ecossistema PHP

Page 38: Php7 e além

Servidor Web

Page 39: Php7 e além
Page 40: Php7 e além

Aplicações

Page 41: Php7 e além

Empresas

Page 42: Php7 e além

O que vem por aí?

Page 43: Php7 e além

Blood has the same color for everyone

Page 44: Php7 e além

[email protected]

slideshare.net/duodraco

#somostodosphp #comunidadefunciona #manadapoderosa