$book = ['The title', 'the author'];
// Old version
list($title, $author) = $book;
// In new version
[$title, $author] = $book;
// Complex array.
$books = [
['title' => 'Chernovik', 'author' => 'Lukjznenko'],
['title' => 'Dnevnow Dozor', 'author' => 'Lukjznenko'],
];
['title' => $book, 'author' => $author] = $books[0];
foreach ($books as ['title' => $book, 'author' => $author]) {
var_dump($title, $author);
}
class User{
protected $age;
public public function age() : ?int
{
return $this->age;
}
public function subscribe(?callable $callback) {
var_dump('subcribe here');
$callback();
}
}
$age = (new User)->age();
var_dump($age);
(new User)->subscribe(function() {
var_dump('respond here');
});
//or
(new User)->subscribe(null);