Last active
May 15, 2018 06:35
-
-
Save TijmenWierenga/a2b73a0725147da391ef4438756d3731 to your computer and use it in GitHub Desktop.
PHP strongly typed arrays with a required length of one
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function save(User $user, User ...$users): void | |
{ | |
$users[] = $user; | |
foreach ($users as $user) { | |
// Save the user | |
} | |
} | |
$users = [ | |
new User('Tijmen'), | |
new User('Paul'), | |
new User('Bart') | |
]; | |
save(...$users); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment