PHP Göteborg Meetup #5 - 2016-10-06
Rickard Bennison
Active support ends 31 Dec 2016 😱
Two more years of security patches
Almost one year old! 🎉
One more year of active support
Two more years of security patches
Release Candidate 3
To be released in November
function testReturn(): ?string
{
return 'elePHPant';
}
function test(?string $name)
{
var_dump($name);
}
function swap(&$left, &$right) : void
{
if ($left === $right) {
return;
}
$tmp = $left;
$left = $right;
$right = $tmp;
}
$data = [[1, 'Tom'], [2, 'Fred']];
// list() style
list($id1, $name1) = $data[0];
// [] style
[$id1, $name1] = $data[0];
// list() style
foreach ($data as list($id, $name)) {
// logic here with $id and $name
}
// [] style
foreach ($data as [$id, $name]) {
// logic here with $id and $name
}
class ConstDemo
{
const PUBLIC_CONST_A = 1;
public const PUBLIC_CONST_B = 2;
protected const PROTECTED_CONST = 3;
private const PRIVATE_CONST = 4;
}
iterable
pseudo-typefunction iterator(iterable $iter)
{
foreach ($iter as $val) {
//
}
}
try {
// some code
} catch (FirstException | SecondException $e) {
// handle first and second exceptions
}
list()
$data = ["id" => 1, "name" => 'Tom'];
// list() style
list("id" => $id, "name" => $name) = $data;
// [] style
["id" => $id, "name" => $name] = $data;
var_dump("abcdef"[-2]);
var_dump(strpos("aabbcc", "b", -3));
ext/openssl
Closure::fromCallable()
ext/curl