Upgrade to Pro — share decks privately, control downloads, hide ads and more …

PHP Episodio VII: El Despertar de la Fuerza

PHP Episodio VII: El Despertar de la Fuerza

César Suárez Ortega

February 24, 2016
Tweet

More Decks by César Suárez Ortega

Other Decks in Programming

Transcript

  1. Hiphop HPHPc Compilador de PHP a C++  En tiempo de

    ejecución (JIT compiler) HPHPi Intérprete para desarrollo Descontinuado
  2. hhvm Máquina virtual  ¡No es un conversor de código! Compilador

    JIT: PHP a byte code (HHBC)  HHBC en código máquina x64 Optimización al vuelo Detección de zonas calientes
  3. Scalar Type Hints <?php declare(strict_types=1); class ElePHPant { public $name,

    $age, $cuteness, $evil; public function __construct(string $name, int $age, float $cuteness, bool $evil) { $this->name = $name; $this->age = $age; $this->cuteness = $cuteness; $this->evil = $evil; } }
  4. ReturN Type Hints <?php function foo(): array { return [];

    } function foo2(): DateTime { return null; // invalid } function &array_sort(array &$data): array { return $data; }
  5. Spaceship operatoR // Si $a < $b devuelve -1 //

    Si $a = $b devuelve 0 // Si $a > $b devuelve 1 function compare(int $a, int $b): int { return $a <=> $b; } unicode codePoint echo "\u{9999}"; //prints 香
  6. Null coalesce operator $var = $value1 ?? $value2 ?? $value3;

    Bind closure on Call $three = new Value(3); $four = new Value(4); $closure = function ($delta) { var_dump($this->getValue() + $delta); }; $closure->call($three, 4); // prints 7 $closure->call($four, 4); // prints 8
  7. Group use declarations use Doctrine\Common\Collections\Expr\Comparison; use Doctrine\Common\Collections\Expr\Value; use Doctrine\Common\Collections\Expr\CompositeExpression; use

    Doctrine\Common\Collections\Expr\{ Comparison, Value, CompositeExpression }; Anonymous classes $util->setLogger(new class { public function log($msg) { echo $msg; } });
  8. Engine exceptions BaseException (abstract) ├── Exception extends BaseException ├── ErrorException

    extends Exception └── RuntimeException extends Exception └── EngineException extends BaseException ├── TypeException extends EngineException ├── ParseException extends EngineException └── AssertionError extends EngineException