-
-
Save Danack/49c6e39a97cfcd978388276649682e7a to your computer and use it in GitHub Desktop.
auto vs explicit unboxing.
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 | |
// a function in the email api library we're using. | |
function sendEmail(string $email, string $body, string $subject) {} | |
// A function in our application | |
function foo(EmailString $es, NameString $ns) | |
{ | |
$body = "Hello " . $ns; | |
sendEmail($es, $body, "howdy"); | |
} | |
// vs A function in our application with unboxing. | |
function foo(EmailString $es, NameString $ns) | |
{ | |
$body = "Hello " . $ns->unbox(); | |
sendEmail($es->unbox(), $body, "howdy"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment