Slide 1

Slide 1 text

Slide 2

Slide 2 text

PHP 7 Highlights • Scalar type declarations • Return type declarations • Null coalesce operator ?? • Combined comparison operator <=> • Anonymous classes • Way faster then previous release

Slide 3

Slide 3 text

Scalar Typehints • bool, float, int, string • declare(strict_types=1) • function sum(int $a, int $b) {
 return $a + $b
 }

Slide 4

Slide 4 text

Return type declarations • Same types as for argument type declarations • function sum(int $a, int $b):int {
 return $a + $b
 }

Slide 5

Slide 5 text

Null coalesce operator
 ?? • Because we are lazy and other languages have it • $u = isset($_GET['user']) ? $_GET['user'] : 'nobody';
 
 becomes
 
 $u = $_GET['user'] ?? 'nobody';

Slide 6

Slide 6 text

Combined comparison operator <=> • aka Spaceship operator • sorting the right way • echo 1 <=> 1; // 0
 echo 1 <=> 2; // -1
 echo 2 <=> 1; // 1

Slide 7

Slide 7 text

Anonymous classes • Throwaway objects made easy • Testers rejoice • $app = new Application;
 $app->setLogger(new class implements Logger {
 public function log(string $msg) {
 echo $msg;
 }
 });

Slide 8

Slide 8 text

2X faster?! • PHP Framework Benchmark available on Github: http://rtr.im/y • Virtual machine (2 cores @ 3.4GHz, 4GB RAM) running Ubuntu 14.04 • nginx 1.6 + php-fpm

Slide 9

Slide 9 text

PHP 5.5.15

Slide 10

Slide 10 text

PHP 7.0 RC7

Slide 11

Slide 11 text

FRAMEWORK REQUEST PER SECOND PHP 5.5.15 PHP 7 - RC7 PHALCON-2.0 1469 6605 CI-3.0 314 918 LUMEN-5.1 223 1345 YII-2.0 189 363 SILEX-1.3 486 1822 AURA-2.0 257 1080 CAKE-3.1 174 472 SYMFONY-2.7 167 326 LARAVEL-5.1 80 72 ZF-2.5 40 445

Slide 12

Slide 12 text

• mihai@wisesystems.co • https://twiter.com/redecs • https://facebook.com/redecs
 
 
 
 Mihai Nica ?>