Доклад с PUG#7 https://www.facebook.com/events/772501586209518/
- Введение в PHP7. Почему стоит смотреть в эту сторону
- Используем PHP7 сейчас
- Нововведения
- Производительность
- “Строгая” типизация в PHP
- Подробный разбор нового механизма работы с ошибками
- Новые возможности для работы с замыканиями
- Синтаксический сахар
10. Unlike parameter type declarations, the type
checking mode used for return types depends
on the file where the function is defined, not
where the function is called. This is because
returning the wrong type is a problem with the
callee, while passing the wrong type is a
problem with the caller.
14. Group use declarations
use somenamespace{ClassA, ClassB, ClassC as C};
use function somenamespace{fn_a, fn_b, fn_c};
use const somenamespace{ConstA, ConstB, ConstC};
22. Exceptions handling
interface Throwable
{
public function getMessage(): string;
public function getCode(): int;
public function getFile(): string;
public function getLine(): int;
public function getTrace(): array;
public function getTraceAsString(): string;
public function getPrevious(): Throwable;
public function __toString(): string;
}
23. How to use it now
try {
// Code that may throw an Exception or Error.
} catch (Throwable $t) {
// Executed only in PHP 7, will not match in PHP 5.x
} catch (Exception $e) {
// Executed only in PHP 5.x, will not be reached in PHP 7
}